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

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

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 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