NavigationRail
Added in alpha.11
Included in Mavis 0.1.0-alpha.11 for Vue + Vite, Nuxt and NativeScript iOS/Android. Keep core and renderers on the same version.
<MNavigationRail
v-model:collapsed="collapsed"
:modelValue="routeKey"
:groups="groups"
label="Workspace"
/>| Prop | Type | Default | Description |
|---|---|---|---|
groups | readonly NavigationGroup[] | required | Unique groups with key, label and NavigationItem entries. Item values are unique across groups. |
modelValue | ChoiceValue or null | null | App-owned current destination; successful routing determines the active item. |
collapsed / collapsible / disabled | boolean | false / true / false | Compact 80 px/DIP or expanded 256 px/DIP presentation. |
header / footer | slots | — | Receive { collapsed } for branding and account content. |
Links use the installed Mavis navigation adapter or an item navigate callback. Web retains href and browser link behavior. Current state is controlled by the application rather than optimistic clicks. Compact buttons keep accessible names and badge context. Jolt animates current-item signals and button feedback; the application chooses when to collapse for its layout.
Events: update:collapsed(boolean), error(unknown).
Motion
The current destination sits on a soft highlight that glides to the next item when the app changes modelValue, across groups and in both the expanded and compact rail. The icon of the new destination gives a small bump as it arrives. Collapsing and expanding animate the rail's width; on expand the group headings slide in one after another, and the rail clips its content while it grows, so labels never spill outside its edge. The highlight is decoration: aria-current, the accessible names and the badge text change at once. Reduced motion settles the highlight and skips the heading arrivals. In forced colors the highlight becomes an outline.
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
import type { NavigationGroup, ChoiceValue } from '@getcortexlabs/mavis-core'
const props = defineProps<{ lang?: 'en' | 'pt' }>()
const { locale } = useCatalogLocale(() => props.lang)
const t = (en: string, br: string) => ((props.lang ?? locale.value) === 'pt' ? br : en)
const current = ref<ChoiceValue>('overview')
const collapsed = ref(false)
const groups = computed<NavigationGroup[]>(() => [
{
key: 'workspace',
label: t('Workspace', 'Seu espaço'),
items: [
{
value: 'overview',
label: t('Overview', 'Visão geral'),
href: '/overview',
icon: 'layout-dashboard',
navigate: () => {
current.value = 'overview'
},
},
{
value: 'projects',
label: t('Projects', 'Projetos'),
href: '/projects',
icon: 'layers',
badge: 8,
navigate: () => {
current.value = 'projects'
},
},
{
value: 'insights',
label: t('Insights', 'Análises'),
href: '/insights',
icon: 'chart-no-axes-combined',
navigate: () => {
current.value = 'insights'
},
},
],
},
{
key: 'people',
label: t('Together', 'Em companhia'),
items: [
{
value: 'team',
label: t('Team', 'Equipe'),
href: '/team',
icon: 'users',
badge: 4,
navigate: () => {
current.value = 'team'
},
},
{
value: 'settings',
label: t('Settings', 'Preferências'),
href: '/settings',
icon: 'settings-2',
navigate: () => {
current.value = 'settings'
},
},
],
},
])
</script>
<template>
<MNavigationRail
v-model:collapsed="collapsed"
:modelValue="current"
:groups="groups"
:label="t('Studio navigation', 'Navegação do estúdio')"
:collapseLabel="t('Collapse navigation', 'Recolher navegação')"
:expandLabel="t('Expand navigation', 'Expandir navegação')"
>
<template #header="{ collapsed: compact }"
><MRow padding="sm" gap="sm" justify="center"
><MIcon name="orbit" :size="28" tone="primary" /><MText
v-if="!compact"
text="Orbit"
variant="heading" /></MRow
></template>
<template #footer="{ collapsed: compact }"
><MRow padding="sm" gap="sm" justify="center"
><MAvatar name="Alex Morgan" size="sm" /><MText
v-if="!compact"
text="Alex Morgan"
variant="caption" /></MRow
></template>
</MNavigationRail>
<MText id="rail-value" :text="String(current)" variant="caption" tone="muted" />
</template>Desktop
On the desktop the rail is a sidebar of link buttons with its groups and badges, one tab stop that the up and down arrows, Home and End move through. Collapsed, it shows the icons alone and names each destination in a tooltip. See Desktop components.