1.0.1 • Published 11 months ago

tailwindcss-animated v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Tailwind CSS Animated

Extended animation utilities for Tailwind CSS https://tailwindcss-animated.com

Installation

Install the plugin from npm:

npm i tailwindcss-animated

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  // ...
  plugins: [
    require('tailwindcss-animated')
  ],
}

Usage

This plugin brings various utility classes as well as several ready-to-use CSS animations. Here are some simple examples:

<button class="animate-wiggle">
  Hej, look at me!
</button>

<button class="animate-jump-in animate-delay-300 animate-once">
  Wait a bit, then jump right in.
</button>

Ready-to-use animations

There are several animations that can be integrated with a single utility class. These extend the Spin, Ping and Pulse animations of Tailwind CSS.

Open the configurator to see them in action: https://tailwindcss-animated.com/configurator.html

All animations can be customized with the utility classes below.

Duration

ClassProperties
animate-duration-75animation-duration: 75ms;
animate-duration-100animation-duration: 100ms;
animate-duration-150animation-duration: 150ms;
animate-duration-200animation-duration: 200ms;
animate-duration-300animation-duration: 300ms;
animate-duration-500animation-duration: 500ms;
animate-duration-700animation-duration: 700ms;
animate-duration-1000animation-duration: 1000ms;

Delay

ClassProperties
animate-delay-noneanimation-delay: 0ms;
animate-delay-75animation-delay: 75ms;
animate-delay-100animation-delay: 100ms;
animate-delay-150animation-delay: 150ms;
animate-delay-200animation-delay: 200ms;
animate-delay-300animation-delay: 300ms;
animate-delay-500animation-delay: 500ms;
animate-delay-700animation-delay: 700ms;
animate-delay-1000animation-delay: 1000ms;

Iteration Count

ClassProperties
animate-infiniteanimation-iteration-count: infinite;
animate-onceanimation-iteration-count: 1;
animate-twiceanimation-iteration-count: 2;
animate-thriceanimation-iteration-count: 3;

Direction

ClassProperties
animate-normalanimation-direction: normal;
animate-reverseanimation-direction: reverse;
animate-alternateanimation-direction: alternate;
animate-alternate-reverseanimation-direction: alternate-reverse;

Timing Function

ClassProperties
animate-ease-linearanimation-timing-function: linear;
animate-ease-inanimation-timing-function: cubic-bezier(0.4, 0, 1, 1);
animate-ease-outanimation-timing-function: cubic-bezier(0, 0, 0.2, 1);
animate-ease-in-outanimation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);

Fill Mode

ClassProperties
animate-fill-noneanimation-fill-mode: normal;
animate-fill-forwardsanimation-fill-mode: forwards;
animate-fill-backwardsanimation-fill-mode: backwards;
animate-fill-bothanimation-fill-mode: both;

Play State

ClassProperties
animate-runanimation-play-state: running;
animate-playanimation-play-state: running;
animate-stopanimation-play-state: paused;
animate-pauseanimation-play-state: paused;

Variant modifiers and breakpoints

All variants and breakpoints (hover, focus, lg, ...) work with animations und animation utility classes.

<div class="lg:hover:animate-shake motion-reduce:animate-none">
  <!-- ... -->
</div>

Arbitrary values

You can create custom properies on the fly by using square brackets. This works for Delay and Durations values.

<div class="animate-delay-[85ms] animate-duration-[2s]">
  <!-- ... -->
</div>

Customizing your theme

If you want to change some animations, extend your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    extend: {
      animationDelay: {
        275: '275ms',
        5000: '5s',
      },
      animationDuration: {
        2000: '2s',
        'long': '10s',
        'very-long': '20s',
      },
    },
  },
  plugins: [
    require('tailwindcss-animated')
  ],
}

Take a look at src/theme.js for the default settings.