Synertech Web/ui v0.57.5 Site Storybook

Documentation / Navigation & actions

Breadcrumb

Server-compatible@synertech/uiOpen in Storybook

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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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

ComponentServer-compatible
import { Breadcrumb } from "@synertech/ui";

Props — BreadcrumbProps

PropTypeDefaultDescription

+ 278 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).

Types

interface BreadcrumbItem
FieldTypeDefaultDescription