Skip to content
Discussion options

You must be logged in to vote

There are two approaches:

  1. Use & nesting to scope rules within a parent selector:
const Title = styled.h1`
  #container & {
    color: red;
  }
`;
  1. Use stylisPlugins on StyleSheetManager to write a custom stylis plugin that prepends a selector to all rules:
<StyleSheetManager stylisPlugins={[myPrefixPlugin]}>
  <App />
</StyleSheetManager>

Approach 1 is simpler for individual components. Approach 2 is better if you need it globally.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@carpben
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by quantizor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants