Installation
$ pnpm dlx shadcn@latest add @synccn/radio-groupFirst time in this project? Connect synccn with one command.
Usage
import { RadioGroup } from "@/components/ui/radio-group";<RadioGroup variant="cards" options={plans} />API reference
Generated from the component's TypeScript types, so it always matches the code.
RadioGroup
options: [{ value, label, description?, disabled? }] variant "default" renders dots, "cards" renders selectable tiles.
PropTypeDescription
- optionsrequired
RadioOption[]Choices.
- value
stringControlled value.
- defaultValue
stringInitial value when uncontrolled. Defaults to the first option.
- onValueChange
(value: string) => voidCalled with the new value.
- variant
"default" | "cards"Default
"default"Dots or selectable cards.
- name
stringAccessible name if no label is given.
- label
stringAccessible name for the group.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
npm packages
- clsx for cn()
- tailwind-merge for cn()
Used by
Keyboard
- ↓or→Select the next option
- ↑or←Select the previous option
- TabLeave the group
Accessibility
- Only the selected radio is in the tab order, as in a native radio group.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: radio, radiogroup
- ARIA attributes: aria-checked, aria-label
- Keys handled: ArrowUp, ArrowDown, ArrowLeft, ArrowRight
- Shows a visible focus ring for keyboard users
- Labels are tied to their controls
More inputs
ButtonSeven variants, four sizes and a built-in loading state.InputText field with optional leading icon and invalid state.TextareaMulti-line field that grows with its content and counts characters.CheckboxChecked, unchecked and indeterminate, with label and description.SwitchToggle with a springy thumb in three sizes.SliderSingle value or range, with keyboard steps and value bubbles.