Keyframery

Four motion styles, one setting

Switch every Keyframery component between Calm, Springy, Snappy and Playful motion with one attribute. Timing, springiness and pop change; your markup doesn't.

Part of Keyframery, the open-source animated components for UI SDK

A motion style changes how everything moves: how fast, how springy, how much pop. Try it here. The switcher changes this whole site.

Motion style
Changes the whole site, and is remembered.
StyleSpeedFeelGood for
Calm1.35× slowerNo bounce; moves settle softlyDashboards, finance, long sessions
Springy1×A 5% spring and a 16% pop. The defaultMost products
Snappy0.6× (faster)Crisp, almost no overshootDeveloper tools, dense apps
Playful1.15×A 12% spring and a 29% popConsumer apps

Set a style

Put data-motion on <html>. Popups render at the end of <body>, so setting it on <html> makes sure they follow too. Leave it off for Springy.

<html data-motion="calm">

Let people choose

The switcher is a component like the others. It applies the style to the page and remembers the choice.

npx shadcn@latest add @keyframery/motion-style
import { MotionStyleSwitcher } from "@/components/keyframery/motion-style"

export function Settings() {
  return <MotionStyleSwitcher />
}

How it works

Every duration in every component is written as a multiple of one variable, and every easing reads one of three tokens:

/* inside a component */
transition: scale calc(260ms * var(--kf-speed, 1)) var(--ease-pop);
TokenWhat it isUsed for
--kf-speedA multiplier for every duration and delayThe overall pace
--ease-houseA smooth ease-out, no overshootFades, heights, stretches
--ease-springA spring with a small overshootMoves and entrances
--ease-popA livelier springSmall payoffs: a check landing, a press releasing

A style is new values for those tokens. The springs are written with CSS linear(), so nothing runs in JavaScript.

Make your own

[data-motion="brand"] {
  --kf-speed: 0.85;
  --ease-spring: var(--ease-house); /* no overshoot on moves */
}

Then use data-motion="brand".

Nesting

data-motion works on any element, so one part of an app can move differently from the rest:

<html data-motion="calm">
  …
  <section data-motion="playful">{/* onboarding */}</section>
</html>

Popups opened from inside the section render at the end of <body>, so they follow the style on <html>.

Questions

Can different parts of my app use different styles?

Yes. data-motion works on any element and changes the motion inside it.

Can I make my own style?

Yes. A style is three CSS variables: --kf-speed, --ease-spring and --ease-pop. Set them under your own data-motion value.

On this page