Divide Color

Utilities for controlling the border color between elements.

Default class reference

Class
Preview 
divide-transparent > +
divide-current > +
divide-black > +
divide-white > +
divide-gray-50 > +
divide-gray-100 > +
divide-gray-200 > +
divide-gray-300 > +
divide-gray-400 > +
divide-gray-500 > +
divide-gray-600 > +
divide-gray-700 > +
divide-gray-800 > +
divide-gray-900 > +
divide-red-50 > +
divide-red-100 > +
divide-red-200 > +
divide-red-300 > +
divide-red-400 > +
divide-red-500 > +
divide-red-600 > +
divide-red-700 > +
divide-red-800 > +
divide-red-900 > +
divide-yellow-50 > +
divide-yellow-100 > +
divide-yellow-200 > +
divide-yellow-300 > +
divide-yellow-400 > +
divide-yellow-500 > +
divide-yellow-600 > +
divide-yellow-700 > +
divide-yellow-800 > +
divide-yellow-900 > +
divide-green-50 > +
divide-green-100 > +
divide-green-200 > +
divide-green-300 > +
divide-green-400 > +
divide-green-500 > +
divide-green-600 > +
divide-green-700 > +
divide-green-800 > +
divide-green-900 > +
divide-blue-50 > +
divide-blue-100 > +
divide-blue-200 > +
divide-blue-300 > +
divide-blue-400 > +
divide-blue-500 > +
divide-blue-600 > +
divide-blue-700 > +
divide-blue-800 > +
divide-blue-900 > +
divide-indigo-50 > +
divide-indigo-100 > +
divide-indigo-200 > +
divide-indigo-300 > +
divide-indigo-400 > +
divide-indigo-500 > +
divide-indigo-600 > +
divide-indigo-700 > +
divide-indigo-800 > +
divide-indigo-900 > +
divide-purple-50 > +
divide-purple-100 > +
divide-purple-200 > +
divide-purple-300 > +
divide-purple-400 > +
divide-purple-500 > +
divide-purple-600 > +
divide-purple-700 > +
divide-purple-800 > +
divide-purple-900 > +
divide-pink-50 > +
divide-pink-100 > +
divide-pink-200 > +
divide-pink-300 > +
divide-pink-400 > +
divide-pink-500 > +
divide-pink-600 > +
divide-pink-700 > +
divide-pink-800 > +
divide-pink-900 > +

Usage

Control the border color between elements using the divide-{color} utilities.

Divide Color - 图1

  1. <div class="divide-y divide-fuchsia-300">
  2. <div>1</div>
  3. <div>2</div>
  4. <div>3</div>
  5. </div>

Changing opacity

Control the opacity of borders between elements using the divide-opacity-{amount} utilities.

Divide Color - 图2

  1. <div class="divide-y-4 divide-black divide-opacity-25">
  2. <div>1</div>
  3. <div>2</div>
  4. <div>3</div>
  5. </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.

  1. <div class="divide-y divide-teal-400 md:divide-pink-400">
  2. <div class="py-2">1</div>
  3. <div class="py-2">2</div>
  4. <div class="py-2">3</div>
  5. </div>

For more information about Tailwind’s responsive design features, check out the Responsive Design documentation.


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.

  1. // tailwind.config.js
  2. module.exports = {
  3. theme: {
  4. divideColor: theme => ({
  5. - ...theme('borderColors'),
  6. + 'primary': '#3490dc',
  7. + 'secondary': '#ffed4a',
  8. + 'danger': '#e3342f',
  9. })
  10. }
  11. }

Variants

By default, only responsive and dark mode (if enabled) 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:

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + divideColor: ['hover', 'focus'],
  7. }
  8. }
  9. }

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:

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + divideColor: false,
  6. }
  7. }

←Divide WidthDivide Opacity→