「及時」模式:全新世代的 Tailwind CSS
Tailwind CSS on GitHub

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.

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

Changing opacity

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

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

<div class="divide-y divide-teal-400 md:divide-pink-400">
  <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.


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',
      })
    }
  }

Variants

默認情況下, 只有 響應式 和 深色模式 (如果啟用) 的 divide color 變化模式 (variants) 會產生。

tailwind.config.jsvariants 區塊中變更 divideColor 屬性來決定有哪些變化模式會生成。

舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
+       divideColor: ['responsive', 'hover'],
      }
    }
  }

Disabling

如果你不打算在專案中使用 divide color 功能,可以在你的設定檔裡的 corePlugins 屬性中將 divideColor 設定為 false 來停用功能:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     divideColor: false,
    }
  }