Animated Button
A drop-in replacement for the shadcn-svelte Button powered by svelte-motion. Spring-based press feedback and subtle hover lift come out of the box — no extra config needed.
Installation
Install via the shadcn-svelte CLI from our registry:
npx shadcn-svelte@latest add https://motion.svelte.page/r/animated-button.jsonnpx shadcn-svelte@latest add https://motion.svelte.page/r/animated-button.jsonThis installs AnimatedButton alongside your existing Button. It automatically pulls in @humanspeak/svelte-motion and tailwind-variants as dependencies.
Then use it:
<script>
import { AnimatedButton } from '$lib/components/ui/animated-button'
</script>
<AnimatedButton variant="default">Click me</AnimatedButton>
<AnimatedButton variant="outline" size="icon" aria-label="Like"><i class="fa-solid fa-heart" /></AnimatedButton>
<AnimatedButton animated={false}>No motion</AnimatedButton><script>
import { AnimatedButton } from '$lib/components/ui/animated-button'
</script>
<AnimatedButton variant="default">Click me</AnimatedButton>
<AnimatedButton variant="outline" size="icon" aria-label="Like"><i class="fa-solid fa-heart" /></AnimatedButton>
<AnimatedButton animated={false}>No motion</AnimatedButton>Manual Installation
Alternatively, copy the component source directly from GitHub.
Live Demo
Try clicking and hovering on each variant:
Variants
Sizes
With Icons
As Link
Disabled State
Without Animation
Set animated={false} to get vanilla shadcn behavior with no motion:
Animation Details
| Variant | whileTap | whileHover | Transition |
|---|---|---|---|
| default, secondary, outline, ghost, destructive | scale: 0.97 | y: -1 | Spring (400/25) |
| icon, icon-sm, icon-lg | scale: 0.9 | scale: 1.08 | Spring (400/25) |
| link | scale: 0.97 | scale: 1.03 | Spring (400/25) |
The animated prop (default true) lets consumers opt out entirely for vanilla shadcn behavior — useful for cases where the animation conflicts with a parent layout.
API
All standard shadcn-svelte Button props are supported, plus:
| Prop | Type | Default | Description |
|---|---|---|---|
animated | boolean | true | Enable/disable motion animations |
variant | string | "default" | Visual variant |
size | string | "default" | Size variant |
href | string | — | Renders as <a> (or motion.a) when set |