WlSegmented
Segmented control with one selection from options.
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Disables the entire control.
Fill the available inline width.
Props options, pt, size, density, orientation, models, handlers and slots can be edited in the SFC. See their descriptions in API.
Example
Focus: outside the example · pointer: outside the example
Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.
Code for your application
Vue SFC · current settings
<script setup lang="ts">
import { WlSegmented } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<"list" | "grid" | "archive" | null>("list");
const options = computed(() => [
{ label: "List", value: "list" as const },
{ label: "Grid", value: "grid" as const },
{ label: "Archive", value: "archive" as const, disabled: true }
]);
</script>
<template>
<div class="wl-stack" data-space="md">
<WlSegmented
v-model="selected"
size="sm"
block
:options="options"
aria-label="View"
/>
</div>
</template>Period, icons and disabled
Controlled selection, an unavailable option, icon options and a fully disabled group.
Period: Week. View: List.
Vue SFC · additional 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>