Borders
Utilities for controlling the width of an element's borders.
Use the border
, .border-0
, .border-2
, .border-4
, or .border-8
utilities to set the border width for all sides of an element.
border
border-2
border-4
border-8
<div class="border border-indigo-600 ..."></div> <div class="border-2 border-indigo-600 ..."></div> <div class="border-4 border-indigo-600 ..."></div> <div class="border-8 border-indigo-600 ..."></div>
<div class="border border-sky-500"></div> <div class="border-2 border-sky-500"></div> <div class="border-4 border-sky-500"></div> <div class="border-8 border-sky-500"></div>
Use the border-{side}
, .border-{side}-0
, .border-{side}-2
, .border-{side}-4
, or .border-{side}-8
utilities to set the border width for one side of an element.
border-t-4
border-r-4
border-b-4
border-l-4
<div class="border-t-4 border-indigo-500 ..."></div>
<div class="border-r-4 border-indigo-500 ..."></div>
<div class="border-b-4 border-indigo-500 ..."></div>
<div class="border-l-4 border-indigo-500 ..."></div>
Use the border-{x|y}-{width}
utilities to set the border width on two sides of an element at the same time.
border-x-4
border-y-4
<div class="border-x-4 border-indigo-500 ..."></div>
<div class="border-y-4 border-indigo-500 ..."></div>
You can also add borders between child elements using the divide-{x/y}-{width}
and divide-{color}
utilities.
<div class="divide-y divide-slate-200 ..."> <div>01</div> <div>02</div> <div>03</div> </div>
<div class="divide-y divide-slate-700 ..."> <div>01</div> <div>02</div> <div>03</div> </div>
Learn more in the Divide Width and Divide Color documentation.
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:border-t-4
to only apply the border-t-4
utility on hover.
<div class="border-2 hover:border-t-4">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:border-t-4
to apply the border-t-4
utility at only medium screen sizes and above.
<div class="border-2 md:border-t-4">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind provides five border-width
utilities, and the same number of utilities per side (horizontal, vertical, top, right, bottom, and left). You change, add, or remove these by editing the theme.borderWidth
section of your Tailwind config.
module.exports = {
theme: {
borderWidth: {
DEFAULT: '1px',
'0': '0',
'2': '2px',
'3': '3px',
'4': '4px',
'6': '6px',
'8': '8px',
}
}
}
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off border-{side}-{width}
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="border-t-[3px]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.