-
I have a React component that's injected into an existing page (using a Chrome extension). I'd like to style that component without affecting the page that it's being injected into. Using tailwind, is there a way to isolate the styles so that only the root component is affected by the tailwind styles? I believe at the moment setting the directives ( |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
If you are building via PostCSS, you could have a PostCSS plugin that runs after Tailwind that scopes every rule. |
Beta Was this translation helpful? Give feedback.
-
Although So I created a It allows you to scope an entire This is useful in my case because I'm developing a Chrome extension that injects a component into existing pages, but also has an extension popup and it's own page. In this case I was able to allow tailwind to reset styles globally. |
Beta Was this translation helpful? Give feedback.
Although
postcss-scopify
did help me in this situation, I wanted a bit more control.So I created a
postcss
plugin called postcss-scope.It allows you to scope an entire
css
file, including the tailwind directives. But it also allows you to specify files to ignore & allows you to override the selector per file.This is useful in my case because I'm developing a Chrome extension that injects a component into existing pages, but also has an extension popup and it's own page. In this case I was able to allow tailwind to reset styles globally.