Guide · CSS & Frontend
How CSS Animations Work (and How to Preview Them)
Updated 2026-08-11 · 4 min read
A CSS animation is a timeline: at 0% the element looks like this, at 100% like that, and the browser interpolates (or jumps) in between. A transition is simpler - “when this property changes, ease it over 150 ms.” Most UI polish is transitions. Most loaders and attention pulses are @keyframes.
CSS Animations lets you preview catalog motion and copy the CSS before it lands in a global stylesheet. Use Color Studio so the moving thing uses the same primary as the rest of the UI. This is concrete CSS, not a theory of “delight.”
Keyframes versus transitions
Transition - attach to a selector:
.button {
background: var(--primary);
transition: background-color 150ms ease, transform 150ms ease;
}
.button:hover {
background: var(--primary-hover);
transform: translateY(-1px);
}
The browser only animates when the value changes. No change, no work.
Keyframes - a named timeline:
@keyframes spin {
to { transform: rotate(360deg); }
}
.loader {
animation: spin 0.8s linear infinite;
}
You get delay, iteration count, direction (alternate), fill-mode, and multiple waypoints (0%, 40%, 100%). That power is how people accidentally ship a 2-second bounce on every card.
Rule of thumb: if a user action causes the change, start with a transition. If the element must move while the user waits, use a short, looping keyframe.
Easing, duration, and what feels expensive
Duration. Buttons and toggles: 100–200 ms. Page-level fades: 200–300 ms. Anything over 400 ms on a repeated control feels like lag. Loaders can loop; they should still complete a visual cycle quickly so the motion reads as “working,” not “stuck.”
Easing. ease-out for things that enter (fast start, settle). ease-in for things that leave. linear for constant spins. cubic-bezier when the catalog’s curve matches a motion you already previewed. ease-in-out on a 80 ms color change is wasted nuance.
Delay. Staggered lists look expensive because they are more timers. A 40 ms stagger on five items is enough; 200 ms × 12 items is a film.
Preview the exact curve in CSS Animations before you paste. Then cut 20% off the duration. Almost no one will complain that a hover is too snappy.
Compositor-friendly properties
Promote motion that can avoid layout and paint storms:
- Good:
transform: translate,scale,rotate;opacity. - Expensive on large surfaces:
top/left,width/height,margin, animatingbox-shadoworfilteron a full-page layer.
will-change: transform is a hint, not a free lunch. Use it on an element that will actually animate soon, then remove it. Painting a spinning 4K decorative blob behind the page will hitch no matter how “compositor-friendly” the property list is.
If the motion is a color wash, you are painting. Keep the layer small. Tokens from Color Studio keep the wash on-brand without a second magenta.
prefers-reduced-motion is not optional
Some people set the OS to reduce motion because it makes them ill. Your job is to honor that:
@media (prefers-reduced-motion: reduce) {
.loader,
.hero-kenburns {
animation: none;
transition: none;
}
}
Replace a parallax hero with a static crop. Replace a looping bounce with a still icon. If a toast only appears because of an animation end event, show it immediately in the reduce branch.
Reduced motion is not “no color change.” A 100 ms background transition is usually fine. A sliding page plus zoom is not.
This is also an accessibility checkbox; A Practical WCAG Checklist will not catch every motion issue for you.
How to preview before you paste
- Open CSS Animations and find a motion close to the need (fade, slide, pulse, spin).
- Watch it at the catalog’s default duration, then imagine it on a 1× CPU phone.
- Copy the keyframes. Rename them (
@keyframes app-spin) so they do not collide. - Swap hard-coded colors for tokens.
- Add the reduced-motion query in the same PR.
- In the real page, confirm nothing else is animating
widthon the same frame.
The catalog is not a dependency. Once the CSS is in your repo, you do not need the tab.
What to leave as CSS and what to leave as JS
CSS: hover, focus-visible rings (do not animate the ring away), loaders, simple enter/leave if you can toggle a class.
JS (or Web Animations API): interruptible gestures, scroll-linked scenes, springs that should cancel mid-way. If you are already on Framer Motion for a reason, do not also run a CSS loop on the same node.
Favicons and palette work are separate steps - How to Generate Favicons will not make the tab icon dance, and it should not.
Preview the motion before you paste it
Preview the motion in CSS Animations, paint it with tokens from Color Studio, and ship a reduced-motion path in the same change. If the animation exists only to hide a slow request, fix the request.
Frequently asked questions
What is the difference between a transition and an animation?
A transition interpolates when a property changes (hover, class toggle). A @keyframes animation runs a timeline on its own (loops, delay, multiple stops). Use a transition for hover color; use keyframes for a loader that spins forever.
Which properties are cheapest to animate?
transform and opacity can run on the compositor. Animating width, top, or box-shadow on large layers is more likely to hitch. Preview first in CSS Animations, then measure in DevTools.
How do I respect reduced motion?
Wrap motion in @media (prefers-reduced-motion: reduce) and cut it to a fade or to nothing. Do not hide information that only appears mid-animation.
Why does my animation look fine in the preview and janky in the app?
The preview is one element. The app also has layout, images, and React re-renders. Keep the same properties, shorten duration, and check the Performance panel.
Can I copy keyframes from the catalog into production?
Yes. Treat them as a starting point: rename the animation, match your tokens from Color Studio, and add the reduced-motion query.
Do I need an account?
No. CSS Animations and Color Studio open on DevOkk.com without registration. You preview keyframes and copy CSS in the browser, then close the tab.
Related guides
More reading that links back to the same tools and workflows.
How to Build a UI Color Palette
Pick primaries, tints, and contrast-safe pairs in the browser.
4 min read
How to Generate Favicons for Every Browser
ICO, PNG, Apple touch, and SVG favicons from one source image.
4 min read
Why Your Favicon Isn’t Updating in the Browser Tab
You replaced favicon.ico and the old icon is still there. Caches, HTML link tags, SVG vs ICO, and how to generate a new set without an account.
7 min read
Best CSS and Frontend Design Tools
Color palettes, CSS animation previews, favicons, patterns, bundle size, and screen-reader checks - all in the browser.
4 min read