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

110
Views
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 answers
Answer question

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