PeakUI

Breadcrumbs

Breadcrumb trail for hierarchical navigation

Usage

import {Breadcrumbs} from "@peakui/react";

Anatomy

import {Breadcrumbs} from "@peakui/react";

export default () => (
  <Breadcrumbs>
    <Breadcrumbs.Item href="/products">Products</Breadcrumbs.Item>
    <Breadcrumbs.Item>Laptop</Breadcrumbs.Item>
  </Breadcrumbs>
);

Examples

Custom Separator

separator accepts any node; an element receives the separator slot's class and data-slot.

Disabled State

isDisabled disables every link in the trail.

Customization

Tailwind CSS

<Breadcrumbs className="text-base">
  <Breadcrumbs.Item href="#">Home</Breadcrumbs.Item>
  <Breadcrumbs.Item>Laptop</Breadcrumbs.Item>
</Breadcrumbs>

Global CSS

@layer components {
  .breadcrumbs {
    gap: calc(var(--spacing) * 2);
  }

  .breadcrumbs__link {
    color: var(--color-muted);
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The Breadcrumbs component uses these CSS classes (view source styles):

Base Classes

  • .breadcrumbs - Base list styles: flex row, gap-1.5

Element Classes

  • .breadcrumbs__item - The <li> wrapper: flex row, gap-1
  • .breadcrumbs__link - The item's link, composed with the .link classes
  • .breadcrumbs__separator - The separator glyph: size-3, muted, flipped in RTL

Slots

  • [data-slot="breadcrumbs"] - The root ordered list
  • [data-slot="breadcrumbs-item"] - Each breadcrumb's <li>
  • [data-slot="breadcrumbs-separator"] - Each separator between items

The item's link is the Link component and keeps its own link slot.

Interactive States

The component supports both CSS pseudo-classes and data attributes:

  • Hover: :hover or [data-hovered] on a link
  • Focus: :focus-visible or [data-focus-visible] on a link
  • Pressed: :active or [data-pressed] on a link
  • Current: [aria-current="page"] on the last item's link
  • Disabled: [aria-disabled="true"] on a link

API Reference

PropTypeDefaultDescription
childrenReactNode-The breadcrumb items
separatorReactNode-Separator between items; defaults to a right chevron
isDisabledboolean-Disables every link in the trail
onAction(key: Key) => void-Called with the pressed item's id
classNamestring-Additional classes on the list
renderDOMRenderFunction<'ol', undefined>-Replaces the rendered <ol> with your own element

Every other attribute of an <ol> is accepted.

PropTypeDefaultDescription
childrenReactNode | ((values: BreadcrumbRenderProps) => ReactNode)-The item content, or a function of the render props
hrefstring-The URL the item's link navigates to
idKey-Passed to onAction when the item is pressed
classNamestring | ((values: BreadcrumbRenderProps) => string)-Additional classes, or a function of the render props
renderPossibleLinkDOMRenderProps<'span', LinkRenderProps>-Replaces the item's link with your own element

Every other attribute of an <a> is accepted.

Render Props

PropTypeDescription
children(values: BreadcrumbRenderProps) => ReactNodeReceives isCurrent, isDisabled
className(values: BreadcrumbRenderProps) => stringSame values as children

On this page