Question T14518
Visible to All Users

Define an icon for a custom question component also how to add validation before form submit.

created a year ago (modified a year ago)

[Ticket cloned from T14501: How to add custom component in surveyjs form - Custom textwithbutton React component]

@Jane Thank you for your response Now i am able to add custom question type with custom component but one issue is that, how to add icon for that question as well?

Answers approved by surveyjs Support

created a year ago

Hello,
To define an icon for a custom React component, you can define the icon-yourQuestionType entry within the settings.customIcons array. For instance, the following code sets an icon for the descriptivetext question type. This question will use the icon-text icon from a built-in SurveyJS icon collection: Built-In Icons.

JavaScript
import { settings } from "survey-core"; settings.customIcons["icon-descriptivetext"] = "icon-text";

An example is available at Implement a Descriptive Text Element.

If you wish to register a custom icon, please follow these instructions: Custom Icons.

Please let me know if you have any further questions.

    Comments (2)
    M M
    MD AMIR SOHAIL a year ago

      I need to add icon for custom question which i added do not want to replace any icon with other icon.

        You can follow the above recommendation and add an icon for your custom question. As mentioned, you need to register an icon under the icon-yourQuestionType key. For instance:

        JavaScript
        ... import { settings } from "survey-core"; SvgRegistry.registerIconFromSvg("yourCustomIconName", iconSvg); settings.customIcons["icon-textwithbutton"] = "icon-yourCustomIconName";

        Please let me know if this helps.