Tabs
A compact segmented navigation component for switching between views.
Installation
npx alixan-ui-nuxt add tabsUsage
<script setup lang="ts">
import Tabs from '@/components/ui/tabs/Tabs.vue'
const tabs = ['Account', 'Password']
const selected = ref(0)
</script>
<template>
<div class="grid gap-4">
<Tabs v-model="selected" :tabs="tabs" design="cupertino" />
<Tabs v-model="selected" :tabs="tabs" design="material" />
</div>
</template>Full Width
<script setup lang="ts">
import Tabs from '@/components/ui/tabs/Tabs.vue'
</script>
<template>
<Tabs v-model="selected" :tabs="tabs" full />
</template>Swipeable tabs
Drag the tab row with touch or mouse, with momentum and automatic positioning of the selected tab. Buttons stay on one line at their content width. Swiping only moves the row; select a tab by clicking it. TabsSwiper has no full option and requires Swiper. Install the dependency before adding the component.
npm install swiper@^12.2.0npx alixan-ui-nuxt add tabs-swiperAll products
All products
<script setup lang="ts">
import TabsSwiper from '@/components/ui/tabs/TabsSwiper.vue'
const tabs = [
'componentDocs.tabs.demo.all',
'componentDocs.tabs.demo.active',
'componentDocs.tabs.demo.paused',
'componentDocs.tabs.demo.problems',
'componentDocs.tabs.demo.belowMinimum',
'componentDocs.tabs.demo.atMinimum',
'componentDocs.tabs.demo.favorites',
]
const counts = [128, 84, 16, 9, 7, 12, 18]
const selected = ref(0)
</script>
<template>
<TabsSwiper v-model="selected" :tabs="tabs" :counts="counts" design="material" />
<p>{{ $t(tabs[selected]) }}</p>
</template>API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | number | 0 | Selected tab index used by v-model. |
| tabs | string[] | [] | List of tab labels. |
| design | 'material' | 'cupertino' | 'cupertino' | Visual style of the tabs. |
| full | boolean | false | Makes the tabs container and every tab use full available width. |
TabsSwiper props
| Prop | Type | Default | Description |
|---|---|---|---|
| modelValue | number | 0 | Selected tab index used by v-model. |
| tabs | string[] | [] | List of tab labels. |
| design | 'material' | 'cupertino' | 'cupertino' | Visual style of the tabs. |
| counts | number[] | undefined | Optional counts displayed next to tab labels, in the same order as tabs. Zero values are shown. |