Single- and Multi-Select Questions with Custom Item Template
SurveyJS Form Library supports the usage of custom templates to change the appearance of choice options in Checkboxes, Radio Button Group, and other single- or multi-select question types. This demo shows how to customize choice options using a custom template component.
To create and apply a custom option template, follow the steps below:
Implement a component that renders option markup.
The component accepts the option configuration object as a prop. You can use itsvalueandtextproperties to access the option's value to be saved in survey results and display text.Register the component so that it can be accessed by name.
In HTML/CSS/JavaScript projects, register the component inReactElementFactoryas shown in theindex.jsfile.
In React, register the component inReactElementFactoryas shown in theSurveyComponent.jsxfile.
In Angular, register the component inAngularComponentFactoryas shown in thecustom-choice-item.component.tsfile.
In Vue.js, use techniques native to this framework.Assign the component name to the question's
itemComponentproperty in the survey JSON schema.