TabBar
Alpha.10
Available in Mavis alpha.11 for Vue Web and NativeScript. Keep core and renderer versions aligned.
<MTabBar :modelValue="currentRoute" :items="destinations" label="Main navigation" />| Property | Type | Default | Description |
|---|---|---|---|
material | solid / glass | theme | Sets the material for this component. See Bar and speed dial material. |
items | NavigationItem[] | required | Stable value, label, href and optional icon, badge, disabled, navigate. |
modelValue | string / number / null | null | Current route identity, supplied by the app. |
label | string | required | Navigation region name. |
disabled | boolean | false | Disables all destinations. |
safeArea | boolean | false | Opt-in Web bottom viewport inset; native already uses MScreen. |
Route navigation with real Web links and native actions using the installed navigation service. Derive modelValue from the confirmed route; no optimistic selection or update:modelValue event bypasses route guards. Modified Web clicks retain normal link behavior. error forwards navigation failures. Current links expose aria-current="page"; native accessible names include currentLabel. Badges are included in action names. Each destination stacks its icon over its label. A soft pill glides to the current destination through a shared layout, the current icon bumps when it becomes current, and badges bump when their count changes. Web keeps the visible text in the order of the action name. Use MTabs for local content panels. The bar participates in normal layout; the host decides its position. A small set of short labels is recommended; there is no overflow menu. Keep native MScreen safe-area ownership and enable the Web inset only when placing the bar against the viewport bottom.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const pt = computed(() => (props.lang ?? locale.value) === 'pt')
const t = (en: string, br: string) => (pt.value ? br : en)
import type { NavigationItem } from '@getcortexlabs/mavis-core'
const current = ref('home')
const items = computed<NavigationItem[]>(() => [
{
value: 'home',
label: t('Home', 'Início'),
href: '/home',
icon: 'house',
navigate: async () => {
current.value = 'home'
},
},
{
value: 'saved',
label: t('Saved', 'Salvos'),
href: '/saved',
icon: 'bookmark',
badge: 3,
navigate: async () => {
current.value = 'saved'
},
},
{
value: 'profile',
label: t('Profile', 'Perfil'),
href: '/profile',
icon: 'user',
navigate: async () => {
current.value = 'profile'
},
},
])
</script>
<template>
<MColumn gap="md">
<MText
:text="
t('A destination for every part of your day.', 'Um destino para cada parte do seu dia.')
"
/>
<MTabBar
:modelValue="current"
:items="items"
:label="t('Main navigation', 'Navegação principal')"
:currentLabel="t('Current page', 'Página atual')"
/>
<MText id="tab-bar-current" :text="current" tone="muted" />
</MColumn>
</template>Desktop
On the desktop each destination is a link button and the bar is one tab stop: the left and right arrows, Home and End move the keyboard among destinations, and the system's activation follows the destination through the application's navigation. safeArea is accepted and does nothing, since a window has no inset of its own. See Desktop components.