Raccourci clavier : Ctrl + K
Commencer

Fil d'Ariane

VBreadcrumb affiche un fil d’Ariane à partir d’un tableau d’éléments et identifie la page actuelle par son URL.

Utilisation

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
]
</script>

<template>
  <VBreadcrumb :items="items" current-path="/app/projects/vectis-ui" />
</template>

Exemples

Séparateur personnalisé

separatorIcon remplace le séparateur entre les segments.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'
import { arrow_right_alt as arrowRightAlt } from 'vectis-ui/icons'

import slash from '~/assets/img/breadcrumb-slash.svg'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
]
</script>

<template>
  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui"
    :separator-icon="arrowRightAlt"
    label="Trail with an icon separator"
  />

  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui"
    :separator-icon="{ src: slash }"
    label="Trail with an image separator"
  />
</template>

Avec des icônes

Chaque élément peut inclure une icon décorative à côté du libellé.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'
import {
  cloud_upload as cloudUpload,
  picture_as_pdf as pictureAsPdf,
  table_chart as tableChart,
} from 'vectis-ui/icons'

const items = [
  { label: 'Uploads', href: '/app/files', icon: cloudUpload },
  { label: 'Reports', href: '/app/files/reports', icon: tableChart },
  { label: 'Third quarter', href: '/app/files/reports/q3', icon: pictureAsPdf },
]
</script>

<template>
  <VBreadcrumb :items="items" current-path="/app/files/reports/q3" />
</template>

Troncature

Au-delà de maxItems, le fil conserve le premier élément et les deux derniers. Un menu de points de suspension liste les éléments masqués.

vue
<script setup lang="ts">
import { VBreadcrumb } from 'vectis-ui'

const items = [
  { label: 'Home', href: '/app' },
  { label: 'Projects', href: '/app/projects' },
  { label: 'Vectis UI', href: '/app/projects/vectis-ui' },
  { label: 'Components', href: '/app/projects/vectis-ui/components' },
  { label: 'Breadcrumb', href: '/app/projects/vectis-ui/components/breadcrumb' },
  { label: 'Accessibility', href: '/app/projects/vectis-ui/components/breadcrumb/a11y' },
]
</script>

<template>
  <VBreadcrumb
    :items="items"
    current-path="/app/projects/vectis-ui/components/breadcrumb/a11y"
    :max-items="4"
  />
</template>

Routeur

Chaque segment est un vrai <a>. Un clic émet navigate avec l’élément et l’événement : avec Nuxt ou Vue Router, appelez preventDefault() et poussez item.href. Un clic avec une touche de modification n’émet rien et ouvre toujours un nouvel onglet.

vue
<VBreadcrumb
  :items="items"
  :current-path="$route.path"
  @navigate="(item, event) => { event.preventDefault(); $router.push(item.href) }"
/>

API

Props

PropTypeDéfaut
itemsBreadcrumbItem[]aucune
Éléments du fil, de la racine au niveau actuel.
labelstringaucune
Nom accessible de la navigation. Utilise le dictionnaire par défaut.
currentPathstringaucune
URL utilisée pour identifier l’élément actuel. Les barres obliques finales, paramètres de requête et fragments sont ignorés.
separatorIconIconSourcechevron_right
Icône de séparation. Retournée dans les dispositions de droite à gauche.
maxItemsnumberaucune
Seuil de troncature, avec un minimum effectif de 3.
ellipsisLabelstringaucune
Nom accessible du menu de points de suspension. Utilise le dictionnaire par défaut.

Événements

ÉvénementType
navigate[item: BreadcrumbItem, event: MouseEvent]
Segment suivi, depuis le fil ou le menu des points de suspension. Reçoit l’élément et le clic ; appelez preventDefault() pour le routage. Les clics avec une touche modificatrice ne l’émettent pas.

Types

Types utilisés dans les tables d’API. Importez les types exportés depuis vectis-ui.

export interface BreadcrumbItem {
  label: string
  href: string
  icon?: IconSource
}
export interface BuiltinIcon {
  name: string
  paths: readonly [string] | readonly [string, string]
}
export type IconRender =
  | { path: string; viewBox?: string }
  | { component: Component; props?: Record<string, unknown> }
  | { src: string }
  | { text: string; class?: string }
  | { class: string }
export type IconSource = string | BuiltinIcon | IconRender