Dropdown option style

Hi,
Is it possible with the dropdown list to have different style for each option ?
For example :
image
If I get a notification on the line 043001 I would like that the option 043001 be in yellow

Thank you

1 Like

kinda but not very practical

I second this. I am trying to set the background color of each option as well based on data for the option.

You can use markdown to inject a custom stylesheet element into the page, which can apply styles to each element in the dropdown based on their value:

image

It is fairly straightforward:

  1. Give the dropdownOptionsStyle an empty style class, so that you can target the particular dropdown modal (cannot use domId, as it is assigned only to the dropdown component, not the options modal).
    image

  2. Create a new markdown component to inject the <style> tag with the appropriate CSS styles. You will need to disable escapeHtml and create a binding on the source prop like so.

	styleClass = value['targetStyleClass']
	styles = [s.value for s in value['styles']]
	
	css = "\r\n".join([".iaDropdownCommon_options .psc-%s[data-label='%s'] { color:white; background-color: %s;}\r\n\r\n" % (styleClass,v['value'].value,v['color'].value) 
			 for v in styles])
	code = "<style type='text/css'>\r\n %s \r\n</style>" % css
	return code
2 Likes