WlSegmented
Appearance
Full example
<div class="wl-stack" data-space="md">
<WlSegmented
v-model="selected"
size="sm"
block
:options="options"
aria-label="View"
/>
</div>Period, icons and disabled
Controlled selection, an unavailable option, icon options and a fully disabled group.
Period: Week. View: List.
Full example
<script setup lang="ts">
import { WlSegmented, type WlSegmentedOption } from "legato-ui";
import { ref } from "vue";
const period = ref<string | null>("week");
const view = ref<string | null>("list");
const periods: WlSegmentedOption[] = [{ label: "Day", value: "day" }, { label: "Week", value: "week" }, { label: "Month", value: "month" }, { label: "Year", value: "year", disabled: true }];
const views: WlSegmentedOption[] = [{ label: "List", value: "list", icon: "list" }, { label: "Grid", value: "grid", icon: "grid" }];
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlSegmented
v-model="period"
:options="periods"
aria-label="Planning period"
:pt="{ root: { style: { flexWrap: 'wrap', height: 'auto' } } }"
/>
<WlSegmented v-model="view" :options="views" aria-label="Materials view" />
<WlSegmented
model-value="list"
:options="views"
disabled
aria-label="Unavailable materials view"
/>
<p class="wl-text-small" role="status">
{{ "Period:" }} {{ periods.find(item => item.value === period)?.label }}{{ ". View:" }}
{{ views.find(item => item.value === view)?.label }}.
</p>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: Value |Selected option value (default null).
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
options | readonly WlSegmentedOption< | [] | WlSegmentedOption[] options: { label, value, icon?, disabled? }. |
disabled | boolean | false | Disables the entire control. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
size | WlSizeSm | "md" | Size within the component family's documented scale. |
density | WlDensity | "default" | Spacing density for this component family. |
block | boolean | false | Fill the available inline width. |
orientation | "horizontal" | | "horizontal" | Layout direction and applicable arrow-key navigation direction. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | Value | | Emitted when the component requests a model change; the payload is the next value. |
Slots
No public slots.
Pass-through: pt
Sections WlSegmented are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-segmented | The root section in WlConfig.pt.segmented configuration. |
item.root | button.wl-segmented__item | One repeated item. |
item.content | span.wl-segmented__item-content | Main content area. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Card, Accordion, Alert and Segmented expose component font-size, line-height, font-weight and font-family tokens. Defaults retain 1.0 typography. Import styles/primitives.css and add wl-type-scale to opt into semantic roles; the mapping table and live toggle are in Typography → Scale. Set local scale values on the same group, or override a component token on a closer element. Select and MultiSelect use the font size of each role. To scale a local dropdown, pass the class and role values through pt.overlay.
- Name the group through aria-label; each option's text remains the native button's accessible name.
- V-model stores value, while aria-pressed announces the selected option. Disabled works on both the group and individual options.
- Move between buttons with Tab and activate with Enter/Space; the component does not declare a tablist or implement tab arrow navigation.
Keyboard and application responsibilities
| Key | Action |
|---|---|
| Tab | Enter or leave the group through one active focus stop. |
| ← / → or ↑ / ↓ | Move in the configured orientation and skip disabled items. |
| Home / End | Focus the first or last enabled item. |
| Enter / Space | Activate the focused action. Tabs, radios and segmented choices select as documented. |
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.