Breadcrumbs

Shows where the current page sits in the site.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrBreadcrumbs, WrBreadcrumbsItem } from 'ngwr/breadcrumbs';

@Component({ imports: [WrBreadcrumbs, WrBreadcrumbsItem] })
export class MyComponent {}

Playground

An item with no routerLink or href is the current page.

<wr-breadcrumbs separator="/" ariaLabel="Breadcrumbs">
  <wr-breadcrumbs-item icon="home" routerLink="/">Home</wr-breadcrumbs-item>
  <wr-breadcrumbs-item icon="folder" routerLink="/docs">Docs</wr-breadcrumbs-item>
  <wr-breadcrumbs-item routerLink="/docs/components">Components</wr-breadcrumbs-item>
  <wr-breadcrumbs-item>Breadcrumbs</wr-breadcrumbs-item>
</wr-breadcrumbs>

Customize

Separator
Aria Label

API

NameDescriptionTypeDefault
<wr-breadcrumbs>Container. Renders <nav aria-label><ol>…</ol></nav>.component—
separatorShort string drawn between items.string'/'
ariaLabelName of the nav landmark. Falls back to breadcrumbs.label.string | nullnull
<wr-breadcrumbs-item>One item: .wr-breadcrumbs__link when linked, .wr-breadcrumbs__current (aria-current="page") when not.component—
iconLeading icon from the icon registry.WrIconName | nullnull
routerLinkAngular router target. Wins over href.string | readonly unknown[] | nullnull
hrefPlain anchor href.string | nullnull
externalOpen href in a new tab (adds target="_blank" rel="noreferrer noopener").booleanfalse

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/breadcrumbs's own element.

VariableDefaultDeclared on
--wr-breadcrumbs-colorcolor-mix(in srgb, var(--wr-color-on-surface) 60%, transparent).wr-breadcrumbs
--wr-breadcrumbs-current-colorvar(--wr-color-on-surface).wr-breadcrumbs
--wr-breadcrumbs-current-font-weightvar(--wr-font-weight-semibold).wr-breadcrumbs
--wr-breadcrumbs-current-gapvar(--wr-space-sm).wr-breadcrumbs
--wr-breadcrumbs-font-familyvar(--wr-font-family-base).wr-breadcrumbs
--wr-breadcrumbs-font-sizevar(--wr-text-sm).wr-breadcrumbs
--wr-breadcrumbs-gapvar(--wr-space-sm).wr-breadcrumbs
--wr-breadcrumbs-link-colorvar(--wr-color-primary-ink).wr-breadcrumbs
--wr-breadcrumbs-link-gapvar(--wr-space-sm).wr-breadcrumbs
--wr-breadcrumbs-link-radiusvar(--wr-border-radius-sm).wr-breadcrumbs
--wr-breadcrumbs-separator'/'.wr-breadcrumbs
--wr-breadcrumbs-separator-colorcolor-mix(in srgb, var(--wr-color-on-surface) 30%, transparent).wr-breadcrumbs

Dependencies

@angular/router@angular/router(optional peer)
Built onIcon

See also