Skip to content

Segmented ​

A single-select linear segmented control for light filtering / view switching, role="radiogroup", with per-item disabling. The selection indicator slides between items.

Basic usage ​

Basic usage

Default selection ​

Controlled value

Disabled items ​

Disabled options

Sizes ​

size supports small / medium (default) / large, aligned with the input control size system (also follows the config-provider size injection):

Sizes

Block ​

block stretches to the parent width with evenly divided items:

block

Icon options ​

An option's icon field (oas-icons name) renders before the text; omitting label gives the icon-only form, where the icon name is converted to readable text as the aria-label fallback:

Icon options

Icon only

Vertical ​

direction="vertical" stacks items vertically (side toolbars and similar); keyboard navigation switches to ↑ / ↓ accordingly:

Vertical

Read-only ​

readonly keeps the control focusable but the value cannot change (distinct form semantics from disabled):

readonly

Custom option rendering ​

template[slot="option"] is cloned into each option (the element with data-option-label binds the option text, aligned with the select option slot convention):

option slot

Keyboard & accessibility ​

Built on a hidden native radio group (input[type="radio"] grouped by name): Tab focuses the current selection, ← / → (vertical: ↑ / ↓) cycle through items skipping disabled ones, Home / End jump to the first / last item; focus (roving tabindex) follows the selection. Setting name names the inner radio group (an internal group name is generated when unset, so instances never interfere) — the component is not form-associated, so the radios in its shadow are not collected/submitted by an outer form; name is used only for intra-group exclusivity and keyboard semantics.

Switch event ​

oas-change event

Currently selected: chart

API ​

oas-segmented ​

Attributes ​

AttributeDescriptionTypeDefault
blockFill the parent width (options share equally)——
directionOrientation: horizontal (default) / vertical (mirrors aria-orientation and axis keys)stringhorizontal
disabledDisables the whole segmented control (explicitly, or inherited from the config-provider global disabled injection)boolean—
nameInner native radio group name (auto-generated unique name when unset, so instances do not clash); used only for intra-group exclusivity and keyboard semantics — the component is not form-associated, so the radios in its shadow are not collected/submitted by an outer formstring—
options[{ label, value, disabled? }] JSON stringstring[]
readonlyRead-only: focusable but selection immutable (radiogroup aria-readonly)boolean—
sizeSize preset small / medium (default) / largestringmedium
valueSelected value (defaults to the first option; controlled)string—

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
valueCurrent value: the selected option value stringstring—

Events ​

EventDescription
oas-changeSwitched, detail: { value }

Slots ​

NameDescription
template[slot="option"]Custom option template (<template slot="option">)

The container is role="radiogroup"; each item is backed by a native <input type="radio"> (the label itself has no role / aria-checked; checked state and accessible name come from the inner native radio, while the aria-disabled state attribute is kept).

Released under the MIT OR Apache-2.0 License.