Borders
Utilities for controlling the border width between elements.
Use the divide-x-*
utilities to add borders between horizontal elements.
<div class="grid grid-cols-3 divide-x">
<div>01</div>
<div>02</div>
<div>03</div>
</div>
Use the divide-y-*
utilities to add borders between stacked elements.
<div class="grid grid-cols-1 divide-y">
<div>01</div>
<div>02</div>
<div>03</div>
</div>
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.
<div class="flex flex-col-reverse divide-y divide-y-reverse">
<div>01</div>
<div>02</div>
<div>03</div>
</div>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:divide-y-8
to only apply the divide-y-8
utility on hover.
<div class="divide-y divide-gray-400 hover:divide-y-8">
<!-- ... -->
</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:divide-y-8
to apply the divide-y-8
utility at only medium screen sizes and above.
<div class="divide-y divide-gray-400 md:divide-y-8">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
The divide width scale inherits its values from the borderWidth
scale by default, so if you’d like to customize your values for both border width and divide width together, use the theme.borderWidth
section of your tailwind.config.js
file.
module.exports = {
theme: {
borderWidth: {
DEFAULT: '1px',
'0': '0',
'2': '2px',
'3': '3px',
'4': '4px',
'6': '6px',
'8': '8px',
}
}
}
To customize only the divide width values, use the theme.divideWidth
section of your tailwind.config.js
file.
module.exports = {
theme: {
divideWidth: {
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 divide 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="divide-x-[3px]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.