score:2
Accepted answer
How to move global styles into a scope for emotion ?
@Andarist found a solution for that by creating a stylis plugin for extra scope
Example
Create a cache with stylis plugin for extra scope
const STRONG_ID = 'very-strong-id';
const cache = createCache({
stylisPlugins: [createExtraScopePlugin(`#${STRONG_ID}`)],
});
Use your global styles in the cache provider
<CacheProvider value={cache}>
<Global
styles={css`
div {
background-color: red;
}
`}
/>
<div id={STRONG_ID}>
<div>I must be red (global style scoped to the parent div)</div>
<Container>
I must be blue (local style defined on this div)
</Container>
</div>
</CacheProvider>
Then your global styles will be scope by very-strong-id
You can find the example here
Hope it will help someone in the future 😊
Source: stackoverflow.com
Related Query
- How to move global styles into a scope for emotion?
- How to override global border color styles for disabled Material UI TextField?
- How to import styles into React for Material Components for Web
- How to apply global styles with CSS modules in a react app?
- How to add global loading/spin effect in axios interceptor for a React project
- How to use typescript with the definition of custom styles for a select using react-select
- How to handle global state data into deeply nested components in Redux?
- How to use different styles for android and ios on react-native?
- How to override styles for material-ui TextField component without using the MUIThemeProvider?
- Electron: How to securely inject global variable into BrowserWindow / BrowserView?
- React: How do I move my ajax api call into a separate component?
- How to use theme in styles for custom class components
- how can use hsl instead of rgb for scss global declaration javascript api
- How to use conditional styles with MUI v5 using emotion styled
- How to link 'from outside' into Navigator (for example from a global footer)
- How to exclude global styles in a React App?
- In a ReactJS app, how to substitute env vars from the global environment into my index.html file?
- Why is css imported into the global scope in React?
- How to create insertion point to mount styles in shadow dom for MUI material v5 in React custom element
- How to import css file for into Component .jsx file
- how to change double "OO" existed words in the paragraph into green square in react? for example clooney - cl[green square]ey
- How to move react event handlers to separate file ,export and then import for reuse in multiple different functional components?
- How to set global style for a react-select.js
- angular scope vs react state how does it work for data binding
- Global styles for specific pages in next js
- How can I create a global array in react? When I do separate operations for each index, I want them to save them in a single array
- How do I create a class decorator for mixing new methods into a React component when using Typescript?
- how to add global scss styles to preact app
- How to render global styles from styled-components in Storybook?
- How to move React-JSS styles to separate file?
More Query from same tag
- Styling a React Material UI Component with a .map function
- React JS - can't call setState on a component that is not yet mounted
- Redux: A state mutation was detected inside a dispatch
- How to load image outside of Frontend folder
- How do you update the div with React?
- module import work with react in dev but not in build
- Mixed Error: This request has been blocked; the content must be served over HTTPS
- How to submit a form in react
- How to use calc css function in react render
- Execute a React js function on d3js event
- Semantic-UI / ReactJS | Use DropDown as group
- TypeError: Cannot destructure property 'cartItems' of 'cart' as it is undefined
- adding to an array using useState using the input value - React
- Material-UI Data-Grid: How pass parameter to custom toolbar?
- Access to instance of fullCalendar v5
- JavaScript Map Function with React.js gives me index, but not value in the index
- Webpack 4 and code splitting
- webpack-dev-server set cookie via proxy
- React JS bold the text in between
- Videos In React Going Fullscreen
- OnScroll event firing without scrolling - Reactjs
- ReactJS - replacing an object in an array with another
- Component doesn't re-render after state changes
- How to animate a google material bar chart
- How to display the information submitted in the html form on another page using react js?
- Styling Grid to have more elements than text
- How do I add a background image in React+bootstrap?
- Why is my object.item always returning undefined?
- axios response.blob is not a function
- cPanel & Passenger: what's my entry point?