Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Field examples · Advanced

Choice Cards Field for React

Radio choice cards, each a bordered row with a title, a description and a radio, for picking a compute environment.

Framework
UI library

Turn each radio option into a card people can click anywhere on. Each FieldLabel wraps a horizontal Field with a FieldTitle, a FieldDescription and a RadioGroupItem, so the whole bordered row selects its option and highlights when checked. Use it for plans, environments or onboarding choices that need a line of context each.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How does the whole card select the radio?

FieldLabel wraps the Field, so the row is the label for that radio. RadioGroupItem sits at the end of the row.

Where do Kubernetes and Virtual Machine come from?

FieldTitle is the visible name, Kubernetes or Virtual Machine. The GPU sentence is the FieldDescription under that title, inside FieldContent.

What is the Compute Environment line?

FieldDescription under the caption reads Select the compute environment for your cluster. The caption is a FieldLegend with variant set to label, the quieter legend.

Which card starts selected?

defaultValue on RadioGroup is kubernetes. The other item's value is vm.

Why is the radio at the end of the card?

The inner Field sets orientation to horizontal, with FieldContent first and RadioGroupItem after it. FieldContent stacks the title and the description beside the radio.

How wide are the cards?

max-w-md caps the group. Both cards are rows in the same RadioGroup, so one environment is selected at a time.