Cart Badge
betaA bag tile with a count badge and a plus button that flies a dot into the bag on an arc, popping the badge as it lands.
- Feedback
- 1 file
- 1 npm package
- Accessibility notes
Loading the example…
pnpm dlx @dowel-ui/cli add cart-badgenpm packages installed: class-variance-authority.
import { CartBadge } from "@/components/ui/cart-badge";Default
Demo
Controlled Count
Sizes
<CartBadge>
| Prop | Type | Default |
|---|---|---|
addLabelThe accessible name of the "+" button. | string | "Add to bag" |
countControlled count. | number | — |
defaultCountInitial count when uncontrolled. | number | 0 |
disabledDisables the "+" button. | boolean | — |
formatStatusWords for the live region. Defaults to "3 items in bag". | (count: number) => string | defaultStatus |
onAddCalled when "+" is pressed, before the dot lands. | () => void | — |
onCountChangeCalled with the requested count when "+" is pressed. | (count: number) => void | — |
size | "sm" | "md" | "lg" | "md" |
Plus every attribute of <div> except children.
The plus is a native button named by `addLabel` ("Add to bag"), operable with Enter and Space and with a visible focus ring. The bag drawing, badge digits and flying dot are aria-hidden; a polite live region states the count in words ("3 items in bag") and updates only when a dot lands, so rapid presses do not chatter. Under reduced motion the flight and pop snap to their final frames and the count updates at once.
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