Keyboard shortcut: Ctrl + K
Get started

Tabs

VTabs selects a tab and optionally displays its panel. It also supports a tab bar without panels.

Usage

vue
What the project is for.
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabPanel, VTabs } from 'vectis-ui'

const tab = ref('overview')
</script>

<template>
  <VTabs v-model="tab" label="Project">
    <VTab value="overview" label="Overview" />
    <VTab value="activity" label="Activity" />
    <template #panels>
      <VTabPanel value="overview">What the project is for.</VTabPanel>
      <VTabPanel value="activity">What has happened lately.</VTabPanel>
    </template>
  </VTabs>
</template>

Examples

Variants and tones

flat underlines the selected tab. outline, elevated and filled add a frame with a border, a shadow or a muted surface, and inset uses a recessed track. tone colours the selection.

vue

flat

outline

elevated

filled

inset

accent

neutral

danger

<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs, type TabsTone, type TabsVariant } from 'vectis-ui'

const variants: TabsVariant[] = ['flat', 'outline', 'elevated', 'filled', 'inset']
const tones: TabsTone[] = ['accent', 'neutral', 'danger']

const selectedByVariant = ref<Record<string, string>>({
  flat: 'overview',
  outline: 'overview',
  elevated: 'overview',
  filled: 'overview',
  inset: 'overview',
})
const selectedByTone = ref<Record<string, string>>({
  accent: 'overview',
  neutral: 'overview',
  danger: 'overview',
})
</script>

<template>
  <div class="demo">
    <div v-for="value in variants" :key="value" class="row">
      <p class="caption">{{ value }}</p>
      <VTabs v-model="selectedByVariant[value]" :variant="value" :label="`Project, ${value}`">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
        <VTab value="settings" label="Settings" />
      </VTabs>
    </div>

    <div v-for="value in tones" :key="value" class="row">
      <p class="caption">{{ value }}</p>
      <VTabs v-model="selectedByTone[value]" :tone="value" :label="`Project, ${value}`">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
        <VTab value="settings" label="Settings" />
      </VTabs>
    </div>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
}
.row {
  display: grid;
  gap: var(--vectis-space-2);
}
.caption {
  margin: 0;
  color: var(--vectis-color-text-muted);
  font-size: var(--vectis-text-caption-size);
}
</style>

Sizes

Set size on the group.

vue

xs

sm

md

lg

xl

<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs, type TabsSize } from 'vectis-ui'

const sizes: TabsSize[] = ['xs', 'sm', 'md', 'lg', 'xl']
const selected = ref<Record<string, string>>({
  xs: 'overview',
  sm: 'overview',
  md: 'overview',
  lg: 'overview',
  xl: 'overview',
})
</script>

<template>
  <div class="demo">
    <div v-for="size in sizes" :key="size" class="row">
      <p class="caption">{{ size }}</p>
      <VTabs v-model="selected[size]" :size="size" :label="`Project, ${size}`">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
      </VTabs>
    </div>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: grid;
  gap: var(--vectis-space-2);
}
.caption {
  margin: 0;
  color: var(--vectis-color-text-muted);
  font-size: var(--vectis-text-caption-size);
}
</style>

What a tab holds

Use labels, icons or slots. Give icon-only tabs a label for their accessible name.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VBadge, VTab, VTabs } from 'vectis-ui'
import { description, notifications, schedule, search } from 'vectis-ui/icons'

const tab = ref('files')
</script>

<template>
  <VTabs v-model="tab" label="Workspace">
    <VTab value="files" label="Files" :icon-start="description" />
    <VTab value="recent" label="Recent" :icon-start="schedule" />

    <VTab value="search" :icon-start="search" aria-label="Search" />

    <VTab value="alerts">
      <VBadge :count="3">Alerts</VBadge>
    </VTab>
    <VTab value="muted" label="Muted" :icon-end="notifications" />
  </VTabs>
</template>

Panels

Provide one matching panel per tab in panels, or omit this slot from the start. Hidden panels retain their state and form values. lazy delays mounting until the first opening.

