W3cubDocs

/Tailwind CSS

border-width

Utilities for controlling the width of an element's borders.

Class Styles
border
border-width: 1px;
border-<number>
border-width: <number>px;
border-(length:<custom-property>)
border-width: var(<custom-property>);
border-[<value>]
border-width: <value>;
border-x
border-inline-width: 1px;
border-x-<number>
border-inline-width: <number>px;
border-x-(length:<custom-property>)
border-inline-width: var(<custom-property>);
border-x-[<value>]
border-inline-width: <value>;
border-y
border-block-width: 1px;
border-y-<number>
border-block-width: <number>px;

Examples

Basic example

Use border or border-<number> utilities like border-2 and border-4 to set the border width for all sides of an element:

Individual sides

Use utilities like border-r and border-t-4 to set the border width for one side of an element:

Horizontal and vertical sides

Use utilities like border-x and border-y-4 to set the border width on two sides of an element at the same time:

Using logical properties

Use utilities like border-s and border-e-4 to set the border-inline-start-width and border-inline-end-width logical properties, which map to either the left or right border based on the text direction:

Between children

Use utilities like divide-x and divide-y-4 to add borders between child elements:

Reversing children order

If your elements are in reverse order (using say flex-row-reverse or flex-col-reverse), use the divide-x-reverse or divide-y-reverse utilities to ensure the border is added to the correct side of each element:

Using a custom value

Use the border-[<value>] syntax to set the border width based on a completely custom value:

<div class="border-[2vw] ...">
  <!-- ... -->
</div>

For CSS variables, you can also use the border-(length:<custom-property>) syntax:

<div class="border-(length:--my-border-width) ...">
  <!-- ... -->
</div>

This is just a shorthand for border-[length:var(<custom-property>)] that adds the var() function for you automatically.

Responsive design

Prefix a border-width utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:

<div class="border-2 md:border-t-4 ...">
  <!-- ... -->
</div>

Learn more about using variants in the variants documentation.