A button that presses down when tapped.
Installation
Usage
<script setup lang="ts">
import { Button } from '@animate-ui/vue/primitives/buttons/button';
</script>
<template>
<Button class="rounded-md px-4 py-2">Save</Button>
</template>With as-child, the animation lands on your own element:
<Button as-child>
<a href="/docs">Docs</a>
</Button>Animation
- Pressing scales the button to
tap-scale(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 sethover-scale. transitionreplaces that spring.<AnimateUIProvider :tempo>paces the default spring.- Under reduced motion, the button doesn't scale.
API Reference
Button
| Prop | Type | Default |
|---|---|---|
hover-scale? | number | 1 |
tap-scale? | number | 0.97 |
transition? | Transition | { type: 'spring', stiffness: 550, damping: 30, restSpeed: 10 } |
as-child? | boolean | false |
...props? | HTMLMotionProps<'button'> | - |