Choice card
A few options that each need a title, a sentence and perhaps a price: plans, add-ons, delivery methods. Each card is a real radio button or checkbox with the whole card as its target. For options that fit in a word or two use the radio group or the checkbox group.
Install
npx shadcn@latest add @thrum-pro/choice-cardThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icon check from the icon set.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
ChoiceCardGroup: type | "radio" | "checkbox" | Default "radio" | radio: one card is picked and the arrow keys move the pick. checkbox: any number of cards can be ticked. |
ChoiceCardGroup: value | string | null, or readonly string[] | – | What is picked, when the parent holds it: one value for radio cards, a list for checkbox cards. Use it with onValueChange. |
ChoiceCardGroup: defaultValue | string | null, or readonly string[] | – | What is picked at first, when the group holds it itself. |
ChoiceCardGroup: onValueChange | (value: string) => void, or (value: string[]) => void | – | Called with the picked card's value for radio cards, or with the list of all ticked values for checkbox cards. |
ChoiceCardGroup: name | string | – | The field name of every card's input in a form. Left out, radio cards get a generated one, which they need to act as one group. |
ChoiceCardGroup: disabled | boolean | Default false | Every card is dimmed and cannot be picked. |
ChoiceCardGroup: sound | boolean | Default true | Play a soft click when a radio card is picked, or a pair of clicks when a checkbox card changes, if the visitor has sound on. |
ChoiceCardGroup: className | string | – | Extra classes for the group, merged last. It is a grid with an 8 pixel gap and one column; set columns or a width here. |
ChoiceCard: value | string | Required | What the group reports when this card is picked. Unique within the group. |
ChoiceCard: disabled | boolean | Default false | Shown dimmed. It cannot be picked, and the arrow keys skip it. |
ChoiceCard: className | string | – | Extra classes for the card, merged last. |
ChoiceCardTitle | ComponentProps<"span"> | – | The option's name, on the first line beside the mark. |
ChoiceCardDescription | ComponentProps<"span"> | – | A sentence about the option, in the muted text colour, across the card's width. |
ChoiceCardMeta | ComponentProps<"span"> | – | A price, a badge or another short fact, on the card's last line. |
Motion and sound
Motion
- A picked card's border takes the primary colour and gains a second pixel, drawn inside the card, over 150 ms. The card keeps its size.
- The mark in the corner fills while its dot or tick fades in and grows from half size, over the same 150 ms.
- Hovering a card darkens its border over 150 ms.
- Reduced motion: border, mark and tick change at once.
Sound
- Radio cards: a soft click with a short tone when another card is picked.
- Checkbox cards: two rising clicks when a card is ticked, two falling clicks when it is cleared.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- Every card is a label around a native radio button or checkbox, so roles, keyboard and form submission come from the browser. Radio cards follow the WAI-ARIA radio group pattern.
- The group has the radiogroup role, or the group role for checkbox cards. Name it with an aria-label or with aria-labelledby.
- A card's name is its text: title, description and price are read together.
- A picked card shows a heavier border and a filled corner mark, so selection never rests on colour. Radio cards have a round mark with a dot and checkbox cards a box with a tick, so the two kinds stay apart under any corner radius.
- The focus ring surrounds the whole card: 2 pixels of the theme's ring colour, 2 pixels away from it.
- Text wraps inside the card. Nothing overflows at 160 pixels wide.
- Each card is a control surface: under a glass material it turns translucent while keeping text at 4.5 to 1 contrast.
| Keys | Action |
|---|---|
| Tab | Radio cards: focus the picked card, or the first when none is picked; the group is one tab stop. Checkbox cards: every card is a tab stop. |
| ↓ / → | Radio cards: move to the next card and pick it. The last wraps to the first, and disabled cards are skipped. |
| ↑ / ← | Radio cards: move to the previous card and pick it. |
| Space | Tick or clear the focused checkbox card, or pick the focused radio card. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/choice-card.tsx- Packages
- None
- Brings along
- Sound engine
- Icons
check
Changelog
- 1.0.0 · 2026-12-03First release.