Segmented control

Segmented control is used to pick one choice from a linear set of closely related choices, and immediately apply that selection.

v0.35.1AlphaReviewed for accessibility

Description

Use a segmented control to let users select an option from a short list and immediately apply the selection

Accessibility

A SegmentedControl should not be used in a form as a replacement for something like a radio group or select. See the Accessibility section of the SegmentedControl interface guidelines for more details.

Arguments

NameTypeDefaultDescription
hide_labels
Boolean

false

Whether to hide the labels and only show the icons

full_width
Boolean

false

If the component should be full width

size
Symbol

:medium

One of :large, :medium, or :small.

system_arguments
Hash

N/A

Examples

Slots

items

Use to render an item in the segmented control

NameTypeDefaultDescription
system_arguments
Hash

N/A

SegmentedControl::Item

SegmentedControl::Item is a private component that is only used by SegmentedControl It wraps the Button and IconButton components to provide the correct styles

Arguments

NameTypeDefaultDescription
label
String

N/A

The label to use

selected
Boolean

false

Whether the item is selected

icon
Symbol

nil

The icon to use

hide_labels
Symbol

false

Whether to only show the icon

Slots

trailing_visual_label

Optional trailing Label

NameTypeDefaultDescription
system_arguments
Hash

N/A

The arguments accepted by Button's with_trailing_visual_label slot.

Methods

with_trailing_visual_label(system_arguments: Hash)

Optional trailing label.

Parameters

NameTypeDefaultDescription
system_arguments
Hash

N/A

The arguments accepted by Button's with_trailing_visual_label slot.