Like Button
betaA heart toggle with a rolling count: liking pops the heart with a ring burst and radiating dots, unliking deflates quietly.
- Feedback
- 1 file
- 1 npm package
- Accessibility notes
pnpm dlx @dowel-ui/cli add like-buttonnpm packages installed: class-variance-authority.
import { LikeButton } from "@/components/ui/like-button";Default
Glyphs
Sizes
Compact Count
Icon Only
Controlled
<LikeButton>
| Prop | Type | Default |
|---|---|---|
countThe total, as your data has it. Uncontrolled, it is the total at | number | — |
defaultLikedInitial state when uncontrolled. | boolean | false |
formatIntl.NumberFormat options for the count, e.g. | Intl.NumberFormatOptions | — |
iconThe glyph. Defaults to a heart; any stroked icon (a star, a bookmark) fills the same way. | ReactNode | — |
labelThe accessible name, before the count: "Like, 128". | string | "Like" |
likedControlled state. When set, | boolean | — |
onLikedChange | (liked: boolean) => void | — |
showCountShow the count beside the icon. Hidden when there is no | boolean | true |
size | "sm" | "md" | "lg" | "md" |
tone | "destructive" | "primary" | "warning" | "success" | "foreground" | "destructive" |
Plus every attribute of <button> except children, iconOnly.
10/10
checks passed
- Tested — passes
- axe assertion — passes
- Keyboard tested — passes
- Storybook examples — passes
- Accessibility documented — passes
- Semantic tokens only — passes
- Motion from tokens — passes
- className merged — passes
- Visible focus — passes
- No fixed widths — passes