Breadcrumbs

Material Design 3-styled breadcrumbs web components (lit-material-breadcrumbs, lit-material-breadcrumb-item).

  • 1.2 KB gzipped
  • @lit-material/breadcrumbs 0.1.0
  • Renders on the server

Example

Install

npm install @lit-material/breadcrumbs @lit-material/tokens
import "@lit-material/breadcrumbs";

Link @lit-material/tokens/css/index.css once per page for the colour, type and shape tokens. Install guide

API

<lit-material-breadcrumb-item>

A single crumb within lit-material-breadcrumbs — a real <a> link, or plain text for the current page. Renders its own trailing separator via :host(:not(:last-of-type))::after, so the parent needs no JS coordination to know which crumb is last; override --lit-material-breadcrumb-separator to use something other than "/".

Properties

PropertyAttributeTypeDefaultDescription
hrefhrefstring""
currentcurrentbooleanfalseMarks this as the current page: always renders as plain text (even if href is set) with aria-current="page".

Slots

SlotDescription
defaultThe crumb's label.

CSS parts

PartDescription
crumbThe link or current-page text.

<lit-material-breadcrumbs>

Groups lit-material-breadcrumb-item elements into a <nav> wrapping an <ol> — an ordered list, since a breadcrumb trail genuinely is a sequence. <ol> has an implicit ARIA list role on its own; nothing extra to set there. Each item sets its own role="listitem" (see that component), and draws its own trailing separator, so this container needs no JS logic beyond rendering the wrapper.

Properties

PropertyAttributeTypeDefaultDescription
labellabelstring"Breadcrumb"The <nav> landmark's accessible name.

Slots

SlotDescription
defaultlit-material-breadcrumb-item elements, in order from the root down to the current page.

CSS parts

PartDescription
navThe <nav> landmark.
listThe <ol>.

Source on GitHub npm