Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

139
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda