Breadcrumb

Fil d'ariane de navigation montrant la hierarchie de la page actuelle. Installez Breadcrumb depuis le registre VLLNT UI avec la CLI shadcn.

Signaler un bug

Fil d'ariane de navigation montrant la hierarchie de la page actuelle. Fait partie de la famille navigation dans VLLNT UI, il est publie comme entree de registre lisible par machine — copiez la source directement dans votre application avec la CLI shadcn et possedez-la, sans dependance d'execution a une bibliotheque de composants.

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Installation

Ajoutez Breadcrumb a votre projet avec la CLI shadcn. La source arrive dans votre code, prete a etre adaptee :

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/breadcrumb.json

Source

import Link from "next/link"; import type * as React from "react"; import { cn } from "../../lib/utils"; export type BreadcrumbItem = { href?: string; icon?: React.ReactNode; label: React.ReactNode; }; type BreadcrumbProps = { className?: string; items: BreadcrumbItem[]; separator?: "arrow" | "chevron" | "slash"; showHomeIcon?: boolean; variant?: "default" | "minimal"; }; const SEPARATOR_CHARS: Record<string, string> = { arrow: "→", chevron: "›", slash: "/", }; function SeparatorIcon({ type }: { type: string }) { return ( <span aria-hidden="true" className="text-muted-foreground"> {SEPARATOR_CHARS[type] ?? "›"} </span> ); } export function Breadcrumb({ className, items, separator = "chevron", variant = "default", }: BreadcrumbProps) { return ( <nav aria-label="Breadcrumb" className={cn("flex items-center space-x-1 text-sm", className)} > {items.map((item, index) => ( <div className="flex items-center" key={ typeof item.label === "string" ? item.label : `breadcrumb-${index}` } > {index > 0 && ( <span className="mx-2"> <SeparatorIcon type={separator} /> </span> )} {item.href ? ( <Link className="flex items-center gap-1 hover:text-foreground transition-colors" href={item.href} > {item.icon ? ( <span className="flex-shrink-0">{item.icon}</span> ) : null} <span className={cn( // Truncate plain string labels; custom React elements handle their own overflow typeof item.label === "string" && "truncate", variant === "minimal" ? "text-muted-foreground" : "text-foreground", )} > {item.label} </span> </Link> ) : ( <span className="flex items-center gap-1 text-muted-foreground"> {item.icon ? ( <span className="flex-shrink-0">{item.icon}</span> ) : null} <span className={cn(typeof item.label === "string" && "truncate")} > {item.label} </span> </span> )} </div> ))} </nav> ); }

Stories

Explorez chaque variante et etat dans le Storybook interactif :

Apercu

Basculez entre clair et sombre pour inspecter l'apercu Storybook integre.

Dependances

  • @vllnt/ui@^0.3.0