Skip to content

Tabs Components

Based on:

Demo

Tab Panel 1
Code
vue
<template>
  <div class="d-demo">
    <TabContainer v-model="currentTab">
      <TabList class="d-tab-list">
        <Tab v-for="(tab, i) in Object.keys(tabs)" :value="i" class="d-tab">
          {{ tab }}
        </Tab>
      </TabList>

      <TabPanel
        v-for="(tab, i) in Object.values(tabs)"
        :value="i"
        class="d-tab-panel"
      >
        {{ tab }}
      </TabPanel>
    </TabContainer>
  </div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { TabContainer, TabList, Tab, TabPanel } from "../../../src/main";

const tabs = {
  "Tab 1": "Tab Panel 1",
  "Tab 2": "Tab Panel 2",
  "Tab 3": "Tab Panel 3",
};

const currentTab = ref(0);
</script>

TabContainer

The root component.

Properties

PropertyRequiredDescriptionTypeDefault
modelValuefalseThe selected value.string | numberundefined

TabList

Properties

PropertyRequiredDescriptionTypeDefault
orientationfalseThe orientation of tabs. Affects keyboard navigation.'horizontal' | 'vertical''horizontal'

Keyboard interactions

  • Down Arrow - Moves focus to the next tab (vertical orientation).
  • Right Arrow - Moves focus to the next tab (horizontal orientation).
  • Up Arrow - Moves focus to the previous tab (vertical orientation).
  • Left Arrow - Moves focus to the previous tab (horizontal orientation).
  • Home - Moves focus to the first tab.
  • End - Moves focus to the last tab.

ARIA roles and attributes

The tab container has the tablist role and automatically manages the following attributes:

Tab

Properties

PropertyRequiredDescriptionTypeDefault
valuetrueThe value assigned to the tab.string | numberundefined
idfalseThe ID of the tab.stringauto-generated
aria-controlsfalseThe ID of the controlled tab panel.stringauto-generated

ARIA roles and attributes

Tabs are assigned the tab role.

The following attributes are automatically managed:

TabPanel

Properties

PropertyRequiredDescriptionTypeDefault
valuetrueThe value assinged to the panel. Must match to a tab's value.string | numberundefined

ARIA roles and attributes

The tab panel has the tablist role and automatically manages the following attributes: