Switch, Checkbox, RadioGroup
FrondUsage
The import, then a use to start from. Both copy as they are.
Import
import { Checkbox } from "@/components/ui/checkbox";import { Label } from "@/components/ui/label";import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";import { Switch } from "@/components/ui/switch";Example
<Switch checked={askFernEnabled} onCheckedChange={setAskFernEnabled} aria-label="Ask Fern" /> <RadioGroup value={layout} onValueChange={setLayout}> <div className="flex items-center gap-2"> <RadioGroupItem value="stacked" id="layout-stacked" /> <Label htmlFor="layout-stacked">Stacked</Label> </div> <div className="flex items-center gap-2"> <RadioGroupItem value="side-by-side" id="layout-side-by-side" /> <Label htmlFor="layout-side-by-side">Side by side</Label> </div></RadioGroup>When to use
Use it for
Switchapplies the moment it flips and confirms with a toast: for settings that take effect at once.Checkboxbelongs to a form that waits for Save, or selects rows in a table. It has an indeterminate state for “some”.RadioGroupfor one choice of 2 to 5 that should all stay in view.
Avoid
- A
Switchin a form with a Save button. People expect a switch to act on its own. - Two radio buttons for on and off: that's one
SwitchorCheckbox. - More than 5 options: use a
Select.
Accessibility
Checks
- Every control has a visible label tied to it, or an
aria-labelwhen the row's text names it. - Space toggles and the arrow keys move within a radio group; don't override them.
API
Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.
Switch
| Prop | Values |
|---|---|
| disabled | boolean |
VariantsDefaultCheckedDisabledDisabledCheckedWithLabel
Checkbox
| Prop | Values |
|---|---|
| disabled | boolean |
VariantsDefaultCheckedIndeterminateDisabledDisabledCheckedWithLabel
RadioGroup
Its stories don't declare
argTypes, so no props are listed. The variants show its states.Also exportsRadioGroupItem
VariantsDefaultWithDescriptionsDisabled
Keep going
- Input, TextareaText entry. Always with a
Label; errors viaaria-invalidand aNote.Frond - Select, SearchableDropdownOne of many. Searchable above ~8 options.Frond
- Settings cardsOne card per concern with its own Save; destructive actions last.Understory
Patterns
How components come together into pages.