Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

230
Views
how can I change the css of a selected <Option/> of <Select/>?

I am using React.js, and ant-design components.

I have a <Select/> component with a few <Option/> inside of it, now I know that on each selected option has this automatic hue added to it, but I want to change it do a different one, and also to change the background etc, but only if an option has been selected.

is there a way to do that?

(Select, Option Components - https://ant.design/components/select/ )

about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

<select>
  <option selected="">1</option>
  <option>2</option>
</select>
<style>
  option[selected]{
    background: #f00;
  }
</style>

This is the right CSS for this but I think it doesn't work on every browser. Even on Firefox it works only if you hover over the expanded options. Changing CSS styles of inputs was always pretty bad and weird. That's why there are libraries for that.

about 4 years ago · Santiago Trujillo Report

0

first of all sorry for my bad english, i dont know it is the best answer but when i want to change an element style i use its class and give that class a css. for selectbox you can use ant-select-selector in your css file :

.ant-select-selector{background-color:green}

if you want to check class for diffrent things you can check the element in dev tools.If you look at this img when i select to selectbox div i can see its own class and i can change its background-color.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!