Files
nuxt__ui/docs/app/components/content/examples/tabs/TabsRouteQueryExample.vue
Sabih Sarowar cbc9f8d66c docs(tabs): improve model value examples (#5722)
Co-authored-by: Benjamin Canac <canacb1@gmail.com>
2026-01-19 16:00:16 +01:00

38 lines
725 B
Vue

<script setup lang="ts">
import type { TabsItem } from '@nuxt/ui'
const route = useRoute()
const router = useRouter()
const items: TabsItem[] = [
{
label: 'Account',
icon: 'i-lucide-user',
value: 'account'
},
{
label: 'Password',
icon: 'i-lucide-lock',
value: 'password'
}
]
const active = computed({
get() {
return (route.query.tab as string) || 'account'
},
set(tab) {
// Hash is specified here to prevent the page from scrolling to the top
router.push({
path: '/docs/components/tabs',
query: { tab },
hash: '#with-route-query'
})
}
})
</script>
<template>
<UTabs v-model="active" :content="false" :items="items" class="w-full" />
</template>