vue
What the project is for.
<script setup lang="ts">
import { ref } from 'vue'
import { VInput, VTab, VTabPanel, VTabs } from 'vectis-ui'

const withPanels = ref('overview')
const bare = ref('day')
</script>

<template>
  <div class="demo">
    <VTabs v-model="withPanels" label="Project">
      <VTab value="overview" label="Overview" />
      <VTab value="details" label="Details" />
      <VTab value="history" label="History" />
      <template #panels>
        <VTabPanel value="overview">What the project is for.</VTabPanel>
        <VTabPanel value="details">
          <VInput label="Reference" model-value="INV-2481" />
          <p class="note">Type here, switch tab and come back: the value is still there.</p>
        </VTabPanel>
        <VTabPanel value="history" lazy>Built the first time this tab is opened.</VTabPanel>
      </template>
    </VTabs>

    <VTabs v-model="bare" variant="inset" label="Range">
      <VTab value="day" label="Day" />
      <VTab value="week" label="Week" />
      <VTab value="month" label="Month" />
    </VTabs>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
}
.note {
  margin: var(--vectis-space-3) 0 0;
  color: var(--vectis-color-text-muted);
  font-size: var(--vectis-text-caption-size);
}
</style>

Alignment

align positions tabs when they do not fill the bar.

vue

start

center

end

<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs, type TabsAlign } from 'vectis-ui'

const aligns: TabsAlign[] = ['start', 'center', 'end']
const selected = ref<Record<string, string>>({
  start: 'overview',
  center: 'overview',
  end: 'overview',
})
</script>

<template>
  <div class="demo">
    <div v-for="align in aligns" :key="align" class="row">
      <p class="caption">{{ align }}</p>
      <VTabs v-model="selected[align]" :align="align" :label="`Project, ${align}`">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
        <VTab value="settings" label="Settings" />
      </VTabs>
    </div>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-5);
}
.row {
  display: grid;
  gap: var(--vectis-space-2);
}
.caption {
  margin: 0;
  color: var(--vectis-color-text-muted);
  font-size: var(--vectis-text-caption-size);
}
</style>

Filling the bar

fullWidth gives tabs equal shares of the bar. Long labels truncate; scrolling is disabled.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs } from 'vectis-ui'

const tab = ref('day')
const wide = ref('overview')
</script>

<template>
  <div class="demo">
    <VTabs v-model="tab" variant="inset" full-width label="Range">
      <VTab value="day" label="Day" />
      <VTab value="week" label="Week" />
      <VTab value="month" label="Month" />
    </VTabs>

    <VTabs v-model="wide" full-width label="Project">
      <VTab value="overview" label="Overview" />
      <VTab value="activity" label="Activity and recent changes" />
      <VTab value="settings" label="Settings" />
    </VTabs>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
  max-inline-size: 28rem;
}
</style>

Orientation

Vertical tabs appear beside their panels. Arrow key navigation follows the orientation.

vue
What the project is for.
What the project is for.
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabPanel, VTabs } from 'vectis-ui'

const flat = ref('overview')
const framed = ref('overview')
</script>

<template>
  <div class="demo">
    <VTabs v-model="flat" orientation="vertical" label="Project">
      <VTab value="overview" label="Overview" />
      <VTab value="activity" label="Activity" />
      <VTab value="settings" label="Settings" />
      <template #panels>
        <VTabPanel value="overview">What the project is for.</VTabPanel>
        <VTabPanel value="activity">What has happened lately.</VTabPanel>
        <VTabPanel value="settings">How it is configured.</VTabPanel>
      </template>
    </VTabs>

    <VTabs v-model="framed" orientation="vertical" variant="outline" label="Project, framed">
      <VTab value="overview" label="Overview" />
      <VTab value="activity" label="Activity" />
      <VTab value="settings" label="Settings" />
      <template #panels>
        <VTabPanel value="overview">What the project is for.</VTabPanel>
        <VTabPanel value="activity">What has happened lately.</VTabPanel>
        <VTabPanel value="settings">How it is configured.</VTabPanel>
      </template>
    </VTabs>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
}
</style>

