Spring press button

Button squashes on press and springs back with a slight overshoot on release.

ButtonPress Pure CSS time-based Targets: Web · App All modern browsers
Target
Implement the "Spring press button" effect in vanilla HTML/CSS/JS.

Context: Button squashes on press and springs back with a slight overshoot on release.
Trigger: the element is pressed (pointerdown → pointerup).
Timeline: time-based (duration + easing).

Motion tokens (normal):
- scale: 0.94 (while pressed) → 1 (release)
- duration: 400ms
- easing: cubic-bezier(0.34, 1.56, 0.64, 1)
- note: press-in uses 120ms ease-out; release uses the overshoot curve

Motion tokens (prefers-reduced-motion):
- opacity: 1 → 0.8 (while pressed)
- duration: 120ms
- easing: ease-out

Technique: prefer pure CSS transitions/animations; use JS only to toggle classes.

Acceptance:
- animate only transform and opacity unless the spec lists other properties
- no layout shift; content is visible without the animation
- when prefers-reduced-motion is set, use the reduced tokens only
- works with keyboard activation (Space/Enter) as well as pointer
- no change to layout size of neighbours

Generated from the spec. Prompts differ by target name only; the tokens are the source of truth.