Like buttonPro
Heart toggle that bursts into particles and rolls its count.
pnpm dlx shadcn@latest add @lode/like-buttonShipping our biggest release yet
Thirty new components, all animated and keyboard friendly.
When to use
- Likes, favorites and reactions on posts, comments and products.
When not to use
- Settings: use a switch.
Installation
pnpm dlx shadcn@latest add @lode/like-buttonPro components need an API key and the registry in components.json. See CLI and API keys.
1Install the dependencies
npm install motion lucide-react2Copy the source into your project
Usage
Import it from @/components/ui/like-button after installing.
import { LikeButton } from "@/components/ui/like-button";
export function PostActions({ post }: { post: Post }) {
return <LikeButton count={post.likes} defaultLiked={post.likedByMe} onLikedChange={(liked) => setLike(post.id, liked)} label="Like this post" />;
}API reference
LikeButton
A toggle button with a heart, a particle burst and an optional rolling count.
liked / defaultLiked / onLikedChange
boolean
Controlled or uncontrolled state.
count
number
Total likes. Uncontrolled, it adjusts by one as you toggle.
label= "Like"
string
What is being liked; the count is appended for screen readers.
size= "md"
"sm" | "md" | "lg"
Height and icon size.
| Prop | Type | Default | Description |
|---|---|---|---|
| liked / defaultLiked / onLikedChange | boolean | – | Controlled or uncontrolled state. |
| count | number | – | Total likes. Uncontrolled, it adjusts by one as you toggle. |
| label | string | "Like" | What is being liked; the count is appended for screen readers. |
| size | "sm" | "md" | "lg" | "md" | Height and icon size. |
Keyboard interactions
| Keys | Action |
|---|---|
| EnterorSpace | Toggle |
Accessibility
- A button with aria-pressed, named with what is liked and the count.
- Color is backed by a filled heart.
Motion
- The heart springs in from 20%; a ring and ten particles burst outward (600ms).
- The count rolls up or down.
- No burst under reduced motion.
Responsive behavior
- Inline; three sizes for dense lists and hero actions.
Performance
- Particles exist only during the burst.
Notes for AI
- When controlled, pass the already-updated count yourself.
This page as Markdown, for assistants and coding agents:
/components/like-button/markdownThe full library index for assistants is at /llms.txt.
Related
Lode·229 doc pages·llms.txt