Vitral 0.2
Panel

Tabs

Views that share one place on the page, switched by a list of tabs.

Import

main.ts
import { Tabs } from '@vitral/vue';

Basic

Files you opened in the last week.

value: recent
<script setup lang="ts">import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@vitral/vue';import { ref } from 'vue'; const tab = ref<string | number>('recent');const views = [    { value: 'recent', label: 'Recent', body: 'Files you opened in the last week.' },    { value: 'shared', label: 'Shared with me', body: 'Files other people gave you access to.' },    { value: 'favorites', label: 'Favorites', body: 'Files you starred.' },    { value: 'trash', label: 'Recycle bin', body: 'Deleted files, kept for 30 days.', disabled: true }];</script> <template>    <Tabs v-model:value="tab" style="width: 100%">        <TabList aria-label="Files">            <Tab v-for="v in views" :key="v.value" :value="v.value" :disabled="v.disabled">{{ v.label }}</Tab>        </TabList>        <TabPanels>            <TabPanel v-for="v in views" :key="v.value" :value="v.value">                <p style="margin: 0">{{ v.body }}</p>            </TabPanel>        </TabPanels>    </Tabs>    <small style="color: var(--vt-text-muted-color)">value: {{ tab }}</small></template>

Vertical

Name, email and password.

<script setup lang="ts">import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@vitral/vue';import { ref } from 'vue'; const vertical = ref<string | number>(0);</script> <template>    <Tabs v-model:value="vertical" orientation="vertical" style="width: 100%">        <TabList aria-label="Settings">            <Tab :value="0">Account</Tab>            <Tab :value="1">Notifications</Tab>            <Tab :value="2">Billing</Tab>        </TabList>        <TabPanels>            <TabPanel :value="0"><p style="margin: 0">Name, email and password.</p></TabPanel>            <TabPanel :value="1"><p style="margin: 0">What to be told about, and where.</p></TabPanel>            <TabPanel :value="2"><p style="margin: 0">Plan, invoices and payment method.</p></TabPanel>        </TabPanels>    </Tabs></template>

Manual activation

With `select-on-focus` off, the arrows only move focus; Enter or Space selects.

Rendered only while selected (`lazy`).

<script setup lang="ts">import { Tab, TabList, TabPanel, TabPanels, Tabs } from '@vitral/vue';</script> <template>    <Tabs value="a" :select-on-focus="false" lazy>        <TabList aria-label="Manual">            <Tab value="a">Overview</Tab>            <Tab value="b">Activity</Tab>            <Tab value="c">Members</Tab>        </TabList>        <TabPanels>            <TabPanel value="a"><p style="margin: 0">Rendered only while selected (`lazy`).</p></TabPanel>            <TabPanel value="b"><p style="margin: 0">Recent activity.</p></TabPanel>            <TabPanel value="c"><p style="margin: 0">Who is in the project.</p></TabPanel>        </TabPanels>    </Tabs></template>

API

Read from packages/vue/src/components/Tabs/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
orientation'horizontal' | 'vertical'Tabs above the panels (the default) or beside them.
lazybooleanRender a panel only while its tab is selected.
selectOnFocusbooleanSelect a tab as soon as the arrow keys reach it: the APG's automatic activation, and the default. Off, the arrows only move focus and Enter/Space select.

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Slots

NameSlot propsDescription
default——