Skip to content
LIBRARYNavigation

Breadcrumb ​

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.

Web preview
Open example ↗
vue
<MBreadcrumb :items="path" :maxItems="3" label="Breadcrumb" />
PropTypeDefaultDescription
itemsreadonly BreadcrumbItem[]requiredUnique key, label and ancestor href; navigate is optional. Last entry is the current page.
maxItemsnumber4At least two. Extra middle ancestors remain reachable through the expansion button.
label / expandLabelstringBreadcrumb / Show full pathLocalizable navigation and expansion labels.

The last entry is text with current-page semantics. Ancestors are real MLink destinations. Expansion shows the entire path without a second navigation model, and resets when path identities change. Long paths wrap on narrow screens. Separators are decorative.

Events: error(unknown).

Motion ​

When the path changes, the crumbs that join it arrive one after another from where the trail ends, the ones that leave shrink away and the rest close in around them. Expanding the collapsed middle brings the hidden ancestors in the same way; the one that receives focus settles immediately, so the focus ring never travels. A thin accent grows under the current page each time it changes. Links, aria-current and the accessible path update at once. Reduced motion skips the arrivals and the accent growth. The accent uses the system highlight in forced colors. On NativeScript the trail keeps the layout motion, without the per-crumb arrival, and the current page is underlined without the growing accent.

vue
<script setup lang="ts">
import { computed, ref } from 'vue'
import { useCatalogLocale } from '../locale'
import type { BreadcrumbItem } 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 destination = ref('—')
const depth = ref(5)
const trail = computed(() => [
  { key: 'home', label: 'Orbit', href: '/' },
  { key: 'projects', label: t('Projects', 'Projetos'), href: '/projects' },
  { key: 'studio', label: 'Studio', href: '/projects/studio' },
  { key: 'brand', label: t('Brand system', 'Sistema de marca'), href: '/projects/studio/brand' },
  {
    key: 'colors',
    label: t('Color stories', 'Histórias em cores'),
    href: '/projects/studio/brand/colors',
  },
  {
    key: 'coral',
    label: t('Coral at dusk', 'Coral ao entardecer'),
    href: '/projects/studio/brand/colors/coral',
  },
])
// The app owns the path: following a crumb navigates, and the trail then follows the route.
const items = computed<BreadcrumbItem[]>(() =>
  trail.value.slice(0, depth.value).map((entry, index, path) =>
    index === path.length - 1
      ? { key: entry.key, label: entry.label }
      : {
          ...entry,
          navigate: (href: string) => {
            destination.value = href
            depth.value = index + 1
          },
        },
  ),
)
const current = computed(() => trail.value[depth.value - 1]!)
const deeper = () => {
  depth.value = Math.min(trail.value.length, depth.value + 1)
  destination.value = current.value.href
}
</script>

<template>
  <MCard gap="lg" padding="lg">
    <MBreadcrumb
      :items="items"
      :maxItems="3"
      :label="t('Breadcrumb', 'Caminho de navegação')"
      :expandLabel="t('Show full path', 'Mostrar caminho completo')"
    />
    <MSeparator />
    <MRow gap="md"
      ><MIcon name="palette" :size="32" tone="primary" /><MText
        :text="current.label"
        variant="title"
        :shrink="1"
    /></MRow>
    <MText
      :text="
        t(
          'Every detail has a place. Find your way back without losing the thread.',
          'Cada detalhe tem seu lugar. Volte sem perder o fio da história.',
        )
      "
      tone="muted"
    />
    <MRow gap="sm" wrap>
      <MButton
        id="breadcrumb-deeper"
        variant="secondary"
        icon="arrow-right"
        :disabled="depth === trail.length"
        :text="t('Look closer', 'Ver de perto')"
        @click="deeper"
      />
    </MRow>
    <MText id="breadcrumb-value" :text="destination" variant="caption" tone="muted" />
  </MCard>
</template>

Desktop ​

On the desktop each ancestor is a link button and the current page is text marked by an accent. The collapsed middle is a button that opens the whole path and moves the keyboard to the first link it showed. See Desktop components.

Components for NativeScript and Web. Starting with Vue.