Components/Forms
Single choice from a set, with arrow-key navigation and card layouts.
Shipping speed
Installation#
npx shadcn@latest add https://get-neonkit.vercel.app/r/radio-group.jsonUsage#
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue="express" aria-label="Shipping speed">
<RadioGroupItem value="standard" label="Standard" />
<RadioGroupItem value="express" label="Express" />
</RadioGroup>Examples#
Card variant
variant="card" turns each option into a tile. icon sits above the label and children render below it.
Horizontal
Row density
Disabled option
Disabled options are skipped by arrow keys.
Backup frequency
API reference#
RadioGroup
Renders a div with role="radiogroup" and accepts its attributes.
| Prop | Type | Default |
|---|---|---|
value | stringControlled selected value. | — |
defaultValue | stringInitial value when uncontrolled. | — |
onValueChange | (value: string) => voidCalled when the selection changes. | — |
name | stringShared name of the native radios. Set it to submit the value with a form. | generated |
orientation | "vertical" | "horizontal"Stacks options or lays them out in a row (a responsive grid for cards). | "vertical" |
variant | "default" | "card"Classic radios, or bordered tiles with a corner indicator. | "default" |
color | NeonColorPalette name or hex. Falls back to --neon-accent, then cyan. | inherited |
size | "sm" | "md" | "lg"Radio, text and card padding. | "md" |
disabled | booleanDisables every option. | false |
required | booleanRequires a selection before a form can submit. | false |
RadioGroupItem
className and style go to the outer label; other native input attributes go to the radio input, which also receives the ref.
| Prop | Type | Default |
|---|---|---|
value | stringValue reported when this option is selected. Required. | — |
label | ReactNodeOption name, used as the accessible name. | — |
description | ReactNodeSecondary text, linked with aria-describedby. | — |
icon | ReactNodeCard variant only. Shown above the label and lit when selected. | — |
children | ReactNodeExtra content below the description, such as a price. Also announced as a description. | — |
disabled | booleanDisables this option only. | false |
Accessibility#
- Options are native radio inputs sharing one name, so the group is a single tab stop and arrow keys move and select.
- Give the group an accessible name with aria-label or aria-labelledby.
- Each label is wired with aria-labelledby, so descriptions and card content are read as descriptions, not as part of the name.