KANTO DS v1.12.0
Customise

Theme

Accent

Font

Corners

Density

Text size

Reset to Kanto
Navigation

kt-segmented-control

GitHub Copy link

A small set of mutually exclusive choices, drawn as one inset track with the selected segment raised out of it.

Preview

A small set of mutually exclusive choices, drawn as one inset track with the selected segment raised out of it.

control.options = [ { value: 'day', label: 'Day' }, { value: 'week', label: 'Week' }, { value: 'month', label: 'Month' }, ]; control.value = 'week'; control.addEventListener('kt-change', (e) => setRange(e.detail.value));

Two to five options that all fit on screen — a view switch, a date range. Past that, <kt-select>.

Keyboard

It is a radio group, so the whole control is one tab stop and the arrows move between segments — a five-option control does not add five stops to the page.

KeyDoes
← / →Previous / next segment, and selects it
↑ / ↓ (vertical)Same, along the other axis
Home / EndFirst / last segment

Arrows both move and select, which is standard radio-group behaviour. Disabled segments are skipped, and the selection wraps at the ends.

In a form

It is a form control: inside a <form> it submits the chosen value under name, required blocks submission until a segment is chosen, and form.reset() puts back the initial value. Use it for a choice the form sends — a billing period, a plan — as readily as for a view switch.

API

PropertyAttributeTypeDefault
options—KtSegmentedOption[][]
valuevaluestring | number | nullnull
sizesize'small' | 'medium' | 'large''medium'
orientationorientation'horizontal' | 'vertical''horizontal'
disableddisabledbooleanfalse
labellabelstring''
namenamestring''
requiredrequiredbooleanfalse
interface KtSegmentedOption { value: string | number; label?: string; // omit with an icon for an icon-only segment icon?: string; disabled?: boolean; }
EventDetail
kt-change{ value, option } — not fired when the active segment is re-selected
PartDescription
baseThe track
optionA segment