Quick Guide To Tailwind Outline

In this article, we will take a closer look at Tailwind outline classes, and how they can be used to create outlines on your web pages.

Tailwind outlines are a way to highlight elements on a web page, and can be used for a variety of purposes, including:

  • Improving accessibility
  • Indicating focus
  • Providing visual feedback

Tailwind has divided the outline feature into four separate properties, which can be used together or individually to create custom outlines on web pages. These properties include

  1. Outline color.
  2. Outline style.
  3. Outline width.
  4. Outline offset.

Tailwind Outlines

By using these properties, You can create outlines that meet the specific design requirements of your web projects.



Tailwind Outline Color

Tailwind Outline Color allows you to set the color of an outline around an element on a web page.

The color of an outline is an important visual element that can be used to improve accessibility, provide feedback, or indicate focus.

The outline can be used to highlight or emphasize an element, and the color of the outline can be customized using the outline color classes in Tailwind.

Tailwind provides a variety of color options that can be easily applied to an outline using its classes.


Tailwind Outline Color Classes

Tailwind provides a range of classes to set the color of an outline on a web page.

These classes are based on the CSS outline-color property and can be used with any HTML element.

Here are some of the outline color utility classes:

Color ClassesOverview
outline-inheritThe outline color is inherited from the parent element.
outline-currentThe outline color is the same as the text color.
outline-transparentThis is used to make the outline of an element transparent.
outline-blackUsing this class, the outline color of an element is defined as black.
outline-whiteUsed to set an outline color of an element to white.
outline-slate-numThis class is used to apply an outline color to a shade of slate.
outline-gray-numShade of gray color is used for the outline of an element.
outline-zinc-numShade of zinc color is used for the outline of an element
outline-neutral-numThe outline color is specified as a shade of neutral color in Tailwind.
outline-stone-numUsed to set the outline color as a shade of stone color defined in Tailwind.
outline-red-numIn this case, the outline color is set to a shade of red.
outline-orange-numThis class sets the outline color to a shade of orange.
outline-amber-numThe outline color is specified as a shade of amber.
outline-yellow-numShade of yellow color is used for the outline of an element.
outline-lime-numThe outline of an element is colored to a shade of lime using this class.
outline-green-numUsed to set the outline of an element as a shade of green.
outline-emerald-numShades of Tailwind’s emerald color are used for the outline of an element.
outline-teal-numIn this case, the outline of an element is set to a shade of teal.
outline-cyan-numA shade of cyan is used as the outline of an element.
outline-sky-numUsing this class, the outline color of an element is defined as a shade of sky.
outline-blue-numThe outline color is defined as a shade of blue.
outline-indigo-numUsed to set the outline color of an element as a shade of indigo.
outline-violet-numApplies an outline color of a shade of violet to an element.
outline-purple-numThis class applies an outline color of a shade of purple to an element
outline-fuchsia-numA shade of Tailwind’s fuchsia color is used for the outline of an element.
outline-pink-numShade of pink color is used for the outline color of an element.
outline-rose-numThe outline color is specified as a shade of rose.
Note: In place of “num” we can define values such as 50, 100,200 till 900 with increments of 100. Furthermore the outline style needs to be defined in order to use the outline color class. In this case we have used the outline class which specifies the outline as solid.

Syntax

<element class="outline-slate-500">...</element>

To apply an outline color class to an HTML element, simply add the class to the element.

The following example focuses on the implementation of some outline color utility classes in Tailwind:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Outline color class in Tailwind CSS</p> <div class="flex flex-row justify-start flex-wrap gap-4 font-medium mt-4"> <button class="bg-yellow-300 px-4 py-1.5 rounded outline outline-black">outline-black</button> <button class="bg-fuchsia-400 px-4 py-1.5 rounded outline outline-blue-900">outline-blue-900</button> <button class="bg-green-500 px-4 py-1.5 rounded outline outline-teal-900">outline-teal-900</button> <button class="bg-rose-200 px-4 py-1.5 rounded outline outline-violet-700">outline-violet-700</button> <button class="bg-red-500 px-4 py-1.5 text-gray-50 rounded outline outline-slate-800">outline-slate-800</button> </div> </body> </html>
The below example extends the above example and implements further classes of outline color:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Outline color class in Tailwind CSS</p> <div class="flex flex-row justify-start flex-wrap gap-4 font-medium mt-4"> <button class="bg-white px-4 py-1.5 rounded outline outline-current">outline-current</button> <button class="bg-orange-400 px-4 py-1.5 rounded outline outline-neutral-600">outline-neutral-600</button> <button class="bg-neutral-500 px-4 py-1.5 text-gray-50 rounded outline outline-orange-500">outline-orange-500</button> <button class="bg-sky-400 px-4 py-1.5 rounded outline outline-purple-700">outline-purple-700</button> <button class="bg-emerald-500 px-4 py-1.5 rounded outline outline-inherit">outline-inherit</button> </div> </body> </html>

Tailwind Outline Width

