Like Counter
betaA round heart button beside a bold count: liking ripples a ring, bursts sparkles, fills the heart and rolls the number up.
- Forms
- 1 file
- 1 npm package
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add like-counternpm packages installed: class-variance-authority.
import { LikeCounter } from "@/components/ui/like-counter";Default
Pink Accent
Demo
<LikeCounter>
| Prop | Type | Default |
|---|---|---|
count (required)The total, as your data has it. Uncontrolled, it is the total at | number | — |
accentAny CSS colour for the filled heart and burst. Defaults to currentColor. | string | — |
defaultLikedInitial state when uncontrolled. | boolean | false |
labelThe accessible name before the count: "Like, 128". | string | "Like" |
likedControlled state. When set, | boolean | — |
onLikedChange | (liked: boolean) => void | — |
size | "sm" | "md" | "lg" | "md" |
Plus every attribute of <button> except children.
One native button with aria-pressed, named "Like, 128" so the count is heard; the count only changes when the person presses the button, so there is no separate live region to chatter. The heart, the burst and the rolling digits are aria-hidden. Click, Space and Enter toggle it, with a visible focus ring. Under reduced motion every keyframe collapses to its resting frame and the count simply changes. The filled state is shown by fill as well as colour.
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