Drop-Down Menu with Custom Item Template
Custom item templates allow you to implement drop-down menu item appearance from scratch, enhance menu item styling, and create complex item layouts. In this demo, a custom template is used to add icons to drop-down menu items.
To customize a drop-down menu item, follow the steps below:
Implement a component that renders item markup.
The component accepts the item configuration object as a prop. You can use itsvalue
andtext
properties to access the item'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 inReactElementFactory
as shown in theindex.js
file.
In React, register the component inReactElementFactory
as shown in theSurveyComponent.jsx
file.
In Angular, register the component inAngularComponentFactory
as shown in thesurvey.component.ts
file.
In Vue and Knockout, use techniques native to these libraries:Assign the component name to the Dropdown question's
itemComponent
property in the survey JSON schema.