Transitions
Add transition so changes (like hover colours) animate smoothly.
- What:
transition(common properties),transition-colors,transition-transform,transition-all - How long:
duration-150,duration-300,duration-700 - Easing:
ease-in,ease-out,ease-in-out - Wait:
delay-150
<button class="bg-sky-600 hover:bg-sky-700 transition-colors duration-300">
Built-in animations
| Class | Use |
|---|---|
animate-spin |
loading spinners |
animate-ping |
notification pulse |
animate-pulse |
skeleton loaders |
animate-bounce |
"scroll down" arrows |
Respect reduced motion
motion-safe:animate-bounce runs only if the user has not asked for less motion; motion-reduce:transition-none turns transitions off for them.
Custom animations
Define keyframes and an --animate-* variable inside @theme (see Customization).
Example
Example — Spinner, ping, skeleton and smooth hover
HTML
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
<div class="p-8 space-y-8">
<div class="flex items-center gap-8">
<div class="size-8 border-4 border-sky-200 border-t-sky-600 rounded-full animate-spin"></div>
<span class="relative flex size-4">
<span class="absolute inline-flex h-full w-full rounded-full bg-rose-400 opacity-75 animate-ping"></span>
<span class="relative inline-flex size-4 rounded-full bg-rose-500"></span>
</span>
<span class="text-2xl motion-safe:animate-bounce">↓</span>
</div>
<div class="animate-pulse flex gap-4 max-w-sm">
<div class="size-12 bg-slate-200 rounded-full"></div>
<div class="flex-1 space-y-2 py-1">
<div class="h-3 bg-slate-200 rounded"></div>
<div class="h-3 bg-slate-200 rounded w-2/3"></div>
</div>
</div>
<button class="bg-emerald-600 hover:bg-emerald-500 hover:-translate-y-1 hover:shadow-lg text-white px-6 py-3 rounded-xl transition duration-300 ease-out">Smooth hover</button>
</div>