keyframes
stablefunction keyframes(def: KeyframeDef): Keyframe
Map from percent / from / to selectors to a style bag. Same shape as a CSS @keyframes block, expressed as an object — `0%`, `50%`, `100%`, or the convenience aliases `from` and `to`.
Description
Builds a named keyframe sequence that motion props consume directly. The returned Keyframe is a
branded type — motif's runtime recognises it on the animation prop and emits the matching
@keyframes rule into the page stylesheet alongside the using component's class.
A Keyframe is stable across renders. Define it at module scope and reference it from inside the
component; defining it inline allocates on every render.
KeyframeDef
Selectors are the literal CSS keyframe selectors: '0%', '50%', '100%', 'from', 'to'.
Values are style bags identical to the shape accepted by style props — token references,
literals, and shorthands all work.
Example
Where keyframes resolve
The runtime emits the @keyframes rule once per unique definition and hashes the resulting name.
A hundred toasts sharing the same slideIn produce one keyframe rule, one class on each toast,
and no duplication.
On native, the animation prop routes through React Native's animation drivers (or Reanimated if
installed). The Keyframe shape is the same; the runtime adapts.
Related
styled— declare animations onbaseor per-variant.- Animation patterns — common shapes (entrance, exit, attention).