Skip to content
Thrum

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-card

This 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

PropTypeDefaultDescription
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: valuestring | 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: defaultValuestring | 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: namestring–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: disabledbooleanDefault falseEvery card is dimmed and cannot be picked.
ChoiceCardGroup: soundbooleanDefault truePlay 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: classNamestring–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: valuestringRequiredWhat the group reports when this card is picked. Unique within the group.
ChoiceCard: disabledbooleanDefault falseShown dimmed. It cannot be picked, and the arrow keys skip it.
ChoiceCard: classNamestring–Extra classes for the card, merged last.
ChoiceCardTitleComponentProps<"span">–The option's name, on the first line beside the mark.
ChoiceCardDescriptionComponentProps<"span">–A sentence about the option, in the muted text colour, across the card's width.
ChoiceCardMetaComponentProps<"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.
KeysAction
TabRadio 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.
SpaceTick or clear the focused checkbox card, or pick the focused radio card.

Source

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor