How to create Tailwind CSS Animations


By Emmanuel Chinonso

Technical Writer

Last updated: 17 June 2024

Tailwind CSS Animations

Tailwind CSS, known for its utility-first approach, has transformed the way developers design dynamic and visually stunning UIs. A key aspect of Tailwind CSS is its extensive support for animations, which can elevate user engagement, provide visual cues, and enhance the overall experience of web apps. This guide will provide a comprehensive overview of how to harness the power of Tailwind CSS animations to create captivating web experiences.

Table of Content

  • Predefined Animation Classes
  • animate-none
  • animate-spin
  • animate-ping
  • animate-bounce
  • Creating Custom Tailwind Animations
  • Utilizing Arbitrary Values for flexible Animations
  • Conclusion

Predefined Animation Classes

Adding Tailwind animations is as easy as simply appending the class animate- to the element you wish to animate. Tailwind includes several pre-defined animation utilities that can be applied directly to elements for immediate effects:

1. Tailwind animate-Spin: Makes an element rotate indefinitely. Perfect for creating loading indicators.

<div className=" flex justify-center items-center animate-spin....">
<!-- Content that spins -->


This example demonstrates a spinning icon, which is often used for loaders or as a visual indicator of processing.

2. Tailwind Animate-bounce:Adds a playful bounce animation, perfect for interactive elements like buttons. Adding a bounce animation to a download button to make it more engaging.


3. Tailwind Animate-ping: Applies a pulsing effect, useful for notifications and attention-grabbing indicators. Useful for notification icons or to draw attention to specific actions that users can take.


4. Tailwind Animate-pulse: Ideal for focusing user attention on a button or an important feature on the page.

<button class="animate-pulse bg-indigo-500 text-white font-bold py-2 px-4 rounded">
New Feature!


Creating Custom Animations

For those unique design needs, Tailwind allows the creation of bespoke animations using the @keyframes rule in your tailwind.config.js, giving you complete control over the animation sequence.

Define the keyframes in your Tailwind configuration:

// tailwind.config.js
module.exports = {
theme: {
extend: {
keyframes: {
slideInFromLeft: {
'0%': { transform: 'translateX(-100%)' },
'100%': { transform: 'translateX(0)' },
animation: {
'slide-in': 'slideInFromLeft 0.5s ease-out forwards',

Use the custom animation in your HTML:

<div class="animate-slide-in">
<!-- Content that slides in from the left -->

Utilizing Arbitrary Values for Tailored Animations

Tailwind's support for arbitrary values allows developers to apply custom animations directly within the class attribute, facilitating rapid prototyping and unique one-off effects.

<div class="animate-[spin_2s_linear_infinite]">
<!-- Custom spinning element -->



Tailwind CSS animations offer a powerful way to enhance your web projects with captivating and dynamic elements. You can utilize existing animations or create your own to craft an unforgettable user experience that sets your projects apart in the online realm.


Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.

Related Posts