On this page
Tailwind CSS v4 moved configuration from tailwind.config.js into your CSS, and animations moved with it. Custom keyframes, animation classes and easing curves are now defined in an `@theme` block, and new utilities cover things that used to need JavaScript, like animating an element in as it appears. This guide covers each piece, with code you can paste.
Free toolCubic-bezier generatorDrag an easing curve, race it against linear and ease, and copy it as CSS, Tailwind or Motion.The built-in animations
Tailwind ships four animations: animate-spin for loaders, animate-ping for notification dots, animate-pulse for skeletons and animate-bounce for scroll hints. For anything else, you define your own.
Defining a custom animation with @theme
In v4, an animation is a theme variable named --animate-*, with its keyframes declared alongside it. Tailwind then generates a matching class:
@import "tailwindcss";
@theme {
--animate-wiggle: wiggle 1s ease-in-out infinite;
--animate-fade-up: fade-up 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
@keyframes wiggle {
0%, 100% { transform: rotate(-3deg); }
50% { transform: rotate(3deg); }
}
@keyframes fade-up {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: none; }
}
}Now animate-wiggle and animate-fade-up work anywhere, including with variants like hover:animate-wiggle. Keyframes inside @theme are only output when a class uses them, so unused animations cost nothing.
For a one-off, an arbitrary value skips the theme: animate-[wiggle_1s_ease-in-out_infinite], with underscores where the spaces go.
Transitions and custom easing
Most interface motion is transitions rather than keyframes: transition (or transition-transform, transition-colors), plus duration-*, ease-* and delay-*. Tailwind's built-in curves are ease-linear, ease-in, ease-out and ease-in-out. Add your own as --ease-* theme variables:
@theme {
--ease-out-quint: cubic-bezier(0.22, 1, 0.36, 1);
--ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}<div className="transition-transform duration-500 ease-out-quint hover:-translate-y-1">…</div>A strong ease-out like this makes hover effects feel quick and settled. To design a curve by eye, drag one in the free cubic-bezier generator, which outputs the Tailwind class and the @theme line. Easing functions explained covers which curve suits which job.
Animate elements in as they appear with starting:
Fading in a dialog or popover used to need JavaScript, because the element goes from display: none to visible in one step. CSS's @starting-style gives the browser a starting point, and Tailwind v4 exposes it as the starting: variant. Pair it with transition-discrete so display can transition too:
<button popoverTarget="menu">Open menu</button>
<div
id="menu"
popover="auto"
className="scale-95 opacity-0 transition-all transition-discrete duration-200 open:scale-100 open:opacity-100 starting:open:scale-95 starting:open:opacity-0"
>
…
</div>The menu now scales and fades in when it opens, and back out when it closes, with no JavaScript. The same pattern works for <dialog>.
Staggering a list
delay-* sets transition-delay, so for keyframe animations use an arbitrary property instead, setting the delay from each item's index:
{items.map((item, index) => (
<li key={item.id} className="animate-fade-up" style={{ animationDelay: `${index * 60}ms` }}>
{item.label}
</li>
))}Keep the step between 40 and 80 milliseconds: shorter and it reads as one block, longer and the last items feel late. More in stagger animations in React.
Reduced motion
Tailwind's motion-safe: and motion-reduce: variants follow the visitor's operating system setting. Either opt in to motion, or switch it off:
<h1 className="motion-safe:animate-fade-up">…</h1>
<div className="animate-wiggle motion-reduce:animate-none">…</div>A good rule: anything that loops or moves a large area should stop under motion-reduce:, while small fades can stay. The accessible animation checklist has the rest.
When to reach for Motion instead
Tailwind and CSS cover hover states, loops, entrances and simple sequences (Motion vs CSS animations compares the two in detail). Switch to Motion when the animation needs to react to input: springs that carry the speed of a drag, elements animating out before React removes them, layout changes, gestures and scroll-linked values. Most real interfaces use both, which is how every MotionKit component is built: Tailwind for styling and static states, Motion for the parts that move with physics.
Questions
Where is tailwind.config.js in Tailwind v4?
It's optional now. Theme values, including animations, keyframes and easing curves, go in an @theme block in your CSS. A JavaScript config still works through the @config directive if you need it.
How do I add keyframes in Tailwind CSS v4?
Declare an --animate-name variable and its @keyframes inside @theme in your CSS file. Tailwind generates an animate-name class for it.
Can Tailwind animate an element when it's removed?
Only for elements the browser hides itself, like a closing popover or dialog, using transition-discrete. Elements React removes from the page need a library like Motion to animate out.
Does Tailwind support spring animations?
Not natively, but a CSS linear() easing can trace a spring curve. Generate one with a spring generator and use it as a custom --ease-* value or in an arbitrary ease-[…] class.