tailwind css animation examples

In this section we will see tailwind css animation, animation hover, responsive animation, tailwind animation svg icon, tailwind animation customizing keyframes delay example with Tailwind CSS.




Example 1

Tailwind CSS simple animation example with animate-spin, animate-ping, animate-bounce, animate-pulse classes.

<div class="w-20 h-20 p-2 bg-blue-500 rounded-md animate-spin"></div>
<div class="w-20 h-20 p-2 bg-purple-500 rounded-md animate-ping"></div>
<div class="w-20 h-20 p-2 bg-green-500 rounded-md animate-bounce"></div>
<div class="w-20 h-20 p-2 bg-gray-500 rounded-md animate-pulse"></div>
tailwind animation v1

tailwind animation v1


Example 2

Tailwind CSS hover animation.

<div class="w-20 h-20 p-2 bg-blue-900 rounded-md hover:animate-spin"></div>
<div class="w-20 h-20 p-2 bg-purple-500 rounded-md hover:animate-ping"></div>
<div class="w-20 h-20 p-2 bg-green-500 rounded-md hover:animate-bounce"></div>
<div class="w-20 h-20 p-2 bg-gray-500 rounded-md hover:animate-pulse"></div>


Example 3

Tailwind CSS responsive animation.

<div
  class="
    w-20
    h-20
    p-2
    bg-blue-500
    rounded-md
    lg:animate-spin
    md:animate-spin
    animate-none
  "
></div>
<div
  class="
    w-20
    h-20
    p-2
    bg-purple-500
    rounded-md
    animate-ping
    lg:animate-ping
    md:animate-ping
    animate-none
  "
></div>
<div
  class="
    w-20
    h-20
    p-2
    bg-green-500
    rounded-md
    animate-bounce
    lg:animate-bounce
    md:animate-bounce
    animate-none
  "
></div>
<div
  class="
    w-20
    h-20
    p-2
    bg-gray-500
    rounded-md
    animate-pulse
    lg:animate-pulse
    md:animate-pulse
    animate-none
  "
></div>


Example 4

Tailwind CSS text animation.

<h3 class="text-3xl font-bold text-indigo-500 animate-bounce">
  Tailwind CSS Animation
</h3>
<h3 class="text-3xl font-bold text-indigo-500 animate-ping">
  Tailwind CSS Animation
</h3>
tailwind animation v3

tailwind animation v3


Example 5

Tailwind CSS animation customizing keyframes delay and speed.

tailwind.config.js

const colors = require('tailwindcss/colors')

module.exports = {
  mode: 'jit',
  theme: {
    extend: {
      colors: {
        sky: colors.sky,
        cyan: colors.cyan,
      },
      animation: {
        'spin-slow': 'spin 5s linear infinite',
        'ping-slow': 'ping 5s cubic-bezier(1, 1, 0.2, 1) infinite',

      },
       keyframes: {
         spin: {
           to:{
             transform: 'rotate(-360deg)'
           }
         }
        }
    },
  },
  variants: {},
  plugins: [],
}

index.html

<div class="w-20 h-20 p-2 bg-blue-900 rounded-md animate-spin-slow"></div>
<div class="w-20 h-20 p-2 bg-purple-500 rounded-md animate-ping-slow"></div>
tailwind animation v4

tailwind animation v4



Example 5

Use of animation

Loading Spinner

<div class="flex items-center justify-center space-x-2 animate-pulse">
  <div class="w-8 h-8 bg-indigo-500 rounded-full"></div>
  <div class="w-8 h-8 bg-indigo-500 rounded-full"></div>
  <div class="w-8 h-8 bg-indigo-500 rounded-full"></div>
</div>
tailwind animation v5

tailwind animation v5


Skeleton loading animation.

<div class="w-full max-w-sm p-4 mx-auto border border-blue-300 rounded-md shadow">
  <div class="flex space-x-4 animate-pulse">
    <div class="w-12 h-12 bg-blue-400 rounded-full"></div>
    <div class="flex-1 py-1 space-y-4">
      <div class="w-3/4 h-4 bg-blue-400 rounded"></div>
      <div class="space-y-2">
        <div class="h-4 bg-blue-400 rounded"></div>
        <div class="w-5/6 h-4 bg-blue-400 rounded"></div>
      </div>
    </div>
  </div>
</div>
tailwind animation v6

tailwind animation v6


Online User.

<div class="flex">
  <div class="relative">
    <img
      class="object-cover w-16 h-16 rounded-full"
      src="https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460__340.png"
      alt="Avatar"
    />
    <span
      class="
        absolute
        right-0
        w-4
        h-4
        bg-green-600
        border-2 border-white
        rounded-full
        top-2
        animate-pulse
      "
    ></span>
  </div>
</div>


Animation with SVG Icon.

<svg
  xmlns="http://www.w3.org/2000/svg"
  class="w-12 h-12 text-gray-600 animate-spin"
  fill="none"
  viewBox="0 0 24 24"
  stroke="currentColor"
>
  <path
    stroke-linecap="round"
    stroke-linejoin="round"
    stroke-width="2"
    d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
  />
  <path
    stroke-linecap="round"
    stroke-linejoin="round"
    stroke-width="2"
    d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"
  />
</svg>
tailwind animation v8

tailwind animation v8

See Also

Tailwind CSS Free Digital Agency Landing Page

TailFood – Free Tailwind CSS Restaurant Template

Tailwind CSS Real Estate Template

Tailwind CSS Simple Responsive Landing Page Template

Tailwind CSS Simple Verification Email Template


Read Also

Tailwind CSS 3 FAQ Accordion UI Example

Tailwind CSS 3 Alert Message Example

Tailwind CSS 3 Avatars Example

Tailwind CSS 3 Badges Example

Tailwind CSS 3 Breadcrumb Example

Tailwind CSS Gradient Button Example

Tailwind CSS 3D Button Example

Tailwind CSS Loading Button Example

Tailwind CSS v3 Cards Examples

Tailwind CSS Checkbox Form Examples

Tailwind CSS Dropdowns (Menu) on Hover Example

Tailwind CSS Multiselect Dropdown Example

How to use dark mode toggle switch in Tailwind CSS 3

How to use @apply directive in Tailwind CSS

Tailwind CSS sticky header & fixed navbar example

Tailwind CSS Navbar UI Example

Tailwind CSS 3 Login Page UI Example

Tailwind CSS Login Modal Example

Tailwind CSS Search Examples

Tailwind CSS 3 Overlay Image Example

Tailwind CSS Thank You Page Example

Tailwind CSS Timeline UI Example

Tailwind CSS Responsive Footer Section Example

Tailwind CSS Background Image Header Example