Transition Duration

Tailwind CSS version

v1.2.0+

Utilities for controlling the duration of CSS transitions.

Class reference

Class
Properties
.duration-75transition-duration: 75ms;
.duration-100transition-duration: 100ms;
.duration-150transition-duration: 150ms;
.duration-200transition-duration: 200ms;
.duration-300transition-duration: 300ms;
.duration-500transition-duration: 500ms;
.duration-700transition-duration: 700ms;
.duration-1000transition-duration: 1000ms;

Usage

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

Transition Duration - 图1

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

Responsive

To control an element’s transition-duration at a specific breakpoint, add a {screen}: prefix to any existing transition-duration utility. For example, use md:duration-500 to apply the duration-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

Duration values

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

  1. // tailwind.config.js
  2. module.exports = {
  3. theme: {
  4. extend: {
  5. transitionDuration: {
  6. + '0': '0ms',
  7. + '2000': '2000ms',
  8. }
  9. }
  10. }
  11. }

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

Responsive and pseudo-class variants

By default, only responsive variants are generated for transition-duration utilities.

You can control which variants are generated for the transition-duration utilities by modifying the transitionDuration 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. // ...
  5. - transitionDuration: ['responsive'],
  6. + transitionDuration: ['responsive', 'hover', 'focus'],
  7. }
  8. }

Disabling

If you don’t plan to use the transition-duration utilities in your project, you can disable them entirely by setting the transitionDuration property to false in the corePlugins section of your config file:

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

← Transition Property   Transition Timing Function →