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

Transition Timing Function

Utilities for controlling the easing of CSS transitions.

Default class reference

Class
屬性
ease-lineartransition-timing-function: linear;
ease-intransition-timing-function: cubic-bezier(0.4, 0, 1, 1);
ease-outtransition-timing-function: cubic-bezier(0, 0, 0.2, 1);
ease-in-outtransition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);

Usage

Use the ease-{timing} utilities to control an element’s easing curve.

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

Responsive

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

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

Customizing

Timing values

By default, Tailwind provides four general purpose transition-timing-function utilities. You change, add, or remove these by customizing the transitionTimingFunction section of your Tailwind theme config.

  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        transitionTimingFunction: {
+         'in-expo': 'cubic-bezier(0.95, 0.05, 0.795, 0.035)',
+         'out-expo': 'cubic-bezier(0.19, 1, 0.22, 1)',
        }
      }
    }
  }

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

Variants

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

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

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

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

Disabling

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

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