Segmented control

Basic

Each option is a real radio input inside a label, so the value posts with the form and the arrow keys move the choice. No script is needed. Give the group role="radiogroup" and an aria-label.

Small and disabled

data-size="sm" on the group makes it 24px tall. disabled on an input dims that option.

In a field

Use a .field with a label above, like any other input.

Attributes

Attribute / elementValuesDescription
.segmentedThe group. Inline, with a neutral track and a raised selected option.
> label > input[type=radio]One option. The radio is invisible and fills the label. Share a name in the group.
> label > spanThe visible text. An .icon may go before it.
data-sizesm24px tall. The default is 28px.
disabledon an inputDims the option and blocks it.

Events

No Tsunami event: it is a native form control, so the save bar and form code see it as usual.

NameValuesDescription
changenativeFires from the radio that became checked, and bubbles. Read event.target.value.

Accessibility

  • Arrow keys move and select inside the group; Tab enters and leaves it. This is native radio behaviour.
  • The focus ring is drawn on the focused option.
  • Name the group with aria-label or a visible label.
  • Use two to four short options. For more, use a select.