Skip to main content
Kaleidoscope

SegmentedControl

Use SegmentedControls to offer 2—4 related, but mutually exclusive options to choose from.

Default

SegmentedControl displays a short list of options for users to choose from. It's usually best to have an option selected by default, but the component also supports an null initial selected value for when an initial selection can't be determined.

Editable example

Best practices

  1. Don't use a SegmentedControl as a binary switch (e.g. "on" and "off").
  2. Don't use for more than 4 options, or less than 2 options.
  3. Make sure your labels are short enough to fit comfortably in the available width.

Sizes

By default, SegmentedControls are medium sized. For using in context with other large sized controls, or in less dense UIs such as onboarding flows, use the large SegmentedControlSize.

Editable example

Number of options

SegmentedControls are best suited to 2—4 options. Anything beyond that you should consider using another component such as a or . If you only have a single option use a .

Keep in mind the available space for each option's label. Consider abbreviating labels or using icons when space is limited.

Editable example

Icon options

Use icons for options that can be clearly identified with a simple icon. Include a visible label within the option, or pair icon options with a tooltip using the baked in tooltip prop for extra clarity, particularly for less common or more ambiguous icons.

Editable example

End element

To render content at the end of a SegmentedControlOption, use the endElement prop.

Editable example

Asymmetric

By default, SegmentedControl options are equal width. To allow options to be of variable widths, use the asymmetric prop.

Editable example

Errors

Use the error prop to set any validation errors.

Editable example

Accessibility

  • Always include a label that describes the group of choices, e.g. "Block width". If the grouping of options is self-evident or implied by context, use the labelHidden prop so the label will not appear visually but still be read by assistive technology.
  • Always include labels for options, even icon options. The label is used as the aria-label attribute for icon options. You can also use a tooltip for icon options.