Vitral 0.2
Painel

Tabs

Vistas que dividem um mesmo lugar na página, trocadas por uma lista de abas.

Importação

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

Básico

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>

Ativação manual

Com `select-on-focus` desligado, as setas só movem o foco; Enter ou Espaço selecionam.

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

Lido de packages/vue/src/components/Tabs/types.ts, então diz o que o componente aceita de fato.

Props

NomeTipoDescrição
orientation'horizontal' | 'vertical'Abas acima dos painéis (o padrão) ou ao lado deles.
lazybooleanRenderiza um painel só enquanto sua aba está selecionada.
selectOnFocusbooleanSeleciona uma aba assim que as setas chegam nela: a ativação automática do APG, e o padrão. Desligado, as setas só movem o foco e Enter/Espaço selecionam.

Mais pt, dt e unstyled de BaseProps; veja pass-through e modo sem estilo.

Slots

NomeProps do slotDescrição
default——