Utilities for controlling the border width between elements.
Add borders between horizontal elements using the divide-x-{amount}
utilities.
<div class="grid grid-cols-3 divide-x divide-green-500">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
Add borders between stacked elements using the divide-y-{amount}
utilities.
<div class="grid grid-cols-1 divide-y divide-yellow-500">
<div>1</div>
<div>2</div>
<div>3</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 divide-rose-400">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
To control the borders between elements at a specific breakpoint, add a {screen}:
prefix to any existing divide utility. For example, adding the class md:divide-y-8
to an element would apply the divide-y-8
utility at medium screen sizes and above.
<div class="divide-y divide-gray-400 md:divide-y-8">
<div class="py-2">1</div>
<div class="py-2">2</div>
<div class="py-2">3</div>
</div>
For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.
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.
// tailwind.config.js
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.
// tailwind.config.js
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.
默認情況下, 只有 響應式 的 divide width 變化模式 (variants) 會產生。
在 tailwind.config.js
的 variants
區塊中變更 divideWidth
屬性來決定有哪些變化模式會生成。
舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
+ divideWidth: ['responsive', 'hover'],
}
}
}
如果你不打算在專案中使用 divide width 功能,可以在你的設定檔裡的 corePlugins
屬性中將 divideWidth
設定為 false
來停用功能:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ divideWidth: false,
}
}