0
      <select className="option-select">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="opel">Opel</option>
        <option value="audi">Audi</option>
      </select>

Here is how the basic select is defined. How to target the dropdown list UI? For example, changing the default background of the dropdown.

EDIT:

I find that it does work in Chrome if I target the <option> element. But on firefox, it does not work.

1
  • You're pretty limited on the styling that you can apply to a <select> because its rendering is very much driven by the host OS. Your best bet is probably to use (or create) a custom component which mimics the behavior of a <select> using other HTML elements. The framework you're using (React) likely has many available 3rd party components for this. Commented Oct 31, 2021 at 19:56

3 Answers 3

1

select {
  background: yellow    
}
option {
  color: red 
}
<select className="option-select">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

Sign up to request clarification or add additional context in comments.

2 Comments

works on Chrome, not firefox
You can't style this on Firefox
0

It's possible to style the select menu 'button', but not the dropdown itself. To accomplish that you need to mimic the functionality with javascript. https://www.w3schools.com/howto/howto_custom_select.asp

Comments

0

Just a few CSS properties can change dropdown appearance and it's better to use a react components library such as material-ui.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.