Having difficulties with Cumulocity's icon-selector

I’m trying to add an icon-selector to my own widget that resembles the functionality of Cumulocity KPI widget. But it seems that I am currently doing this incorrectly and need a bit of assistance in terms of getting it to show within the UI.

Attached is an example of what I’m looking for in terms of the KPI widget and what I have currently.

This is the code snippet where I am having difficulties:

config.component.html code snippet:

<c8y-icon-selector

[selectedIcon]=“selectedIcon”

(selectedIconChange)=“onIconSelected($event)”

>

<i [c8yIcon]=“‘rocket’”>

Rocket icon test

<c8y-li-icon [icon]=“‘bell’”>

Selected: {{ selectedIcon }}

<c8y-icon-selector

[selectedIcon]=“selectedIcon”

[availableIcons]=“availableIcons”

(selectedIconChange)=“selectedIcon = $event”

>

config.component.ts code snippet:

//ADDED and TESTING

availableIcons = [‘cogs’, ‘bell’, ‘car’, ‘anchor’]; // Cumulocity built-ins

selectedIcon: string = ‘bell’;

selectedDatapointIndex: number | null = null;

onIconSelected(icon: string) {

this.selectedIcon = icon;

console.log(‘Selected icon:’, icon);

}

This is what KPI Widget looks like that is the desired outcome.

This is what inside that KPI Widget looks like that is the desired outcome.

Hi @ChaseTurck,

Just by right clicking the icon selector button in the kpi widget configuration view, you would have been able to find out that you are using the wrong component.

The c8y-icon-selector-wrapper is what you are looking for.

To use this component, you need to import the IconSelectorModule or depending on your version, you can already directly import the IconSelectorWrapperComponent as a standalone component.

Regards,
Tristan

1 Like