WlTabs
Placement
Full example
<div class="wl-stack" data-space="md">
<WlTabs v-model="active" :items="items" >
<template #panel="{ item }">
<p :id="`${prefix}-${item.key}`" class="wl-text-body">
{{ item.key === 'example-overview' ? "Material description." : "Material updated October 1." }}
</p>
</template>
</WlTabs>
</div>Behavior
Full example
<div class="wl-stack" data-space="md">
<WlTabs v-model="active" :items="items" >
<template #panel="{ item }">
<p :id="`${prefix}-${item.key}`" class="wl-text-body">
{{ item.key === 'example-overview' ? "Material description." : "Material updated October 1." }}
</p>
</template>
</WlTabs>
</div>Tabs with icons and panels
Controlled model, note count, scoped panel and keyboard section switching.
Overview
Drawer showcase-overview receives content from the scoped slot.
←/→, Home and End switch tabs.
Active tab: Overview.
Full example
<script setup lang="ts">
import { WlButton, type WlTabItem, WlTabs } from "legato-ui";
import { computed, ref } from "vue";
const active = ref("showcase-overview");
const count = ref(3);
const items = computed<WlTabItem[]>(() => [{ key: "showcase-overview", label: "Overview", icon: "file" }, { key: "showcase-notes", label: "Notes", icon: "edit", count: count.value }, { key: "showcase-history", label: "History", icon: "clock" }]);
</script>
<template>
<div class="wl-stack" data-space="lg">
<WlTabs v-model="active" :items="items" :pt="{ tabList: { 'aria-label': 'Material sections' } }">
<template #panel="{ item }">
<div class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ item.label }}</h3>
<p class="wl-text-body">
{{ "Drawer" }} {{ item.key }} {{ "receives content from the scoped slot." }}
</p>
<div v-if="item.key === 'showcase-notes'">
<WlButton size="sm" @click="count++">{{ "New note" }}</WlButton>
<p class="wl-text-small">{{ "Notes in the local example:" }} {{ count }}</p>
</div>
<p v-else class="wl-text-small wl-text-muted">
{{ item.key === 'showcase-history'
? "Today — documentation reviewed."
: "←/→, Home and End switch tabs." }}
</p>
</div>
</template>
</WlTabs>
<p class="wl-text-small" role="status">{{ "Active tab:" }} {{ items.find(item => item.key === active)?.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: Item["key"] |Active tab key; if empty, the first tab is selected (default "").
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
items | readonly Item[] | [] | WlTabItem[]: { key, label, icon?, count? }. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
orientation | "horizontal" | | "horizontal" | Layout direction and applicable arrow-key navigation direction. |
lazy | boolean | true | Defer a tab panel's first render until it becomes active. |
keepAlive | boolean | false | Keep a previously visited tab panel mounted while it is inactive. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | Item["key"] | | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
panel | panel?(props: { item: Item }): unknown; | Panel content; scope: { item }. |
Pass-through: pt
Sections WlTabs 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 |
|---|---|---|
content | div.wl-tabs__content | Main content area. |
tabList | div.wl-tabs__list | Container with the tablist role. |
activeBar | span.wl-tabs__active-bar | Decorative active-tab indicator. |
panels.root | div.wl-tabs__panels | Main element of the component. |
panel.root | div.wl-tabs__panel | Main element of the component. |
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
- Pass the tablist's aria-label through pt.tabList; each tab label explains its panel content.
- ArrowLeft/ArrowRight, Home and End select a tab and move focus together; the active tab is in the Tab order.
- Each key must be unique on the page: it contributes to panel id and aria-labelledby. Scoped panel contains content for the selected key.
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.