For example:
<select {...props}>
<option value='my_option'>
<div className='flex justify-between items-center'>
<SomeIcon className='w-4'/>
<p>My Option</p>
</div>
</option>
</select>
When I try the above, it just discards the icons and only show text with the default styling
enter image description here
2
Answers
There is no way to wrap a HTML element inside an
<option>
tag. As per the HTML specification for<option>
:Thus, only text is permitted within
<option>
elements. Anything else is discarded.You could try using JS and CSS in order to use absolute positioning with CSS and JS to hide it the content when the menu is closed and show the content when the menu is open. However, this requires a medium understanding of CSS and JS.