I added several properties within this category using Serializer.addProperty("question", {…}) but I haven't found a way to modify the default icon.
How can I change the icon for a new category in the right side menu?
Answers approved by surveyjs Support
Hello,
With v2.0.2, we introduced a new iconName
setting which allows you to define icons for individual property grid categories. To specify an icon for a custom page category, implement the creator.onSurveyInstanceCreated
event handler and define the icon name:
JavaScriptimport { SvgRegistry } from "survey-core";
import { SurveyCreatorModel } from "survey-creator-core";
const creatorOptions = { ... };
const creator = new SurveyCreatorModel(creatorOptions);
const customIcon = '<svg viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg"><path d="..."/></svg>';
SvgRegistry.registerIcon("icon-custom", customIcon);
creator.onSurveyInstanceCreated.add((_, options) => {
if (options.area === "property-grid") {
const choicesCategory = options.survey.getPageByName("choices");
if (choicesCategory) {
choicesCategory.iconName = "icon-custom";
}
}
})
You may wish to use any predefined icon from the Form Library / Survey Creator package or register a custom icon. For more information on how to use predefined and custom icons, please refer to our documentation: UI Icons.
Hello,
Thank you for your inquiry. We are working on this task at Property Grid - Introduce an API for specifying icons for custom property grid categories. We'll update you once we have any news to share. Please stay tuned.