GitHub

How to Add Animation Duration, Delay and Easing Support to Tailwind CSS (v3)

Published: Updated:

Itโ€™s important to mention that you can use JIT for one-off classes, such as:


It may seem strange that Tailwind CSS doesnโ€™t include this, but letโ€™s proceed.

Adding Animation Duration Classes to Tailwind CSS

To do this, add the following to your tailwind.config.js:

const plugin = require('tailwindcss/plugin')

module.exports = {
  plugins: [
    plugin(function ({ matchUtilities, theme }) {
      matchUtilities(
        {
          'animate-duration': (value) => ({
            animationDuration: value,
          }),
        },
        { values: theme('transitionDuration') }
      )
    }),
  ],
}

This will add the duration classes used for transitions to animations with the animate- prefix:

Adding Animation Delay Classes to Tailwind CSS

Add the following to your tailwind.config.js:

const plugin = require('tailwindcss/plugin')

module.exports = {
  plugins: [
    plugin(function ({ matchUtilities, theme }) {
      matchUtilities(
        {
          'animate-delay': (value) => ({
            animationDelay: value,
          }),
        },
        { values: theme('transitionDelay') }
      )
    }),
  ],
}

This will add the delay classes used for transitions to animations with the animate- prefix:

Adding Animation Easing Classes to Tailwind CSS

Add the following to your tailwind.config.js:

const plugin = require('tailwindcss/plugin')

module.exports = {
  plugins: [
    plugin(function ({ matchUtilities, theme }) {
      matchUtilities(
        {
          'animate-ease': (value) => ({
            animationTimingFunction: value,
          }),
        },
        { values: theme('transitionTimingFunction') }
      )
    }),
  ],
}

This will add the ease classes used for transitions to animations with the animate- prefix:

Check out the Tailwind Play example.

The added classes will appear in Tailwind CSS IntelliSense.

This also means you can use JIT, for example:


And thatโ€™s it.

Thatโ€™s all you need to do to add animation duration, delay, and easing support to Tailwind CSS while itโ€™s not yet part of the core. Perhaps it will be included in the future.