Skip to content

Tabs

A tab navigation component for switching between different views.

Basic Usage

vue
<script setup>
import { ref } from 'vue'

const activeTab = ref('tab1')
const tabs = [
  { label: 'Tab 1', value: 'tab1' },
  { label: 'Tab 2', value: 'tab2' },
  { label: 'Tab 3', value: 'tab3' }
]
</script>

<template>
  <MTabs v-model="activeTab" :tabs="tabs" />
</template>

Block Style

Fill the container width:

vue
<template>
  <MTabs v-model="activeTab" :tabs="tabs" block />
</template>

With Badges

vue
<script setup>
const tabs = [
  { label: 'Messages', value: 'messages', badge: 5 },
  { label: 'Notifications', value: 'notifications', badge: 12 },
  { label: 'Settings', value: 'settings' }
]
</script>

<template>
  <MTabs v-model="activeTab" :tabs="tabs" />
</template>

Disabled Tabs

vue
<script setup>
const tabs = [
  { label: 'Active', value: 'active' },
  { label: 'Disabled', value: 'disabled', disabled: true },
  { label: 'Another', value: 'another' }
]
</script>

<template>
  <MTabs v-model="activeTab" :tabs="tabs" />
</template>

Custom Tab Content

vue
<template>
  <MTabs v-model="activeTab" :tabs="tabs">
    <template #tab-messages="{ tab }">
      📧 {{ tab.label }}
    </template>
  </MTabs>
</template>

Props

NameTypeDefaultDescription
modelValuestring-Currently active tab value (v-model)
tabsTab[][]Tab configuration array
blockbooleanfalseFill container width

Tab Configuration

NameTypeDescription
labelstringTab label text
valuestringUnique tab value
disabledbooleanWhether the tab is disabled
badgenumber | stringBadge content

Events

NameParametersDescription
update:modelValue(value: string)Triggered when active tab changes
change(value: string)Triggered when active tab changes

Slots

NameScopeDescription
tab-[value]{ tab }Custom content for specific tab

Released under the MIT License.