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

Transition Delay

Utilities for controlling the delay of CSS transitions.

Default class reference

Class
屬性
delay-75transition-delay: 75ms;
delay-100transition-delay: 100ms;
delay-150transition-delay: 150ms;
delay-200transition-delay: 200ms;
delay-300transition-delay: 300ms;
delay-500transition-delay: 500ms;
delay-700transition-delay: 700ms;
delay-1000transition-delay: 1000ms;

Usage

Use the delay-{amount} utilities to control an element’s transition-delay.

<button class="transition delay-150 duration-300 ease-in-out ...">Hover me</button>
<button class="transition delay-300 duration-300 ease-in-out ...">Hover me</button>
<button class="transition delay-700 duration-300 ease-in-out ...">Hover me</button>

Responsive

To control an element’s transition-delay at a specific breakpoint, add a {screen}: prefix to any existing transition-delay utility. For example, use md:delay-500 to apply the delay-500 utility at only medium screen sizes and above.

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

Customizing

Delay values

By default, Tailwind provides eight general purpose transition-delay utilities. You change, add, or remove these by customizing the transitionDelay section of your Tailwind theme config.

  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        transitionDelay: {
+         '0': '0ms',
+         '2000': '2000ms',
        }
      }
    }
  }

Learn more about customizing the default theme in the theme customization documentation.

Variants

默認情況下, 只有 響應式 的 transition-delay 變化模式 (variants) 會產生。

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

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

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

Disabling

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

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