Skip to content

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 item value.

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

Examples

Custom tab button

Use #tab to style each tab button and react to the active state.

vue
<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.

vue
<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.

vue
<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.

vue
<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.

vue
<Accordion
  :items="items"
  @value-change="(value, details) => {
    if (details.reason === 'trigger') console.log('opened:', value)
  }"
/>

API Reference

Props

PropTypeDefaultDescription
itemsTabsItem[]—Required. List of tab items.
modelValuestring""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.
unmountOnHidebooleanfalseUse v-if instead of v-show for inactive panels.
ariaLabelstring—aria-label for the tab list.
labelKeystring"label"Property to use as label when items are objects.
uiTabsUi—CSS class overrides.

TabsItem

KeyTypeDescription
valuestringRequired. Unique identifier and panel slot suffix.
labelstringDisplay label (used by the default #tab slot).
disabledbooleanDisables this tab.

Slots

SlotScoped propsDescription
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

EventPayloadDescription
value-change[value: string, details]Fired when selected tab changes.

UI Options

KeyDescription
rootThe outer wrapper element.
listThe tab list element.
tabEach tab button element.
indicatorThe sliding indicator span.
panelsThe panels wrapper element.
panelEach panel element.

Styling Hooks

UI keyCSS classData attrs
rootakaza-tabsdata-akaza-orientation
listakaza-tab-list—
tabakaza-tabdata-akaza-state, data-akaza-value, data-akaza-disabled
indicatorakaza-tab-indicator—
panelsakaza-tab-panels—
panelakaza-tab-paneldata-akaza-state

Keyboard

KeyBehavior
ArrowLeft / ArrowRightMoves through enabled horizontal tabs and loops.
ArrowUp / ArrowDownMoves through enabled vertical tabs and loops.
Home / EndFocuses first or last enabled tab.
Enter / SpaceActivates focused tab. Required in manual activation mode.
TabMoves from active tab into active panel or next focusable control.

Automatic mode activates during arrow movement. Manual mode moves focus only until activation.

Edit this page on GitHub ↗