How use my own svg icons for kendo Stepper

1 Answer 732 Views
Icon Stepper SVGIcon
lahiru
Top achievements
Rank 1
lahiru asked on 09 Aug 2022, 06:52 AM

Hi,

I'm using kendo UI for angular and want to know how I can customize stepper icons with my own svg icons without adding icon library (eg: font awesome)

following is the kendo sample I'm using
import { Component } from "@angular/core";

@Component({
  selector: "my-app",
  template: `
    <kendo-stepper
      [steps]="steps"
      stepType="full"
      [(currentStep)]="current"
      [linear]="false"
      [style.width.px]="570"
    >
    </kendo-stepper>
  `,
})
export class AppComponent {
  public current = 1;

  public steps = [
    { label: "Personal Info", icon: "user" },
    { label: "Education", icon: "dictionary-add" },
    { label: "Attachments", icon: "attachment", optional: true },
    { label: "Preview", icon: "preview" },
    { label: "Submit", icon: "file-add" },
  ];
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Kaloyan
Telerik team
answered on 10 Aug 2022, 07:16 AM

Hi lahiru,

Thank you for the provided code snippet.

To add a custom icon to a Kendo UI for Angular Stepper component the developer can use the Stepper Indicator Template and define any custom content as well as attach SVG icons.

In more details, you can create a template with a <span> element with CSS class that is defined by the steps.icon field:

<kendo-stepper 
    [steps]="steps" 
    stepType="full" 
    [currentStep]="current" 
    [linear]="false" 
    [style.width.px]="570">

    <ng-template kendoStepperIndicatorTemplate let-step>
        <span class="{{step.icon}}"></span>
    </ng-template>
    
</kendo-stepper>

 

Then, in the component TS file, add a different string for each step.icon field. For example:

  public steps = [
    { label: "Happy", icon: "myicon1" },
    { label: "Angry", icon: "myicon2" },
    { label: "Cool", icon: "myicon3" },
    { label: "Love", icon: "myicon4" },
    { label: "Fear", icon: "myicon5" },
  ];

 

where myicon1, myicon2, and others are custom CSS classes that use the content CSS property to provide custom SVG icons, like this:

.myicon1 {
    content: url('../../assets/custom-icon-1.svg');
}

.myicon2 {
    content: url('../../assets/custom-icon-2.png');
}

. . .

 

I hope this answers your question. If this is not the case however, please let us know and I will try to assist you further.

Regards,
Kaloyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

lahiru
Top achievements
Rank 1
commented on 11 Aug 2022, 03:59 PM

Hi Kaloyan,

This is the answer what I exactly wanted. perfect!! Thanks

Tags
Icon Stepper SVGIcon
Asked by
lahiru
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or