#341
Press spring
A button that scales to 0.94 on press and overshoots past 1 on release before settling, driven by a Spring.
Hand this to your AI. It names the exact library parts, timings and accessibility promises of this demo.
Build the "Press spring" pattern (@codeatlasdev/ui demo #341, motion/micro) in my app.
Call get_demo({ ids: ["#341"] }) first and keep its structure. It needs @codeatlasdev/[email protected].
Use: Any tappable surface (pay, send, buy) that needs a physical press feel without a color change.
Keep these library parts, with the props and tokens the demo uses:
- MotionStage from "@codeatlasdev/ui"
Behaviour to keep:
- `MotionStage` from `@codeatlasdev/ui` with `loop={1800}`
- `new Spring(1, { stiffness: 0.35, damping: 0.42 })` is the scale
- `scale.target = 0.94` on pointerdown and on Space or Enter keydown
- `scale.target = 1` on pointerup, pointerleave, pointercancel and keyup: the low damping overshoots
- `transform: scale(var(--s, 1))` is the only animated property
- Under reduced motion `--s` stays at 1
Exact motion (do not approximate):
- transform: scale: spring, spring, spring stiffness: 0.35, damping: 0.42
Reduced motion: the demo handles it; keep that branch.
Keyboard: operable; keep the focus order and key handling.
Change only the copy and the data. Use the theme tokens (--ca-*), never raw colours. Library parts
- MotionStage
@codeatlasdev/ui
How it is built
- `MotionStage` from `@codeatlasdev/ui` with `loop={1800}`
- `new Spring(1, { stiffness: 0.35, damping: 0.42 })` is the scale
- `scale.target = 0.94` on pointerdown and on Space or Enter keydown
- `scale.target = 1` on pointerup, pointerleave, pointercancel and keyup: the low damping overshoots
- `transform: scale(var(--s, 1))` is the only animated property
- Under reduced motion `--s` stays at 1
Related
Loading source.