Tailwind Border Width – A Comprehensive Guide
In this article, we will explore the Tailwind border width with examples and show you how to use them to create stunning web designs.
Tailwind border width class specifies the border width of all four sides of an element.
Four properties make up the border-width property.
There are multiple values that can be assigned to this class in Tailwind CSS.
Each property is covered by a class and It’s an alternative to the CSS border-width property.
Syntax
<element class="border-{number}">....</element>
Tailwind Border Width Classes
Classes | Overview |
border-0 | This class sets the border width to 0px hence no border is applied to the element. |
border | This class applies a border of 1px to all four sides of an element. |
border-2 | This class applies a border of 2px to all four sides of an element. |
border-4 | This class applies a border of 4px to all four sides of an element. |
border-8 | This class applies a border of 8px to all four sides of an element. |
border-x-0 | By utilizing the border-x-0 class in Tailwind, a border width of both left and right sides of an element is set to 0px. |
border-x | By utilizing the border-x class in Tailwind, a border width of 1px applied to both left and right sides of an element. |
border-x-2 | By utilizing the border-x-2 class in Tailwind, a border width of 2px applied to both left and right sides of an element. |
border-x-4 | By utilizing the border-x-4 class in Tailwind, a border width of 4px applied to both left and right sides of an element. |
border-x-8 | By utilizing the border-x-8 class in Tailwind, a border width of 8px applied to both left and right sides of an element. |
border-y-0 | In this case, the border width of top and bottom sides of an element is set to 0px. |
border-y | In this case, the border width of top and bottom sides of an element is set to 1px. |
border-y-2 | In this case, the border width of top and bottom sides of an element is set to 2px. |
border-y-4 | In this case, the border width of top and bottom sides of an element is set to 4px. |
border-y-8 | In this case, the border width of top and bottom sides of an element is set to 8px. |
border-t-0 | Using this class, the top side border width of an element is set to 0px. |
border-t | Using this class, the top side border width of an element is set to 1px. |
border-t-2 | Using this class, the top side border width of an element is set to 2px. |
border-t-4 | Using this class, the top side border width of an element is set to 4px. |
border-t-8 | Using this class, the top side border width of an element is set to 8px. |
border-r-0 | Elements with this class have a border width of 0px on their right side. |
border-r | Elements with this class have a border width of 1px on their right side. |
border-r-2 | Elements with this class have a border width of 2px on their right side. |
border-r-4 | Elements with this class have a border width of 4px on their right side. |
border-r-8 | Elements with this class have a border width of 8px on their right side. |
border-b-0 | The result of this class is a border width of 0px on the bottom of an element. |
border-b | The result of this class is a border width of 1px on the bottom of an element. |
border-b-2 | The result of this class is a border width of 2px on the bottom of an element. |
border-b-4 | The result of this class is a border width of 4px on the bottom of an element. |
border-b-8 | The result of this class is a border width of 8px on the bottom of an element. |
border-l-0 | Using this class, an element’s left side border width is set to 0px. |
border-l | Using this class, an element’s left side border width is set to 1px. |
border-l-2 | Using this class, an element’s left side border width is set to 2px. |
border-l-4 | Using this class, an element’s left side border width is set to 4px. |
border-l-8 | Using this class, an element’s left side border width is set to 8px. |
This section uses a class to set the border width on all sides of an element.
The classes include border, border-0, border-2, border-4, and border-8.
Syntax
<element class="border-{number}">...</element>
Below example sheds some light on the Tailwind classes that are used to adjust borders on all four sides of an element:
Tailwind Border Width Example: 1 
In this example, let’s explore classes that adjust vertical or horizontal borders only:
Tailwind Border Width Example: 2 
Below example covers classes that make use of border width on top and bottom borders only:
Tailwind Border Width Example: 3 
The following example portrays how the left and right border widths are adjusted using the border width class in Tailwind:
Tailwind Border Width Example: 4 
Now you know what Tailwind Border Width is and how it can be used to create an elegant website.