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

135
Views
how to style same element with different CSS properties in styled-components

how can i style same type of elements but diffrent ones with diffrent css properties in styled components ? for example

<div></div>
<div></div>

with knowledge i have i can do

 export const StyledDiv = styled.div`
color:red;
`

and change <div></div> to <StyledDiv></StyledDiv> but what if I want to change each of these divs with different styles? for example, I want one of them to have the color blue one and of them to have the color red and these 2 elements are just for example to show you the meaning now imagine a page with 10s of divs each with different style What's the best way to deal with them?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can simply pass props to the styled component like so:

const StyledDiv = styled.div`
  color: ${props => props.color};
`;

And in your component:

  return <StyledDiv color="red">...</div>;
about 4 years ago · Juan Pablo Isaza 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!