Scrolling

Overflowing tabs scroll by touch, trackpad or keyboard. Let the parent shrink with a zero minimum size.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs } from 'vectis-ui'

const cities = ['Paris', 'Lisbon', 'Berlin', 'Madrid', 'Rome', 'Vienna', 'Prague', 'Oslo']
const tab = ref('Paris')
</script>

<template>
  <div class="narrow">
    <VTabs v-model="tab" label="Cities">
      <VTab v-for="city in cities" :key="city" :value="city" :label="city" />
    </VTabs>
  </div>
</template>

<style scoped>
.narrow {
  /* Allow the container to shrink so the tab list can overflow. */
  min-inline-size: 0;
  max-inline-size: 26rem;
}
</style>

Scroll buttons

scrollButtons adds controls at each end. It cannot be combined with fullWidth.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs } from 'vectis-ui'

const cities = ['Paris', 'Lisbon', 'Berlin', 'Madrid', 'Rome', 'Vienna', 'Prague', 'Oslo']
const horizontal = ref('Paris')
const vertical = ref('Paris')
</script>

<template>
  <div class="demo">
    <div class="narrow">
      <VTabs v-model="horizontal" scroll-buttons label="Cities">
        <VTab v-for="city in cities" :key="city" :value="city" :label="city" />
      </VTabs>
    </div>

    <div class="short">
      <VTabs v-model="vertical" orientation="vertical" scroll-buttons label="Cities, vertical">
        <VTab v-for="city in cities" :key="city" :value="city" :label="city" />
      </VTabs>
    </div>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
}
.narrow {
  min-inline-size: 0;
  max-inline-size: 26rem;
}
.short {
  block-size: 14rem;
}
</style>

Custom arrows

Customize scroll icons and their accessible labels with prevIcon, nextIcon, prevLabel and nextLabel.

vue
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabs } from 'vectis-ui'
import { arrow_left_alt as arrowLeftAlt, arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'

const cities = ['Paris', 'Lisbon', 'Berlin', 'Madrid', 'Rome', 'Vienna', 'Prague', 'Oslo']
const tab = ref('Paris')
</script>

<template>
  <div class="narrow">
    <VTabs
      v-model="tab"
      scroll-buttons
      :prev-icon="arrowLeftAlt"
      :next-icon="arrowRightAlt"
      prev-label="Earlier cities"
      next-label="Later cities"
      label="Cities"
    >
      <VTab v-for="city in cities" :key="city" :value="city" :label="city" />
    </VTabs>
  </div>
</template>

<style scoped>
.narrow {
  min-inline-size: 0;
  max-inline-size: 26rem;
}
</style>

Selecting on arrival

Manual activation moves focus with arrows and selects with Enter or Space. Automatic activation selects on focus; use it when panels appear immediately.

vue

manual, the default

What the project is for.

automatic

What the project is for.
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabPanel, VTabs } from 'vectis-ui'

const manual = ref('overview')
const automatic = ref('overview')
</script>

<template>
  <div class="demo">
    <div class="row">
      <p class="caption">manual, the default</p>
      <VTabs v-model="manual" label="Project, manual">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
        <VTab value="settings" label="Settings" />
        <template #panels>
          <VTabPanel value="overview">What the project is for.</VTabPanel>
          <VTabPanel value="activity">What has happened lately.</VTabPanel>
          <VTabPanel value="settings">How it is configured.</VTabPanel>
        </template>
      </VTabs>
    </div>

    <!-- Focus a tab and press an arrow key. -->
    <div class="row">
      <p class="caption">automatic</p>
      <VTabs v-model="automatic" activation="automatic" label="Project, automatic">
        <VTab value="overview" label="Overview" />
        <VTab value="activity" label="Activity" />
        <VTab value="settings" label="Settings" />
        <template #panels>
          <VTabPanel value="overview">What the project is for.</VTabPanel>
          <VTabPanel value="activity">What has happened lately.</VTabPanel>
          <VTabPanel value="settings">How it is configured.</VTabPanel>
        </template>
      </VTabs>
    </div>
  </div>
