Divide Color
- Tailwind CSS version
- v1.3.0+
Utilities for controlling the border color between elements.
Usage
Control the border color between elements using the divide-{color}
utilities.
<div class="divide-y divide-blue-300">
<div class="text-center py-2">1</div>
<div class="text-center py-2">2</div>
<div class="text-center py-2">3</div>
</div>
Changing opacityv1.4.0+
Control the opacity of borders between elements using the .divide-opacity-{amount}
utilities.
<div class="divide-y-4 divide-black divide-opacity-25">
<div class="text-center py-2">1</div>
<div class="text-center py-2">2</div>
<div class="text-center py-2">3</div>
</div>
Learn more in the divide opacity documentation.
Responsive
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-x-8
to an element would apply the divide-x-8
utility at medium screen sizes and above.
For more information about Tailwind's responsive design features, check out the Responsive Design documentation.
<div class="divide-teal-400 sm:divide-pink-400 md:divide-orange-400 lg:divide-green-400 xl:divide-red-400 divide-y">
<div class="text-center py-2">1</div>
<div class="text-center py-2">2</div>
<div class="text-center py-2">3</div>
</div>
Customizing
Border Colors
By default Tailwind makes the entire default color palette available as divide colors.
You can customize your color palette by editing the theme.colors
section of your tailwind.config.js
file, customize just your border and divide colors together using the theme.borderColor
section, or customize only the divide colors using the theme.divideColor
section.
// tailwind.config.js
module.exports = {
theme: {
divideColor: theme => ({
- ...theme('borderColors'),
+ 'primary': '#3490dc',
+ 'secondary': '#ffed4a',
+ 'danger': '#e3342f',
})
}
}
Responsive and pseudo-class variants
By default, only responsive variants are generated for divide color utilities.
You can control which variants are generated for the divide color utilities by modifying the divideColor
property in the variants
section of your tailwind.config.js
file.
For example, this config will also generate hover and focus variants:
// tailwind.config.js
module.exports = {
variants: {
// ...
- divideColor: ['responsive'],
+ divideColor: ['responsive', 'hover', 'focus'],
}
}
Disabling
If you don't plan to use the divide color utilities in your project, you can disable them entirely by setting the divideColor
property to false
in the corePlugins
section of your config file:
// tailwind.config.js
module.exports = {
corePlugins: {
// ...
+ divideColor: false,
}
}