Tailwind Outline Width class enables you to set the width of an outline around an element on a web page.

The outline is a line drawn around the outside of an element, outside the border, to make it stand out visually.

Tailwind offers various outline width options that can be applied using its classes.


Tailwind Outline Width Classes

Tailwind offers a variety of classes for defining the width of an outline in a web page.

These classes utilize the CSS outline-width property and are compatible with any HTML element.

The following are some of the outline width classes that Tailwind provides:

Width ClassesOverview
outline-0This class sets the width of the outline to 0px, effectively removing the outline from an element.
outline-1This class is used to define the outline of an element as 1px.
outline-2This class applies an outline of 2px to an element.
outline-4Using this class, the outline of an element is specified as 4px.
outline-8In this case, the outline of an element is defined as 8px
Note: The outline style needs to be defined in order to use the outline width class. In this case we have used the outline class which specifies the outline as solid.

Syntax

<element class="outline-1">...</element>

To apply an outline width class, simply add the class to the element.

In the below example, our target is to understand the working of the outline width utility classes in Tailwind:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Outline width class in Tailwind CSS</p> <div class="flex flex-row justify-start flex-wrap gap-4 font-medium mt-4"> <button class="bg-rose-200 px-4 py-1.5 rounded outline outline-black outline-0">outline-0</button> <button class="bg-orange-400 px-4 py-1.5 rounded outline outline-black outline-1">outline-1</button> <button class="bg-neutral-500 px-4 py-1.5 text-gray-50 rounded outline outline-black outline-2">outline-2</button> <button class="bg-sky-400 px-4 py-1.5 rounded outline outline-black outline-4">outline-4</button> <button class="bg-emerald-500 px-4 py-1.5 rounded outline outline-black outline-8">outline-8</button> </div> </body> </html>

Tailwind Outline Style

Tailwind outline style classes enables you to apply diverse styles to the outline of an element using the CSS outline-style property.

This property specifies the outline style of an element, such as solid, dashed, dotted and double.

Tailwind offers various outline style options that can be applied using its classes.


Tailwind Outline Style Classes

Here are list of Tailwind outline style property classes:

Style ClassesOverview
outline-noneThis class is used to remove the default outline that appears on focused elements in a web page.
outlineThe outline style is set to a solid line.
outline-dashedUsing this class, the outline style is defined as a dashed line.
outline-dottedIn this case, the outline style is specified as a dotted line.
outline-doubleBy using this class, the outline style is set to a double line.

Syntax

<element class="outline-dashed">...</element>

Below example provides a practical overview of the outline style classes in Tailwind:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Outline style class in Tailwind CSS</p> <div class="flex flex-row justify-start flex-wrap gap-4 font-medium mt-4"> <button class="bg-rose-200 px-4 py-1.5 rounded outline-none">outline-none</button> <button class="bg-orange-400 px-4 py-1.5 rounded outline outline-black">outline</button> <button class="bg-neutral-500 px-4 py-1.5 text-gray-50 rounded outline-dashed outline-black">outline-dashed</button> <button class="bg-sky-400 px-4 py-1.5 rounded outline-dotted outline-black">outline-dotted</button> <button class="bg-emerald-500 px-4 py-1.5 rounded outline-double outline-black">outline-double</button> </div> </body> </html>

Tailwind Outline Offset

In Tailwind CSS, the outline-offset utility class allows you to adjust the distance between element’s outline and its border using the CSS outline-offset property.

This property adds space between the element’s outline and its border, which can be useful for creating a visual effect or separating the outline from the content.


Tailwind Outline Offset Classes

Here are some of the outline offset classes provided by Tailwind:

Offset ClassesOverview
outline-offset-0By default, the outline-offset value is 0, which means the outline is drawn directly on top of the border.
outline-offset-1The outline-offset value is set to 1px.
outline-offset-2This class sets the outline offset to 2px.
outline-offset-4This class is used to apply an outline offset of 4px.
outline-offset-8The outline offset is defined as 8px using this class.

Syntax

<element class="outline-offset-1">...</element>

We can refer to the example below for a better visualization of the outline offset class in Tailwind:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="m-3 text-center"> <h1 class="text-gray-700 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2">Outline offset class in Tailwind CSS</p> <div class="flex flex-row justify-start flex-wrap gap-6 font-medium mt-4"> <button class="bg-rose-200 px-4 py-1.5 rounded border-2 border-black outline outline-offset-0">outline-offset-0</button> <button class="bg-orange-400 px-4 py-1.5 rounded border-2 border-black outline outline-black outline-offset-1">outline-offset-1</button> <button class="bg-neutral-500 px-4 py-1.5 text-gray-50 rounded border-2 border-black outline outline-black outline-offset-2">outline-offset-2</button> <button class="bg-sky-400 px-4 py-1.5 rounded border-2 border-black outline outline-offset-4">outline-offset-4</button> <button class="bg-emerald-500 px-4 py-1.5 rounded border-2 border-black outline outline-offset-8">outline-offset-8</button> </div> </body> </html>
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *