A breadcrumb is a secondary navigation pattern that shows users their current location within a website or application's hierarchy.
Breadcrumbs visually represent the navigational structure of a site or app and help users navigate to parent levels with ease. Each breadcrumb item corresponds to a level in the hierarchy, with the last item indicating the current page or context.
When to use
To use breadcrumb in a standalone component, import DAFF_BREADCRUMB_COMPONENTS
directly into your custom component:
import { DAFF_BREADCRUMB_COMPONENTS } from '@daffodil/design/breadcrumb';
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
imports: [
DAFF_BREADCRUMB_COMPONENTS,
],
})
export class CustomComponent {}
To use breadcrumb in a module, import DaffBreadcrumbModule
into your custom module:
import { NgModule } from '@angular/core';
import { DaffBreadcrumbModule } from '@daffodil/design/breadcrumb';
import { CustomComponent } from './custom.component';
@NgModule({
declarations: [
CustomComponent,
],
exports: [
CustomComponent,
],
imports: [
DaffBreadcrumbModule,
],
})
export class CustomComponentModule { }
This method is deprecated. It's recommended to update all custom components to standalone.
A breadcrumb consists of the following components:
[daff-breadcrumb]
: The wrapper that groups all breadcrumb items together. Applied to an <ol>
element.
[daffBreadcrumbItem]
: Individual breadcrumb element within the navigation path. Applied to a <li>
element.
<ol daff-breadcrumb>
<li daffBreadcrumbItem>
<a routerLink="/">Home</a>
</li>
<li daffBreadcrumbItem>
<a routerLink="/category">Category</a>
</li>
<li daffBreadcrumbItem>
<span>Current Page</span>
</li>
</ol>
Breadcrumb follows the Breadcrumb WAI-ARIA design pattern.
aria-current="page"
automatically applied to the last breadcrumb item<ol>
and <li>
elements)<nav>
element with a descriptive aria-label
<nav aria-label="Category breadcrumb">
<ol daff-breadcrumb>
<li daffBreadcrumbItem>
<a routerLink="/">Home</a>
</li>
<li daffBreadcrumbItem>
<a routerLink="/category">Category</a>
</li>
<li daffBreadcrumbItem>
<span>Current Page</span>
</li>
</ol>
</nav>