Skip to content

Latest commit

 

History

History
87 lines (62 loc) · 3.27 KB

animation-duration.md

File metadata and controls

87 lines (62 loc) · 3.27 KB

Animation Duration

Utilities for controlling the duration of CSS animations.

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

Note: This is reusing the same classes as transition-duration, this may change in the future if it turns out to cause friction.

Basic Usage

Changing animation duration

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

<button class="animate-bounce duration-150 ...">Button A</button>
<button class="animate-bounce duration-300 ...">Button B</button>
<button class="animate-bounce duration-700 ...">Button C</button>

Applying Conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:duration-0 to only apply the duration-0 utility on hover.

<div class="animate-bounce duration-300 hover:duration-0">
  <!-- ... -->
</div>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:duration-0 to apply the duration-0 utility at only medium screen sizes and above.

<div class="animate-bounce duration-150 md:duration-0">
  <!-- ... -->
</div>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.

Using custom values

Customizing your theme

By default, Tailwind provides animation-duration utilities for all of the built-in browser keyword options. You can customize these values by editing theme.animationDuration or theme.extend.animationDuration in your tailwind.config.js file.

// @filename tailwind.config.js
module.exports = {
  theme: {
    extend: {
      animationDuration: {
        '2s': '2s',
      },
    },
  },
};

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

Arbitrary values

If you need to use a one-off animation-duration value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

<div class="duration-[2s]">
  <!-- ... -->
</div>

Learn more about arbitrary value support in the arbitrary values documentation.