Tabs
A set of layered sections of content, one visible at a time.
A tab list with associated panels. Follows the WAI-ARIA Tabs pattern with roving tabindex, keyboard arrow navigation, and an animated sliding indicator.
Anatomy
#tab: Content rendered inside each tab button. Defaults to the item label.#panel-{value}: Content panel for each tab, named by the itemvalue.
The tab button itself is rendered by the component; use the ui.tab prop to add classes to it. The tab list also renders an akaza-tab-indicator span that you can style for a sliding underline or pill effect.
Usage
Account settings
Manage your name, email, and profile picture.
Examples
Custom tab button
Use #tab to style each tab button and react to the active state.
<template>
<Tabs
:items="tabs"
v-model="active"
>
<template #tab="{ item, isActive }">
<span :class="['tab', { 'tab--active': isActive }]">
{{ item.label }}
</span>
</template>
<template #panel-account>Account content.</template>
<template #panel-security>Security content.</template>
</Tabs>
</template>
Pill-style tabs
Apply background styles to the tab list and use the indicator for a sliding pill.
<Button class="rounded-md bg-black px-3 py-2 text-white">
Save
</Button>
Manual activation mode
Arrow keys only move focus; the user must press Space or Enter to activate a tab.
<script setup lang="ts">
import { ref } from 'vue'
import { Dialog } from 'akaza-ui'
const dialog = ref()
function showConfirmation() {
dialog.value?.open()
}
</script>
<template>
<Dialog ref="dialog">
<template #body>Are you sure?</template>
<template #footer="{ close }">
<button @click="close">Dismiss</button>
</template>
</Dialog>
<button @click="showConfirmation">Show confirmation</button>
</template>
Vertical orientation
Use vertical orientation when tab labels should sit beside the active panel.
<script setup lang="ts">
import { ref } from 'vue'
import { Tabs } from 'akaza-ui'
const active = ref('account')
const items = [
{ value: 'account', label: 'Account' },
{ value: 'security', label: 'Security' },
]
</script>
<template>
<Tabs v-model="active" :items="items" aria-label="Settings">
<template #panel-account>Account settings…</template>
<template #panel-security>Security settings…</template>
</Tabs>
</template>
Unmount inactive panels
Remove inactive panels from the DOM instead of hiding them.
<Accordion
:items="items"
@value-change="(value, details) => {
if (details.reason === 'trigger') console.log('opened:', value)
}"
/>
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | TabsItem[] | — | Required. List of tab items. |
modelValue | string | "" | Currently active tab value. |
orientation | "horizontal" | "vertical" | "horizontal" | Tab list direction. |
activationMode | "automatic" | "manual" | "automatic" | automatic: arrow keys activate. manual: arrow keys move focus only. |
unmountOnHide | boolean | false | Use v-if instead of v-show for inactive panels. |
ariaLabel | string | — | aria-label for the tab list. |
labelKey | string | "label" | Property to use as label when items are objects. |
ui | TabsUi | — | CSS class overrides. |
TabsItem
| Key | Type | Description |
|---|---|---|
value | string | Required. Unique identifier and panel slot suffix. |
label | string | Display label (used by the default #tab slot). |
disabled | boolean | Disables this tab. |
Slots
| Slot | Scoped props | Description |
|---|---|---|
tab | { item, isActive, select } | Each tab button. Defaults to rendering the item's label. |
panel-{value} | { item, isActive } | Content panel for the tab with the matching value. |
Emits
| Event | Payload | Description |
|---|---|---|
value-change | [value: string, details] | Fired when selected tab changes. |
UI Options
| Key | Description |
|---|---|
root | The outer wrapper element. |
list | The tab list element. |
tab | Each tab button element. |
indicator | The sliding indicator span. |
panels | The panels wrapper element. |
panel | Each panel element. |
Styling Hooks
| UI key | CSS class | Data attrs |
|---|---|---|
root | akaza-tabs | data-akaza-orientation |
list | akaza-tab-list | — |
tab | akaza-tab | data-akaza-state, data-akaza-value, data-akaza-disabled |
indicator | akaza-tab-indicator | — |
panels | akaza-tab-panels | — |
panel | akaza-tab-panel | data-akaza-state |
Keyboard
| Key | Behavior |
|---|---|
ArrowLeft / ArrowRight | Moves through enabled horizontal tabs and loops. |
ArrowUp / ArrowDown | Moves through enabled vertical tabs and loops. |
Home / End | Focuses first or last enabled tab. |
Enter / Space | Activates focused tab. Required in manual activation mode. |
Tab | Moves from active tab into active panel or next focusable control. |
Automatic mode activates during arrow movement. Manual mode moves focus only until activation.