BreadcrumbBreadcrumb provides contextual information about page hierarchy.

Breadcrumb - 图1

Documentation

Import

  1. import {BreadcrumbModule} from 'primeng/breadcrumb';
  2. import {MenuItem} from 'primeng/api';
  3.  

MenuModel API

Breadcrumb uses the common menumodel api to define its items, visit MenuModel API for details.

Getting Started

Breadcrumb requires a collection of menuitems connected to its model property.

  1. export class BreadcrumbDemo implements OnInit {
  2. private items: MenuItem[];
  3. ngOnInit() {
  4. this.items = [
  5. {label:'Categories'},
  6. {label:'Sports'},
  7. {label:'Football'},
  8. {label:'Countries'},
  9. {label:'Spain'},
  10. {label:'F.C. Barcelona'},
  11. {label:'Squad'},
  12. {label:'Lionel Messi', url: 'https://en.wikipedia.org/wiki/Lionel_Messi'}
  13. ];
  14. }
  15. }
  16.  
  1. <p-breadcrumb [model]="items"></p-breadcrumb>
  2.  

Properties

NameTypeDefaultDescription
modelarraynullAn array of menuitems.
homeMenuItemnullMenuItem configuration for the home icon.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.

Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
ui-breadcrumbContainer element.
ui-menuitemMenuitem element.
ui-menuitem-textLabel of a menuitem.
ui-breadcrumb-chevronChevron element.

Dependencies

None.

Source

View on GitHub

  1. export class BreadcrumbDemo implements OnInit {
  2. items: MenuItem[];
  3. home: MenuItem;
  4. ngOnInit() {
  5. this.items = [
  6. {label:'Categories'},
  7. {label:'Sports'},
  8. {label:'Football'},
  9. {label:'Countries'},
  10. {label:'Spain'},
  11. {label:'F.C. Barcelona'},
  12. {label:'Squad'},
  13. {label:'Lionel Messi', url: 'https://en.wikipedia.org/wiki/Lionel_Messi', icon: 'pi pi-external-link'}
  14. ];
  15. this.home = {icon: 'pi pi-home'};
  16. }
  17. }
  18.  
  1. <p-breadcrumb [model]="items" [home]="home"></p-breadcrumb>
  2.