StepsSteps components is an indicator for the steps in a workflow. Layout of steps component is optimized for responsive design.

Steps - 图1

Documentation

Import

  1. import {StepsModule} from 'primeng/steps';
  2. import {MenuItem} from 'primeng/api';
  3.  

MenuModel API

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

Getting Started

Steps requires a collection of menuitems as its model.

  1. <p-steps [model]="items"></p-steps>
  2.  
  1. export class MenuDemo {
  2. items: MenuItem[];
  3. ngOnInit() {
  4. this.items = [
  5. {label: 'Step 1'},
  6. {label: 'Step 2'},
  7. {label: 'Step 3'}
  8. ];
  9. }
  10. }
  11.  

Readonly

Items are readonly by default, if you'd like to make them interactive then disable readonly.

  1. <p-steps [model]="items" [readonly]="false"></p-steps>
  2.  

Properties

NameTypeDefaultDescription
modelarraynullAn array of menuitems.
activeIndexnumber0Index of the active item.
readonlybooleantrueWhether the items are clickable or not.
stylestringnullInline style of the component.
styleClassstringnullStyle class of the component.

Events

NameParametersDescription
activeIndexChangeindex: Index of the active step itemCallback to invoke when the new step is selected.

Styling

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

NameElement
ui-stepsContainer element.
ui-steps-itemMenuitem element.
ui-steps-currentActive item.
ui-steps-incompleteInactive item.
ui-steps-completeCompleted item.
ui-steps-numberNumber of menuitem.
ui-steps-titleLabel of menuitem.

Dependencies

None.

Source

View on GitHub

  1. <p-toast [style]="{marginTop: '80px'}"></p-toast>
  2. <h3 class="first">Basic</h3>
  3. <p-steps [model]="items"></p-steps>
  4. <h3>Clickable</h3>
  5. <p-steps [model]="items" [(activeIndex)]="activeIndex" [readonly]="false"></p-steps>
  6. <h3>Custom Style</h3>
  7. <p-steps [model]="items" styleClass="steps-custom"></p-steps>
  8.  
  1. @Component({
  2. templateUrl: 'showcase/demo/steps/stepsdemo.html',
  3. providers: [MessageService],
  4. styles: [`
  5. .ui-steps .ui-steps-item {
  6. width: 25%;
  7. }
  8. .ui-steps.steps-custom {
  9. margin-bottom: 30px;
  10. }
  11. .ui-steps.steps-custom .ui-steps-item .ui-menuitem-link {
  12. height: 10px;
  13. padding: 0 1em;
  14. }
  15. .ui-steps.steps-custom .ui-steps-item .ui-steps-number {
  16. background-color: #0081c2;
  17. color: #FFFFFF;
  18. display: inline-block;
  19. width: 36px;
  20. border-radius: 50%;
  21. margin-top: -14px;
  22. margin-bottom: 10px;
  23. }
  24. .ui-steps.steps-custom .ui-steps-item .ui-steps-title {
  25. color: #555555;
  26. }
  27. `],
  28. encapsulation: ViewEncapsulation.None
  29. })
  30. export class StepsDemo implements OnInit {
  31. items: MenuItem[];
  32. activeIndex: number = 1;
  33. constructor(private messageService: MessageService) {}
  34. ngOnInit() {
  35. this.items = [{
  36. label: 'Personal',
  37. command: (event: any) => {
  38. this.activeIndex = 0;
  39. this.messageService.add({severity:'info', summary:'First Step', detail: event.item.label});
  40. }
  41. },
  42. {
  43. label: 'Seat',
  44. command: (event: any) => {
  45. this.activeIndex = 1;
  46. this.messageService.add({severity:'info', summary:'Seat Selection', detail: event.item.label});
  47. }
  48. },
  49. {
  50. label: 'Payment',
  51. command: (event: any) => {
  52. this.activeIndex = 2;
  53. this.messageService.add({severity:'info', summary:'Pay with CC', detail: event.item.label});
  54. }
  55. },
  56. {
  57. label: 'Confirmation',
  58. command: (event: any) => {
  59. this.activeIndex = 3;
  60. this.messageService.add({severity:'info', summary:'Last Step', detail: event.item.label});
  61. }
  62. }
  63. ];
  64. }
  65. }
  66.