Like buttonPro
Heart toggle that bursts into particles and rolls its count.
Shipping 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
Usage
Import it from @/components/ui/like-button after installing.
example.tsx
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.
| 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.
Lode222 doc pagesllms.txt