WlTabs
Tabs with keyboard navigation. Each tab's content is supplied in the scoped panel slot.
Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.
Settings
Defer a tab panel's first render until it becomes active.
Keep a previously visited tab panel mounted while it is inactive.
Props items, pt, 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 { WlTabs } from "legato-ui";
import { useWlId } from "legato-ui/composables";
import { computed, ref } from "vue";
const active = ref("example-overview");
const prefix = `example-tabs-${useWlId()}`;
const items = computed(() => [
{ key: "example-overview", label: "Overview", href: `#${prefix}-example-overview` },
{ key: "example-history", label: "History", href: `#${prefix}-example-history`, count: 3 }
]);
</script>
<template>
<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>
</template>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.
Vue SFC · additional 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>