Overview
animatedIf(condition, trueTpl, falseTpl?, config?) uses the Web Animations API to animate content in and out. Pass animationPresets.* factories into config.enter / config.exit instead of writing keyframes by hand.
Presets return an AnimationPreset ({ keyframes, options }) compatible with animatedIf, animatedRouter, and animate(). Swap preset objects at runtime — they are plain data.
How it differs
|
Approach
|
Best for
|
Notes
|
|---|---|---|
animationPresets.*
| WAAPI enter/exit |
Use with animatedIf / animatedRouter.
|
keyframes(name, stops)
| CSS @keyframes |
Returns a CSS animation name for style.animation — not an AnimationPreset.
|
| Raw WAAPI keyframes | Custom motion |
Pass your own { keyframes, options } when presets are not enough.
|
Switching between animation presets
Select a preset from the buttons, then toggle visibility. Each preset is a plain object with enter and exit AnimationPreset values — swap them freely at runtime.
withStagger on a short list
withStagger(preset, index, delayMs) offsets each item's enter animation.