breadcrumb

Displays the path to the current resource using a hierarchy of links.

PreviousNext
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';

@Component({
  selector: 'z-demo-breadcrumb-preview',
  imports: [ZardBreadcrumbImports],
  template: `
    <z-breadcrumb>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/']">Home</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <z-breadcrumb-ellipsis />
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/docs/components']">Components</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoBreadcrumbPreviewComponent {}

Installation

Copy
npx zard-cli@latest add breadcrumb

Usage

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';
Copy
<z-breadcrumb>
  <z-breadcrumb-item>
    <a z-breadcrumb-link routerLink="/">Home</a>
  </z-breadcrumb-item>
  <z-breadcrumb-item>
    <a z-breadcrumb-link routerLink="/docs/components">Components</a>
  </z-breadcrumb-item>
  <z-breadcrumb-item>
    <span z-breadcrumb-page>Breadcrumb</span>
  </z-breadcrumb-item>
</z-breadcrumb>
Copy

Examples

basic

A basic breadcrumb with z-breadcrumb-link elements using plain href targets.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardBreadcrumbImports } from '../breadcrumb.imports';

@Component({
  selector: 'z-demo-breadcrumb-basic',
  imports: [ZardBreadcrumbImports],
  template: `
    <z-breadcrumb zLabel="Basic breadcrumb">
      <z-breadcrumb-item>
        <a z-breadcrumb-link href="/">Home</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <a z-breadcrumb-link href="/docs/components">Components</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoBreadcrumbBasicComponent {}

custom separator

Project your own li[z-breadcrumb-separator] elements to replace the default chevron between items.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideDot } from '@ng-icons/lucide';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';

@Component({
  selector: 'z-demo-breadcrumb-custom-separator',
  imports: [ZardBreadcrumbImports, NgIcon],
  template: `
    <z-breadcrumb zLabel="Breadcrumb with custom separator">
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/']">Home</a>
      </z-breadcrumb-item>
      <li z-breadcrumb-separator>
        <ng-icon name="lucideDot" />
      </li>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/docs/components']">Components</a>
      </z-breadcrumb-item>
      <li z-breadcrumb-separator>
        <ng-icon name="lucideDot" />
      </li>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  viewProviders: [provideIcons({ lucideDot })],
})
export class ZardDemoBreadcrumbCustomSeparatorComponent {}

dropdown

Compose a z-breadcrumb-item with [z-dropdown] and z-dropdown-menu-content for a menu trigger.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideChevronDown } from '@ng-icons/lucide';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';
import { ZardDropdownImports } from '@/shared/components/dropdown/dropdown.imports';

@Component({
  selector: 'z-demo-breadcrumb-dropdown',
  imports: [ZardBreadcrumbImports, ZardDropdownImports, NgIcon],
  template: `
    <z-breadcrumb zLabel="Breadcrumb with dropdown">
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/']">Home</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <button
          z-breadcrumb-link
          type="button"
          class="flex items-center gap-1.5 border-0 bg-transparent p-0 text-inherit"
          z-dropdown
          [zDropdownMenu]="componentsMenu"
        >
          Components
          <ng-icon name="lucideChevronDown" class="size-3.5!" aria-hidden="true" />
        </button>

        <z-dropdown-menu-content #componentsMenu="zDropdownMenuContent" class="w-48">
          <z-dropdown-menu-item>Documentation</z-dropdown-menu-item>
          <z-dropdown-menu-item>Themes</z-dropdown-menu-item>
          <z-dropdown-menu-item>GitHub</z-dropdown-menu-item>
        </z-dropdown-menu-content>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  viewProviders: [provideIcons({ lucideChevronDown })],
})
export class ZardDemoBreadcrumbDropdownComponent {}

collapsed

Use z-breadcrumb-ellipsis to collapse a long trail while keeping the first and last items visible.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';

@Component({
  selector: 'z-demo-breadcrumb-collapsed',
  imports: [ZardBreadcrumbImports],
  template: `
    <z-breadcrumb zLabel="Collapsed breadcrumb">
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/']">Home</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <z-breadcrumb-ellipsis />
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/docs/introduction']">Docs</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/docs/components']">Components</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoBreadcrumbCollapsedComponent {}

link

Bind [routerLink] on z-breadcrumb-link to navigate through the Angular Router instead of a full page reload.
import { ChangeDetectionStrategy, Component } from '@angular/core';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';

@Component({
  selector: 'z-demo-breadcrumb-link',
  imports: [ZardBreadcrumbImports],
  template: `
    <z-breadcrumb zLabel="Breadcrumb with Angular routing">
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/']">Home</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <a z-breadcrumb-link [routerLink]="['/docs/components']">Components</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>Breadcrumb</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ZardDemoBreadcrumbLinkComponent {}

rtl

To enable RTL support in zard/ui, see the RTL configuration guide.
// You will notice this example is rendered inside a wrapper that sets the dir and data-lang attributes, and
// reads its text from a translations helper. This is because this site is not RTL by default.
// In your application you won't need either: set dir="rtl" on <html> (or use the CDK Dir directive on a subtree)
// and write the text of your own language. See the RTL guide: https://zardui.com/docs/rtl

import { ChangeDetectionStrategy, Component } from '@angular/core';

import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideChevronDown } from '@ng-icons/lucide';

import { ZardBreadcrumbImports } from '@/shared/components/breadcrumb/breadcrumb.imports';
import { ZardDropdownImports } from '@/shared/components/dropdown/dropdown.imports';
import { injectRtlTranslation, type ZardRtlTranslations } from '@/shared/demo-utils/rtl-translation';

interface BreadcrumbRtlValues {
  home: string;
  components: string;
  documentation: string;
  themes: string;
  source: string;
  breadcrumb: string;
  more: string;
}

const translations: ZardRtlTranslations<BreadcrumbRtlValues> = {
  en: {
    dir: 'ltr',
    values: {
      home: 'Home',
      components: 'Components',
      documentation: 'Documentation',
      themes: 'Themes',
      source: 'Source code',
      breadcrumb: 'Breadcrumb',
      more: 'More breadcrumbs',
    },
  },
  ar: {
    dir: 'rtl',
    values: {
      home: 'الرئيسية',
      components: 'المكونات',
      documentation: 'التوثيق',
      themes: 'السمات',
      source: 'الكود المصدري',
      breadcrumb: 'مسار التنقل',
      more: 'مزيد من المسارات',
    },
  },
  he: {
    dir: 'rtl',
    values: {
      home: 'בית',
      components: 'רכיבים',
      documentation: 'תיעוד',
      themes: 'ערכות נושא',
      source: 'קוד מקור',
      breadcrumb: 'פירורי לחם',
      more: 'עוד נתיבים',
    },
  },
};

@Component({
  selector: 'z-demo-breadcrumb-rtl',
  imports: [ZardBreadcrumbImports, ZardDropdownImports, NgIcon],
  template: `
    <z-breadcrumb [zLabel]="i18n.t().breadcrumb">
      <z-breadcrumb-item>
        <a z-breadcrumb-link href="#">{{ i18n.t().home }}</a>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <z-breadcrumb-ellipsis [zLabel]="i18n.t().more" />
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <button
          z-breadcrumb-link
          type="button"
          class="flex items-center gap-1.5 border-0 bg-transparent p-0 text-inherit"
          z-dropdown
          [zDropdownMenu]="componentsMenu"
        >
          {{ i18n.t().components }}
          <ng-icon name="lucideChevronDown" class="size-3.5!" aria-hidden="true" />
        </button>

        <z-dropdown-menu-content #componentsMenu="zDropdownMenuContent" class="w-48">
          <z-dropdown-menu-item>{{ i18n.t().documentation }}</z-dropdown-menu-item>
          <z-dropdown-menu-item>{{ i18n.t().themes }}</z-dropdown-menu-item>
          <z-dropdown-menu-item>{{ i18n.t().source }}</z-dropdown-menu-item>
        </z-dropdown-menu-content>
      </z-breadcrumb-item>
      <z-breadcrumb-item>
        <span z-breadcrumb-page>{{ i18n.t().breadcrumb }}</span>
      </z-breadcrumb-item>
    </z-breadcrumb>
  `,
  changeDetection: ChangeDetectionStrategy.OnPush,
  viewProviders: [provideIcons({ lucideChevronDown })],
})
export class ZardDemoBreadcrumbRtlComponent {
  protected readonly i18n = injectRtlTranslation(translations);
}

API Reference

z-breadcrumbComponent

Displays the path to the current resource using a hierarchy of links. Renders a labelled `<nav>` wrapping an ordered list; separators render automatically unless explicit separators are projected. The default chevron separator flips in right-to-left layouts; a custom separator is rendered as given.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zLabel] Accessible label for the breadcrumb navigation string 'breadcrumb'
[zSize] Breadcrumb text size 'sm' | 'md' | 'lg' 'md'
[zAlign] Horizontal alignment of the item list 'start' | 'center' | 'end' 'start'
[zWrap] Whether the item list wraps onto multiple lines 'wrap' | 'nowrap' 'wrap'
[zSeparator] Custom separator content rendered between auto-generated separators string | TemplateRef<void> ''

z-breadcrumb-item, [z-breadcrumb-item]Component

An individual breadcrumb item, rendered with `role="listitem"`. When no `z-breadcrumb-link`, `z-breadcrumb-page`, or `z-breadcrumb-ellipsis` is projected, it renders a generated link for every item except the last and a page for the last one; the router-compatible inputs below configure that generated link.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[routerLink] Router-compatible command array, string, or UrlTree for the generated link string | any[] | UrlTree []
[queryParams] Query params merged into the generated URL when routerLink is set Params -
[fragment] URL fragment appended to the generated URL when routerLink is set string -
[queryParamsHandling] How the current query params are merged with queryParams 'merge' | 'preserve' | '' -
[state] Navigation state passed to the Router when routerLink is set unknown -
[info] Arbitrary navigation info passed to the Router when routerLink is set unknown -
[relativeTo] Route the routerLink commands are resolved against; defaults to the current activated route ActivatedRoute -
[preserveFragment] Keeps the current URL fragment when navigating via routerLink boolean false
[skipLocationChange] Navigates via routerLink without pushing a new browser history entry boolean false
[replaceUrl] Replaces the current browser history entry instead of pushing a new one boolean false

z-breadcrumb-link, [z-breadcrumb-link]Component

A clickable breadcrumb link. Apply the attribute to a native `<a>` or `<button>` to reuse its interactive semantics. Set routerLink to navigate through the Angular Router (href is generated and kept in sync), or set href directly for a plain link.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[routerLink] Router-compatible command array, string, or UrlTree; navigates via the Router and computes href string | any[] | UrlTree -
[queryParams] Query params merged into the generated URL when routerLink is set Params -
[fragment] URL fragment appended to the generated URL when routerLink is set string -
[queryParamsHandling] How the current query params are merged with queryParams 'merge' | 'preserve' | '' -
[state] Navigation state passed to the Router when routerLink is set unknown -
[info] Arbitrary navigation info passed to the Router when routerLink is set unknown -
[relativeTo] Route the routerLink commands are resolved against; defaults to the current activated route ActivatedRoute -
[preserveFragment] Keeps the current URL fragment when navigating via routerLink boolean false
[skipLocationChange] Navigates via routerLink without pushing a new browser history entry boolean false
[replaceUrl] Replaces the current browser history entry instead of pushing a new one boolean false
[href] Plain link URL, used when routerLink is not set string -

z-breadcrumb-page, [z-breadcrumb-page]Component

The current page in the breadcrumb trail. Renders non-clickable content with `aria-current="page"`.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''

z-breadcrumb-separator, [z-breadcrumb-separator]Component

A decorative separator between breadcrumb items (`aria-hidden`, `role="presentation"`). Project it manually — e.g. on an `<li>` — to override the default chevron and suppress the automatic separators; project custom content inside it to change the glyph.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''

z-breadcrumb-ellipsis, [z-breadcrumb-ellipsis]Component

A control that stands in for one or more collapsed items in a long breadcrumb trail.

PropertyDescriptionTypeDefault
[class] Custom CSS classes ClassValue ''
[zColor] Icon color 'muted' | 'strong' 'muted'
[zLabel] Screen-reader label for the collapsed items string 'More breadcrumbs'
github iconwhatsapp icondiscord iconX icon

Made with ❤ in Brazil. Open source and available on GitHub .