How do i highlight selected item in dropdown
See original GitHub issueI want to apply a css class to the current selected item when the dropdown is open. Something like the following.
As you can see the current selected item is highlighted in red when the dropdown is opened. This is done by passing the className to the option that is currently selected as follows:-
const options = data.map((item) => {
let className = item.isDefault ?
'highlight-selected-item ' :
'';
return {
label: item.profileName,
value: item.profileName,
className
};
});
I think it would be great if the Select component can take a prop like optionSelectedClassName
so that we don’t have to manually see which item is selected and add a className to that.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How can I highlight an option in a dropdown menu?
By highlight i mean either have it selected or change its background colour or something. HTML: <select id="siteId" name="siteId" onchange ...
Read more >How to highlight currently selected item in dropdown menu
addClass('active'); // Store the index of the active li element localStorage.activeItem = $this.parent().index(); }; // Check if activeItem was ...
Read more >How to highlight selected item in dropdown list - CodeProject
Solution 2 ; protected void ; object sender, EventArgs e){ // ; Find element by Text or value ListItem lstItem = DropDownList1.Items.FindByText( ...
Read more >Solved: Blank Gallery - highlight selected item
Blank Gallery - highlight selected item ; Set the OnCheck property of the Checkbox as below. Set(SelectedRow, ThisItem.City) ; Set the Default property...
Read more >DropDownList / How To / Highlight the matched character in ...
By using the highlightSearch method, you can highlight the matched character in DropDownList filtering. The following example demonstrates about how to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will work.
':active': { backgroundColor: 'hotpink' }
This should be mentioned in the docs.