Documentation / Navigation & actions
Breadcrumb
The breadcrumb trail: the current page’s path through the site tree, from the most general to the most specific. It is described by an items array of { label, href?, icon?, onClick? }; the last item is the current page and gets aria-current="page".
maxItems folds the intermediate levels behind "..." while keeping the first and the last ones. Separator, size and colours (Tailwind classes) can be customised. The <nav> carries aria-label="Breadcrumb" by default: pass your own aria-label to translate it. A hook-free, server-compatible component.
Examples
Basic usage
Items with an href become links; the last one marks the current page.
import { Breadcrumb } from "@synertech/ui";
export function Basic() {
return (
<Breadcrumb
aria-label="Fil d’Ariane"
items={[
{ label: "Accueil", href: "/" },
{ label: "Projets", href: "/projets" },
{ label: "Refonte du site" },
]}
/>
);
}Icon and separator
icon comes before the label; separator accepts a text or a React node.
import { Breadcrumb } from "@synertech/ui";
const HomeIcon = () => (
<svg
className="h-4 w-4"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
aria-hidden="true"
>
<path strokeLinecap="round" strokeLinejoin="round" d="M3 12l9-9 9 9M5 10v10h5v-6h4v6h5V10" />
</svg>
);
export function CustomSeparator() {
return (
<Breadcrumb
aria-label="Fil d’Ariane"
separator="›"
items={[
{ label: "Accueil", href: "/", icon: <HomeIcon /> },
{ label: "Paramètres", href: "/parametres" },
{ label: "Facturation" },
]}
/>
);
}Collapsed path
With maxItems, only the first level and the last ones stay visible.
import { Breadcrumb, type BreadcrumbItem } from "@synertech/ui";
const deepPath: BreadcrumbItem[] = [
{ label: "Accueil", href: "/" },
{ label: "Catalogue", href: "/catalogue" },
{ label: "Informatique", href: "/catalogue/informatique" },
{ label: "Ordinateurs portables", href: "/catalogue/informatique/portables" },
{ label: "Ultrabooks", href: "/catalogue/informatique/portables/ultrabooks" },
{ label: "Modèle 14 pouces" },
];
export function Collapsed() {
return <Breadcrumb aria-label="Fil d’Ariane" items={deepPath} maxItems={3} />;
}Sizes and colours
size sets the type size; itemColor, activeColor and separatorColor take classes.
import { Breadcrumb, type BreadcrumbItem } from "@synertech/ui";
const deepPath: BreadcrumbItem[] = [
{ label: "Accueil", href: "/" },
{ label: "Catalogue", href: "/catalogue" },
{ label: "Informatique", href: "/catalogue/informatique" },
{ label: "Ordinateurs portables", href: "/catalogue/informatique/portables" },
{ label: "Ultrabooks", href: "/catalogue/informatique/portables/ultrabooks" },
{ label: "Modèle 14 pouces" },
];
export function Styled() {
return (
<div className="space-y-3">
<Breadcrumb aria-label="Fil d’Ariane" size="sm" items={deepPath.slice(0, 3)} />
<Breadcrumb
aria-label="Fil d’Ariane"
size="lg"
items={deepPath.slice(0, 3)}
itemColor="text-blue-600 hover:text-blue-800"
activeColor="text-gray-900 font-semibold dark:text-gray-100"
separatorColor="text-blue-300"
/>
</div>
);
}Click tracking
onClick runs on click, in addition to navigating to href.
import { Breadcrumb } from "@synertech/ui";
export function WithTracking() {
const track = (label: string) => () => console.log("Clic sur le fil d’Ariane :", label);
return (
<Breadcrumb
aria-label="Fil d’Ariane"
items={[
{ label: "Tableau de bord", href: "/dashboard", onClick: track("Tableau de bord") },
{ label: "Clients", href: "/clients", onClick: track("Clients") },
{ label: "Société Dupont" },
]}
/>
);
}API reference
Components
import { Breadcrumb } from "@synertech/ui";Props — BreadcrumbProps
| Prop | Type | Default | Description |
|---|---|---|---|
items• |
BreadcrumbItem[] |
— | |
activeColor |
string |
"text-gray-700 font-medium dark:text-gray-200" |
|
aria-label |
string |
— | Accessible name of the navigation landmark. English by default ( |
itemColor |
string |
"text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100" |
|
linkComponent |
UILinkComponent |
— | The link of the application's router ( |
maxItems |
number |
— | |
separator |
ReactNode |
"/" |
|
separatorColor |
string |
"text-gray-500 dark:text-gray-400" |
|
size |
"sm" | "md" | "lg" |
"md" |
+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
BreadcrumbItem
Interfaceinterface BreadcrumbItem| Field | Type | Default | Description |
|---|---|---|---|
label• |
string |
— | |
href |
string |
— | Where it leads. An |
icon |
ReactNode |
— | |
onClick |
(event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void |
— | Called on a click, with its event: |