Segmented
A single choice shown as a row of buttons.
MarkdownExamples
Basic
Icon only
The option labels become the buttons' names.
API
| Prop | Type | Default |
|---|---|---|
optionsSegments to render, in order. | SelectOption<T>[] | [] |
labelAccessible name for the group. | string | — |
sizeSize hook, exposed as | "medium" | "small" | "medium" |
iconOnlySegments render only the | boolean | false |
disabledDisables every segment. | boolean | false |
nameForm field name: submits the value with a native form, via hidden inputs. | string | — |
modelValueThe selected value. | T | — |
| Event | Payload |
|---|---|
update:modelValue
| [value: T | undefined] |
| Slot | Props |
|---|---|
optionSegment content, e.g. an icon. | { option: SelectOption<T>; checked: boolean; } |
Types
export interface SelectOption<T extends SelectValue = SelectValue> {
label: string;
value: T;
disabled?: boolean;
}
export type SelectValue = string | number;Copy codeStyling
--ui-indicator-x, --ui-indicator-width, --ui-indicator-top and --ui-indicator-height place the indicator on the selected item.
- Parts
segmentedsegmented-indicatorsegment- States
data-field-namedata-segmented-sizedata-segmented-icon-onlydata-segmented-slidingdata-segmented-animatedata-segment-checked
Keyboard
| Keys | Action |
|---|---|
Tab | Focus the selected segment |
| Arrow keys | Select the next / previous segment |
Home / End | Select the first / last segment |
Accessibility
- The indicator is measured in the browser, so also style
[data-segment-checked]for the first paint. - In right-to-left layouts,
←/→follow the visual direction.