</template>

<style scoped>
.demo {
  display: grid;
  gap: var(--vectis-space-6);
}
.row {
  display: grid;
  gap: var(--vectis-space-2);
}
.caption {
  margin: 0;
  color: var(--vectis-color-text-muted);
  font-size: var(--vectis-text-caption-size);
}
</style>

Disabled tabs

Disabled tabs are skipped. Keep the model on an enabled tab. Disabling the group leaves the current panel visible.

vue
What the project is for.
<script setup lang="ts">
import { ref } from 'vue'
import { VTab, VTabPanel, VTabs } from 'vectis-ui'

const tab = ref('overview')
</script>

<template>
  <VTabs v-model="tab" label="Project">
    <VTab value="overview" label="Overview" />
    <VTab value="activity" label="Activity" disabled />
    <VTab value="settings" label="Settings" />
    <template #panels>
      <VTabPanel value="overview">What the project is for.</VTabPanel>
      <VTabPanel value="activity">Never reached.</VTabPanel>
      <VTabPanel value="settings">How it is configured.</VTabPanel>
    </template>
  </VTabs>
</template>

API

Props

VTabs
PropTypeDefault
variantTabsVariant'flat' | 'outline' | 'elevated' | 'filled' | 'inset''flat'
Tab bar style: underlined, framed by a border, a shadow or a muted fill, or inset.
toneTabsTone'accent' | 'neutral' | 'danger''accent'
Colour of the selected tab.
sizeTabsSize'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
Component size.
orientationTabsOrientation'horizontal' | 'vertical''horizontal'
Horizontal or vertical tab navigation.
alignTabsAlign'start' | 'center' | 'end''start'
Tab alignment when the bar is not full.
fullWidthbooleanfalse
Distributes tabs equally across the bar.
scrollButtonsbooleanfalse
Adds scroll controls. Incompatible with fullWidth.
prevIconIconSourcenone
Backward scroll icon. Defaults to the orientation’s arrow.
nextIconIconSourcenone
Forward scroll icon. Defaults to the orientation’s arrow.
prevLabelstringnone
Accessible backward scroll label. Defaults to the dictionary.
nextLabelstringnone
Accessible forward scroll label. Defaults to the dictionary.
activationTabsActivation'manual' | 'automatic''manual'
Manual selection with Enter/Space, or automatic selection on focus.
disabledbooleanfalse
Disables all tabs and scroll controls; keeps the current panel visible.
labelstringnone
Accessible name of the tab list. Defaults to the dictionary.
v-modelItemValuenone
Selected tab value. Must refer to an existing, enabled tab for keyboard access.
VTab
PropTypeDefault
valueItemValuenone
Tab identifier matching its panel and the model value.
labelstringnone
Visible label, replaced by the default slot. Also names icon-only tabs.
iconStartIconSourcenone
Icon before the label.
iconEndIconSourcenone
Icon after the label.
iconFilledbooleanfalse
Uses filled icons when supported.
disabledbooleanfalse
Disables this tab; group disabling also applies.
VTabPanel
PropTypeDefault
valueItemValuenone
Identifier of the tab displaying this panel.
lazybooleanfalse
Mounts content on first opening, then preserves it.

Slots

VTabs
SlotType
default{}
VTab children.
panels{}
Matching VTabPanel children. Omit for a bar without panels.
VTab
SlotType
default{}
Content replacing the label.
start{}
Content replacing iconStart.
end{}
Content replacing iconEnd.
VTabPanel
SlotType
default{}
Panel content.

Types

Types used in the API tables. Import exported types from vectis-ui.

export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender
export type ItemValue = string | number

CSS variables

TokenValue
--vectis-control-size-tab-indicator2px