Pro
Quantity pill
Add to an order in one press. Add opens sideways into a − count + pill, the count rolls as it changes, and the minus turns into a bin at one. Focus moves to plus after adding and back to Add after the last one is removed.
pnpm dlx shadcn@latest add @caliper/quantity-pillWhen to use
Use it for
- Menus, carts and shop listings where most people add one and some add a few.
- Tight rows where a full number field would crowd the line.
Skip it when
- Large quantities typed exactly; use the number field.
- Settings with a range; use a slider.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Focus never drops
- When Add becomes the pill, focus lands on plus; when the pill becomes Add, focus returns to it.
- Every button names the item
- "One more Oat flat white" and "Remove Oat flat white", so a list of pills is clear out of context.
Installation
pnpm dlx shadcn@latest add @caliper/quantity-pill
Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.
Usage
Import it from your copy of the source. The example behind the preview comes with the source.
import { QuantityPill } from "@/components/ui/quantity-pill"
The worked example comes with Pro
The 42-line example behind the preview opens here, ready to copy.
- 576 Pro parts, blocks and page templates, all with source
- $199 once, with a year of updates. What you have stays yours
- A full refund within 14 days if it is not for you
API reference
QuantityPill
component
Also accepts the native props of its root element and a ref.
Accessibility
It exposes group semantics, with aria-label, aria-hidden and aria-live kept in step with state. Changes that matter are announced through a live region.
No custom key handling; Tab and the native activation keys do the work.
Motion
It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.