A button that presses down when tapped.
Installation
Usage
import { Button } from '@animate-ui/react/primitives/buttons/button';
export function Save() {
return <Button className="rounded-md px-4 py-2">Save</Button>;
}With asChild, the animation lands on your own element:
<Button asChild>
<a href="/docs">Docs</a>
</Button>Animation
- Pressing scales the button to
tapScale(0.97), on Motion's spring for scale (stiffness: 550, damping: 30): quick, with a slight overshoot. It doesn't scale on hover, unless you sethoverScale. transitionreplaces that spring.<AnimateUIProvider tempo>paces the default spring.- Under reduced motion, the button doesn't scale.
API Reference
Button
| Prop | Type | Default |
|---|---|---|
hoverScale? | number | 1 |
tapScale? | number | 0.97 |
transition? | Transition | { type: 'spring', stiffness: 550, damping: 30, restSpeed: 10 } |
asChild? | boolean | false |
...props? | HTMLMotionProps<'button'> | - |