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

113
Vistas
Nesting styles ignores the styled component's styling

I'm using styled-components via cdn. If I do not nest styles, my components are styled. If I try to nest, none of the styles take effect.

const AComponent = () => {
  return (
    <StyledComponent>
      <p>Some Text</p>
    </StyledComponent>
  )
}

// using this shows a red background color
const StyledComponent = styled.div`
  background-color: red;
`

// using this doesn't style anything - not even a red background color
const StyledComponent = styled.div`
  background-color: red;
  p {
    color: black;
  }
`

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I tried with a bit of twist and found the below code working.

export const StyledComponent = styled.div`
  background-color: red;
  & > p {
    color: green;
  }
`;

Here is the supporting link for explanation https://github.com/styled-components/styled-components/issues/330

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