Skip to content

Segmented Control

Bar (text)

View

Toolbar — icons only

Tools

Bottom bar (mobile)

Sections

Vertical — compact (label under icon)

Sections

Vertical — icons only

Sections

The radio-group semantics laid out as a bar of segments: it chooses a value inside a view. Beyond the default text bar it supports iconOnly (a compact toolbar), stacked (icon over label) and orientation="vertical" (a column of segments). The demo above shows each variant.

A Segmented Control is not navigation. A radio group announces “radio button, 2 of 5, checked” and moves the selection with the arrow keys, which is the wrong contract for moving between the sections of an application. For a bar of sections at the bottom of the screen use Navigation Bar; for side navigation use Sidebar.

<script>
import SegmentedControl from "@invisible-ui/svelte/SegmentedControl.svelte";
</script>

In Elements, the segments come from <option> children, or from the items property. An option’s data-icon holds the path data of a 24×24 icon. The selection is reflected by the value attribute and reported through the bubbling change event:

<ds-segmented-control label="View" name="view" value="list">
<option value="list">List</option>
<option value="board">Board</option>
</ds-segmented-control>
PropTypeDefaultDescription
items *SegmentedControlItem[]—
valuestring | nullnull
disabledbooleanfalse
orientation"horizontal" | "vertical""horizontal"Layout direction.
iconOnlybooleanfalseIcon-only segments (each item needs an accessible label).
stackedbooleanfalseStack icon over label (iOS-style).
label *string—Accessible name for the control.
hideLabelbooleanfalseVisually hide the group label (kept for assistive tech).
namestring | undefinedundefinedForm field name — the selected value is submitted under it.
onValueChange((value: string) => void) | undefinedundefinedCalled whenever the selected value changes.
  • Built on native <input type="radio"> segments: the browser handles roving tabindex, arrow navigation and form participation.
  • The control needs an accessible name via label.
<SegmentedControl
label="View"
value="list"
items={[
{ value: "list", label: "List" },
{ value: "grid", label: "Grid" },
]}
onValueChange={(v) => (view = v)}
/>

In React, an item’s icon is any element:

<SegmentedControl
label="View"
value={view}
items={[
{ value: "list", label: "List", icon: <ListIcon /> },
{ value: "grid", label: "Grid", icon: <GridIcon /> },
]}
iconOnly
onValueChange={setView}
/>

Themeable via --ds-segment-*.