score:1

you can't target a parent class from a child, instead, you should do it from the parent itself.

in this example, without overriding in parent, the child will have padding: 10px and the green background will be revealed.

const child = styled.div`
  background-color: palegreen;
  padding: 10px;
`;

const parent = styled.div`
  background-color: palevioletred;
  padding: 1rem;
  ${child} {
    padding: 0px;
  }
`;

const app = () => {
  return (
    <parent>
      <child />
    </parent>
  );
};

edit distracted-williams-w3nh8


Related Query

More Query from same tag