Search docs

Breadcrumb

The path to the current page in the site hierarchy.

Breadcrumb follows the Breadcrumb WAI-ARIA design pattern.

import { component$, useStyles$ } from '@builder.io/qwik';
import { Breadcrumb } from '@leve-ui/breadcrumb';
import { LuChevronRight } from '@qwikest/icons/lucide';
import styles from './default.css?inline';

export default component$(() => {
  useStyles$(styles);

  return (
    <Breadcrumb.Root class="breadcrumb-default">
      <Breadcrumb.List class="breadcrumb-default-list">
        <Breadcrumb.Item>
          <Breadcrumb.Link href="#home" class="breadcrumb-default-link">
            Home
          </Breadcrumb.Link>
        </Breadcrumb.Item>
        {/* The library hides the separator from assistive technology */}
        <Breadcrumb.Separator class="breadcrumb-default-separator">
          <LuChevronRight class="breadcrumb-default-separator-icon" aria-hidden="true" />
        </Breadcrumb.Separator>
        <Breadcrumb.Item>
          <Breadcrumb.Link href="#components" class="breadcrumb-default-link">
            Components
          </Breadcrumb.Link>
        </Breadcrumb.Item>
        <Breadcrumb.Separator class="breadcrumb-default-separator">
          <LuChevronRight class="breadcrumb-default-separator-icon" aria-hidden="true" />
        </Breadcrumb.Separator>
        <Breadcrumb.Item>
          <Breadcrumb.Link href="#breadcrumb" current class="breadcrumb-default-link">
            Breadcrumb
          </Breadcrumb.Link>
        </Breadcrumb.Item>
      </Breadcrumb.List>
    </Breadcrumb.Root>
  );
});

Installation#

Install the individual package, or use @leve-ui/core to get every component at once:

pnpm add @leve-ui/breadcrumb

Anatomy#

import { Breadcrumb } from '@leve-ui/breadcrumb'; // or '@leve-ui/core'

<Breadcrumb.Root>
  <Breadcrumb.List>
    <Breadcrumb.Item>
      <Breadcrumb.Link />
    </Breadcrumb.Item>
    <Breadcrumb.Separator />
    <Breadcrumb.Item>
      <Breadcrumb.Link current />
    </Breadcrumb.Item>
  </Breadcrumb.List>
</Breadcrumb.Root>
PartElementDescription
Breadcrumb.Root<nav>The navigation landmark.
Breadcrumb.List<ol>The ordered list of items.
Breadcrumb.Item<li>One item. Put a Link inside.
Breadcrumb.Link<a>The link to a page. Use current for the current page, and as to render another element or a router link component.
Breadcrumb.Separator<li>A decorative separator between items, such as / or an icon. Hidden from assistive technologies.

Examples#

Pass a router link component such as Qwik City's <Link> to as for client-side navigation and prefetching while keeping Breadcrumb.Link's attributes:

import { Link } from '@builder.io/qwik-city';
import { Breadcrumb } from '@leve-ui/breadcrumb';

<Breadcrumb.Link as={Link} href="/components/">
  Components
</Breadcrumb.Link>

A component passed to as must spread the props it receives onto a single element, including id, aria-*, data-*, and on*$ event handlers.

API Reference#

Root#

No props of its own. Accepts all <nav> attributes.

Data attributeValue
data-leve-breadcrumbAlways present

List#

No props of its own. Accepts all <ol> attributes.

Data attributeValue
data-leve-breadcrumb-listAlways present

Item#

No props of its own. Accepts all <li> attributes.

Data attributeValue
data-leve-breadcrumb-itemAlways present
PropDefaultType
as'a'keyof HTMLElementTagNameMap | Component<any>

The element or component to render instead of <a>. A component must spread the props it receives onto one element.

currentfalseboolean

Marks the link as the current page (outputs aria-current="page").

Also accepts all <a> attributes.

Data attributeValue
data-leve-breadcrumb-linkAlways present
data-currentPresent when current is true

Separator#

No props of its own. Accepts all <li> attributes.

Data attributeValue
data-leve-breadcrumb-separatorAlways present

Accessibility#

Complies with the Breadcrumb WAI-ARIA design pattern.

  • Breadcrumb.Root is a <nav> landmark named aria-label="Breadcrumb" by default. Pass aria-label or aria-labelledby to change the name.
  • Breadcrumb.Link with current renders aria-current="page".
  • Breadcrumb.Separator renders role="presentation" and aria-hidden="true", so it is not read and not counted as a list item.
  • The links are native <a> elements and are reached with Tab. Breadcrumb adds no keyboard interaction of its own.