Switch
Choose between a set of options.
Best Practices
- Use Switch as a segmented selector for 2–3 mutually exclusive options that show different views of the same surface, like
SourcevsOutput. - For a boolean on/off setting, use Toggle. Switch implements radio semantics, so two options stay mutually exclusive rather than reading as a checkbox.
- Past 3 options or when labels grow beyond a couple of words, switch to Tabs or a Select.
- Pass a
nameso the underlying radios are grouped; without it, more than one option can appear selected at once. - Set
defaultChecked(or controlledchecked) on exactly oneSwitch.Controlso the group has a defined initial state. - Pad each
Switch.Controlso the widest label fits without the active pill resizing on selection. Test with the longest copy in the set. - Title Case each
Switch.Controllabel. Keep labels to one or two words and parallel:Source/Output, notSource/Show output. - Always provide a
labelon everySwitch.Control, even when aniconcarries the meaning, so screen readers announce the option. The component renders it asgeist-sr-onlyfor icon-only controls. - Pair an icon-only Switch with a Tooltip on each control so sighted users get the same label assistive tech receives.
Was this helpful?