Breadcrumb
Shows the path from the app root to the current page.
Import
import { Breadcrumb } from '@matix/components/breadcrumb';Usage
Router Links
Pass your router link to render. Breadcrumb.Link puts its styles and props on that element, so the page gets one <a>, not two nested anchors. This is the same render prop that the Base UI components use.
import Link from 'next/link';
<Breadcrumb.Item>
<Breadcrumb.Link render={<Link href="/components" />}>Components</Breadcrumb.Link>
</Breadcrumb.Item>;asChild still works, but it is deprecated. Use render.
Custom Separator
Pass any node as children of Breadcrumb.Separator to replace the default chevron.
Collapsed
Render a Breadcrumb.Ellipsis in place of intermediate items when the path is long. Wrap it in a Menu.Trigger to expose the hidden items on click.
To open the hidden items in a menu, the trigger needs its own name:
<Breadcrumb.Item>
<Menu.Root>
<Menu.Trigger render={<Button variant="ghost" size="sm" aria-label="Show hidden pages" />}>
<Breadcrumb.Ellipsis />
</Menu.Trigger>
{/* Menu.Portal with one Menu.Item per hidden page */}
</Menu.Root>
</Breadcrumb.Item>Custom Styles
import * as stylex from '@stylexjs/stylex';
const custom = stylex.create({
link: { color: '#3b82f6', fontWeight: 500 },
});
<Breadcrumb>
<Breadcrumb.List>
<Breadcrumb.Item>
<Breadcrumb.Link href="/" sx={custom.link}>
Home
</Breadcrumb.Link>
</Breadcrumb.Item>
<Breadcrumb.Separator />
<Breadcrumb.Item>
<Breadcrumb.Page>Current</Breadcrumb.Page>
</Breadcrumb.Item>
</Breadcrumb.List>
</Breadcrumb>;API Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Breadcrumb | sx | StyleXStyles | — | StyleX override for the root <nav> |
Breadcrumb.List | sx | StyleXStyles | — | StyleX override for the <ol> |
Breadcrumb.Item | sx | StyleXStyles | — | StyleX override for the <li> |
Breadcrumb.Link | href | string | — | Href for the anchor |
Breadcrumb.Link | render | ReactElement | (props) => ReactElement | — | Element to render in place of the <a>, e.g. Next.js <Link href="/x" /> |
Breadcrumb.Link | asChild | boolean | false | Deprecated. Use render. Merges styles onto the single child element |
Breadcrumb.Link | sx | StyleXStyles | — | StyleX override |
Breadcrumb.Page | sx | StyleXStyles | — | StyleX override for the current-page <span> |
Breadcrumb.Separator | children | ReactNode | — | Custom separator (defaults to chevron) |
Breadcrumb.Separator | sx | StyleXStyles | — | StyleX override |
Breadcrumb.Ellipsis | children | ReactNode | — | Custom content (defaults to three dots) |
Breadcrumb.Ellipsis | sx | StyleXStyles | — | StyleX override |
All other HTML attributes on each sub-component are forwarded.
Accessibility
- The root
<nav>is labeledaria-label="breadcrumb". - The current page uses
aria-current="page"on a non-interactive<span>. - Separators are marked
aria-hidden="true"androle="presentation"so screen readers skip them. - Ellipsis is decorative (
aria-hidden). When you wrap it in aMenu.Trigger, give the trigger anaria-label, for examplearia-label="Show hidden pages". Without it the trigger has no accessible name. - The list is a semantic
<ol>so assistive tech announces ordered steps.
Keyboard
| Key | Action |
|---|---|
Tab | Moves focus to the next link |
Shift + Tab | Moves focus to the previous link |
Enter | Follows the focused link |