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>
);
};
Source: stackoverflow.com
Related Query
- Override styled component parent div properties in child
- How to override event handler function of child component from parent component in react.js
- Get parent component properties on click of child component
- How to get parent props in child component when using styled component in react
- How do I get the state of the parent component in a child styled component using tagged template literals?
- Toggle div of child component from parent React
- How to override child css class in parent react component using sass
- Calling Child Component Function From Parent Component Give Error : Cannot read properties of undefined
- I want my div to be 100% of my parent div using styled component
- ReactJS useStyles to override text field font color of child component from parent component
- React Child Component does not update properties passed from Parent Component
- How to pass data from child component to its parent in ReactJS?
- React Child Component Not Updating After Parent State Change
- React js change child component's state from parent component
- ReactJS: setState on parent inside child component
- React Hook : Send data from child to parent component
- How do I access refs of a child component in the parent component
- React - Can A Child Component Send Value Back To Parent Form
- React: Update Child Component Without Rerendering Parent
- Prevent child component from unmounting and remounting if parent component changes
- How to pass function as props from functional parent component to child
- ReactJS: "this.props" is not a function when child component calls parent
- Updating Parent Component State from Child Component with UseState React Hook
- ReactJS modify parent state from child component
- React - Get the ref present in child component in the parent component
- Can we pass setState as props from one component to other and change parent state from child component in React?
- Nested React Router : hide parent component on showing nested child component
- Unit test: simulate the click event of child component in parent using enzyme
- Connecting child components to store vs connecting parent component to store and passing down props
- How to re render parent component when anything changes in Child Component?
More Query from same tag
- Spring React and Sessions.. how to keep session
- React help switching between tabs
- Why the theme doesn't work in Material-UI?
- How do I get the current tab to be highlighted?
- Typescript in React: Props type check is not working
- How do I resolve eslint conflict between props and module imports with the same name?
- How to insert state/props in class attribute in reactjs?
- How does React batch setState when mixing object and callback approach?
- How can I import two css frameworks dynamically in React?
- How can I imitate the look of the outline and label from Material-UI's outlined textfield?
- How to post form data from reactjs to controller in mvc asp.net
- react-router redirect doesn't change url in Switch
- Dispatch overrides the full store in React Js
- How do I successfully change the state in one component from another?
- How does shallow compare work in react
- .click() doesn't work in react
- How to unpublish a gatsby page without deleting it?
- how to add animation to D3 custom Radios
- Add Bootstrap button styles to default Gutenberg Button block in WordPress
- Styling of a table's row in React
- display the product as sold out when the value of sold_out is set to true using reactjs
- What is causing this error - Objects are not valid as a React child (found: object with keys {id, task})
- How to receive select value in handlesubmit function with formik react js?
- React test not resolving dynamic require paths
- Getting props inside of componenDidMount
- Spring Boot + React bundling as WebJar with custom context-path for the React app
- Apollo is mixing results from a GraphQL Query in React
- How to populate React Select with JSON data?
- React gradient slider (rating component) with rounded corners
- ClientError: input:9: Field CommentCreateInput.n of required type String! w input:10: Field "name" is not defined by type CommentCreateInput