Like Button
Overview
A heart button that pops with a particle burst and rolling count.
This action component is intended for interfaces that need a heart button that pops with a particle burst and rolling count, SaaS workflows, and onboarding flows. Its implementation is provided as editable source so the final behavior and styling stay inside your project.
Technologies
Detected package dependencies: framer-motion.
Tap a heart — spring pop, ring pulse, particle burst and a rolling count
Installation
Usage
import { LikeButton } from "@/components/spectrumui/like-button"<LikeButton count={128} onLikedChange={(liked) => console.log(liked)} />API Reference
LikeButton
Renders a single button element with aria-pressed reflecting the liked state. Pass liked to control it from outside, or defaultLiked to let it manage its own state.
| Prop | Type | Default | Description |
|---|---|---|---|
liked | boolean | - | Controlled liked state. Leave undefined for uncontrolled usage |
defaultLiked | boolean | false | Initial liked state when uncontrolled |
onLikedChange | (liked: boolean) => void | - | Fires with the next liked state on every toggle |
count | number | - | Like total excluding the current user; +1 is shown while liked. Totals of 1000+ are compacted (1.2K) |
showCount | boolean | true | Hide the rolling counter even when count is set |
size | "sm" | "md" | "lg" | "md" | Visual size of the button |
particleColors | string[] | - | Colors cycled across the burst particles |
label | string | "Like" | Accessible name of the action |
disabled | boolean | false | Disables pointer and keyboard interaction |
className | string | - | Additional classes merged with the default button styles |
Examples
Sizes
Use cases
- interfaces that need a heart button that pops with a particle burst and rolling count
- SaaS workflows
- onboarding flows
Features
- Copy-paste source that remains in your repository
- TypeScript source included with the component
- Tailwind CSS classes editable in the component source
- Animation implemented with Motion
- Responsive Tailwind variants present in the source
- Reduced-motion handling present in the source
Accessibility
- The source includes ARIA attributes or roles; preserve them when customizing the component.
- The source checks reduced-motion preferences or includes motion-reduce styles.
- Test focus order, keyboard operation, labels, contrast, and screen-reader output in the final application context.
Customization
- Edit the Tailwind utility classes in the copied source to match your spacing, color, and typography tokens.
- Use the documented className surface for local layout adjustments, then edit the source for structural changes.
- Adjust Motion transitions in the source and keep the reduced-motion behavior aligned with the final interaction.
Related components
Topic guides
See how this component fits into broader interface patterns, implementation decisions, and working examples.
Like Button FAQ
Is Like Button free to use in commercial projects?
Yes. The public Like Button source is available under the Apache License 2.0, including for commercial use, subject to the LICENSE terms.
How do I install Like Button?
Run npx shadcn@latest add @spectrumui/like-button. The page also exposes the source for manual installation.
Does Like Button require Motion?
Yes. Motion usage was detected in the documented source or registry dependencies for Like Button.
Does Like Button use shadcn/ui or Radix UI?
No shadcn/ui or Radix UI dependency was detected in the documented Like Button source.
Can I use Like Button in Next.js?
The documented React source is used in this Next.js application. Keep its use client directive when copying it into the App Router. Install the detected dependencies and verify any application-specific data or image configuration.
What accessibility checks should I run for Like Button?
The source includes ARIA markup, reduced-motion handling. Test the finished interface with keyboard and screen-reader workflows.