Related views
Switch between a project overview, activity, and team information in one place.
Components / Navigation
Switch related views while keeping each panel mounted.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add tabsImport the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.
<script setup lang="ts">
import { ref } from 'vue'
import Tabs from './components/ui/tabs/Tabs.vue'
import TabsContent from './components/ui/tabs/TabsContent.vue'
import TabsList from './components/ui/tabs/TabsList.vue'
import TabsTrigger from './components/ui/tabs/TabsTrigger.vue'
const view = ref('overview')
</script>
<template>
<Tabs v-model="view" label="Workspace views">
<TabsList>
<TabsTrigger value="overview">
<template #icon>
<svg aria-hidden="true" viewBox="0 0 16 16">
<path d="M2 2h5v5H2zm7 0h5v5H9zM2 9h5v5H2zm7 0h5v5H9z" fill="currentColor" />
</svg>
</template>
Overview
</TabsTrigger>
<TabsTrigger value="activity">Activity</TabsTrigger>
</TabsList>
<TabsContent value="overview">Overview content</TabsContent>
<TabsContent value="activity">Activity content</TabsContent>
</Tabs>
</template>Arrow keys move between tabs. Manual activation selects with Enter or Space.
Switch between a project overview, activity, and team information in one place.
Use manual activation when changing a tab starts costly work.
Connect each trigger value to exactly one panel.
<script setup lang="ts">
import { ref } from 'vue'
import Tabs from './components/ui/tabs/Tabs.vue'
import TabsContent from './components/ui/tabs/TabsContent.vue'
import TabsList from './components/ui/tabs/TabsList.vue'
import TabsTrigger from './components/ui/tabs/TabsTrigger.vue'
const view = ref('overview')
</script>
<template>
<Tabs v-model="view" label="Project views">
<TabsList>
<TabsTrigger value="overview">Overview</TabsTrigger>
<TabsTrigger value="activity">Activity</TabsTrigger>
</TabsList>
<TabsContent value="overview"><p>Project summary</p></TabsContent>
<TabsContent value="activity"><p>Recent changes</p></TabsContent>
</Tabs>
</template>Arrow keys move focus; Enter or Space selects the focused tab.
<script setup lang="ts">
import Tabs from './components/ui/tabs/Tabs.vue'
import TabsContent from './components/ui/tabs/TabsContent.vue'
import TabsList from './components/ui/tabs/TabsList.vue'
import TabsTrigger from './components/ui/tabs/TabsTrigger.vue'
</script>
<template>
<Tabs label="Report views" activation="manual" orientation="vertical">
<TabsList>
<TabsTrigger value="chart">Chart</TabsTrigger>
<TabsTrigger value="data">Data</TabsTrigger>
</TabsList>
<TabsContent value="chart">Chart preview</TabsContent>
<TabsContent value="data">Data summary</TabsContent>
</Tabs>
</template>Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
itemsprop | readonly TabItem[] | undefined | Not set | Data items displayed by this component. |
labelprop | string | undefined | Not set | Visible or accessible name for this item. |
orientationprop | "horizontal" | "vertical" | undefined | "horizontal" | Arrange items horizontally or vertically. |
activationprop | "automatic" | "manual" | undefined | "automatic" | Choose how the action is activated. |
modelValuemodel | string | undefined | Not set | Current value. Use v-model to keep it in sync with your page. |
update:modelValueevent | [value: string | undefined] | — | Requests a new model value from the parent. |
triggerslot | { item: TabItem; active: boolean; } | Optional | Content for the trigger area of Tabs. |
defaultslot | { item: TabItem; active: boolean; } | Optional | Content shown inside Tabs. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
valueprop | string | Required | Value represented by this control or option. |
defaultslot | {} | Optional | Content shown inside TabsContent. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
defaultslot | {} | Optional | Content shown inside TabsList. |
| Name | Type or signature | Default | What it does |
|---|---|---|---|
valueprop | string | Required | Value represented by this control or option. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
defaultslot | () => unknown | Required | Content shown inside TabsTrigger. |
iconslot | (() => unknown) | undefined | Optional | Content for the icon area of TabsTrigger. |
// packages/frameworks/vue/components/tabs/types.ts
// ------- TYPES -------
export interface TabItem {
value: string
label: string
disabled?: boolean
}
export interface TabsProps {
items?: readonly TabItem[]
label?: string
orientation?: 'horizontal' | 'vertical'
activation?: 'automatic' | 'manual'
}