Tokens
The springs, durations, easings and delays every buttery animation is made of.
Motion tokens are the named springs, durations, easings and delays buttery animates with, such as spring.smooth or --bt-dur-fast. Use a token for every animation, so timings stay consistent and reduced motion can turn them all down at once.
Springs
Springs move things: positions, sizes and layouts. spring from @butteryui/core holds them for Motion, and useButteryTransition(name) returns one with reduced motion already applied.
| Token | Settles in | Use |
|---|---|---|
spring.instant | the next frame | Reduced motion, and snaps nobody is driving |
spring.snappy | about 165ms | Selection indicators, and a menu switching sections |
spring.smooth | about 230ms | The default: positions, resets, layout and height changes, dialogs |
spring.morph | about 345ms | A big surface changing shape, such as a card becoming a dialog |
spring.gentle | about 360ms | Choreographed entrances only |
import type { ReactElement } from "react";
import { motion } from "motion/react";
import { useButteryTransition } from "@butteryui/core";
export function SelectedMark({ x }: { readonly x: number }): ReactElement {
const transition = useButteryTransition("snappy");
return <motion.span animate={{ x }} transition={transition} />;
}Durations, easings and delays
CSS transitions fade and recolor: opacity, colors and shadows. Each duration and easing is a CSS variable. Enters use --bt-ease-out, and exits --bt-ease-in.
- --bt-dur-instant
- 0ms
- --bt-dur-press
- 80ms
- --bt-dur-reduced
- 100ms
- --bt-dur-fast
- 120ms
- --bt-dur-base
- 200ms
- --bt-dur-slow
- 300ms
- --bt-dur-shimmer
- 1600ms
- --bt-ease-out
- cubic-bezier(0.22, 1, 0.36, 1)
- --bt-ease-in
- cubic-bezier(0.4, 0, 1, 1)
- --bt-ease-standard
- cubic-bezier(0.2, 0, 0, 1)
The timing tokens hold the delays and lifetimes around a transition, such as how long the pointer rests before a menu opens, or how long a toast stays:
| Token | Value | What it times |
|---|---|---|
| --bt-stagger | 50ms | The gap between staggered items, closer in a long list |
| --bt-delay-hover-open | 150ms | The pointer's rest on a trigger before its menu opens |
| --bt-delay-hover-close | 100ms | The wait after the pointer leaves before a menu closes |
| --bt-delay-hover-skip | 300ms | The time after a close in which a menu reopens at once |
| --bt-delay-tooltip | 500ms | The wait before a tooltip opens |
| --bt-loop-cycle | 4000ms | One step of a Loop |
| --bt-entrance-max | 900ms | The longest choreographed entrance, stagger included |
| --bt-celebration | 900ms | A confetti burst's life |
| --bt-toast-life | 3000ms | How long a toast stays while nothing pauses it |
| --bt-toast-life-action | 5000ms | How long a toast with an action stays |
| --bt-announcement-life | 1000ms | How long a live region holds what it announced |
| --bt-typeahead | 500ms | How long typed letters build up one search in a list |
| --bt-delay-follow | 80ms | The wait before chrome that follows a change arrives |
| --bt-count-up | 800ms | A stat counting up to its number |
| --bt-delay-submenu | 40ms | The pointer's rest on an item before its submenu opens |
| --bt-delay-loading | 300ms | How long loading lasts before a loading pill shows |
| --bt-delay-search | 120ms | The pause after typing before a search asks a server |
Related
- Principles
The ten rules every buttery animation follows, and the few things it never animates.
- Presets
The motion primitives that apply buttery's rules for you, from presence and morphing to reveals and loops.