Selection Card

Card-shaped radio and checkbox options for choosing one or several from a set.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/selection-card.json

Usage

import {
  SelectionCardGroup, SelectionCard, SelectionCardTitle, SelectionCardDescription,
  SelectionCardMedia, SelectionCardContent,
} from "@/components/ui/selection-card"

Examples

Default

Radio options with room for a line of description each, for weighty choices like plans. The whole card is the hit target, and each one needs its own value.

StarterFor side projects and quick experiments. One seat included.ProRecommendedFor growing teams that need shared workspaces and priority support.EnterpriseAdvanced controls, audit logs, and a dedicated account manager.

Multiple

Set mode="multiple" and the cards become checkboxes: a square control, and any number can be picked at once. The value is an array of the picked values.

Product updatesNew features and improvements, sent as they ship.Weekly digestA Monday summary of everything that changed last week.Security alertsSign-in notifications and account activity you should know about.

Title only

The description is optional. With just a title, the card collapses to a single line and the control stays centred on it.

Billed monthlyBilled yearly

Disabled option

Disable a single card with disabled, or the whole set by putting disabled on the group. A disabled card dims and drops out of keyboard navigation.

Credit cardVisa, Mastercard, and American Express.Bank transferNot available in your region yet.

Media

variant="media" drops the control for a picture over the words, for when the picture tells the options apart. The accent ring is the only picked state, and the edge darkens on hover.

StorySomething that happened, and what you took from it.AnnouncementSomething new that people should know about.

Icon

variant="icon" sets an icon over the words, all on the left edge, and moves the control to the top right corner. Pass the icon as the icon prop; it turns accent when the card is picked.

SlideshowYour images, one after another.Live pageA web page, recorded scrolling.Talking clipA cut of someone talking, with captions.Animated cardYour point, a line at a time.

API Reference

PropTypeDefaultDescription
variantSelectionCard"default" | "media" | "icon""default"media removes the control and lays the card out as a picture over its words. Compose it from <SelectionCardMedia /> and <SelectionCardContent />. icon puts the icon prop over the words and moves the control to the top right.
iconSelectionCardReactNodeNoneThe icon an icon card shows over its title, at 20px. Ignored by the other variants.
modeSelectionCardGroup"single" | "multiple""single"single renders radio cards (round control, one choice). multiple renders checkbox cards (square control, any number).
defaultValueSelectionCardGroupstring | string[]NoneThe initially selected value, for uncontrolled usage. A string for single, an array of values for multiple.
valueSelectionCardGroup, SelectionCardstring | string[]NoneOn the group, the controlled selection (use with onValueChange). On <SelectionCard />, the value this card contributes (required).
onValueChangeSelectionCardGroup(value: string | string[]) => voidNoneCalled with the new selection. A string for single, an array for multiple.
disabledSelectionCardGroup, SelectionCardbooleanfalseDisables every card, or a single card on <SelectionCard />.
variantSelectionCard"default" | "media" | "icon" = "default"media removes the control and lays the card out as a picture over its words. Compose it from <SelectionCardMedia /> and <SelectionCardContent />. icon puts the icon prop over the words and moves the control to the top right.
iconSelectionCardReactNodeThe icon an icon card shows over its title, at 20px. Ignored by the other variants.
modeSelectionCardGroup"single" | "multiple" = "single"single renders radio cards (round control, one choice). multiple renders checkbox cards (square control, any number).
defaultValueSelectionCardGroupstring | string[]The initially selected value, for uncontrolled usage. A string for single, an array of values for multiple.
valueSelectionCardGroup, SelectionCardstring | string[]On the group, the controlled selection (use with onValueChange). On <SelectionCard />, the value this card contributes (required).
onValueChangeSelectionCardGroup(value: string | string[]) => voidCalled with the new selection. A string for single, an array for multiple.
disabledSelectionCardGroup, SelectionCardboolean = falseDisables every card, or a single card on <SelectionCard />.