Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda