I have build a custom IconProvider
class to display list of SLDS icons for selection on Lightning App Builder.
public with sharing class IconProvider extends VisualEditor.DynamicPickList {
public override VisualEditor.DataRow getDefaultValue(){
VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('', '');
return defaultValue;
}
public override VisualEditor.DynamicPickListRows getValues() {
List<Icon> icons = (List<Icon>) JSON.deserialize(PageReference.forResource('All', 'sldsIcons.json').getContent().toString(), List<Icon>.class);
System.debug(icons);
VisualEditor.DynamicPickListRows options = new VisualEditor.DynamicPickListRows();
for (Icon ic: icons) {
options.addRow(new VisualEditor.DataRow(ic.id + ' (' + ic.route + ')', ic.fullName));
}
return options;
}
public class Icon{
public String id;
public String route;
public String fullName;
}
}
I have a static resource zip file All
which has a cached list of SLDS icons in a sldsIcons.json
text JSON file.
I have a custom LWC which is available for Lightning Record Pages
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>53.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
<targetConfigs>
<targetConfig targets="lightning__RecordPage">
<property label="Header" name="header" type="String"/>
<property label="Header Icon" name="icon" type="String" datasource="apex://IconProvider"/>
</targetConfig>
</targetConfigs>
</LightningComponentBundle>
I can see the list of icon names and I can select them, but when I try to save the Lightning App Builder page definition, I receive the following error:
"Component has an invalid value for property."