Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding prefix to generic .row and .col-* classes #157

Open
7mllm7 opened this issue Aug 15, 2018 · 2 comments
Open

Adding prefix to generic .row and .col-* classes #157

7mllm7 opened this issue Aug 15, 2018 · 2 comments

Comments

@7mllm7
Copy link

7mllm7 commented Aug 15, 2018

Hi,

Love this repo, thanks! 馃憤

My app is a "embeddable bundle" / widget, that is given to others to embed inside their website. Imagine a JS script that is loaded in a hosting website, and that enables some UI capabilities.

The challenge for me here is to "prefix" my own .row and .col-* classes, imported by this module, in order to avoid conflicts with the hosting website's classes.
For example, if I don't do that, and a hosting website has their own style definition of .row, then either I or they will override each other's styles.
So I'd want all of this modules classes to become, for example, .my-module-row instead of .row, and therefore minimize the chance for styling overrides.

My React app is created with create-react-app, so don't have much control on my Webpack configuration.

Thanks!

@eemeli
Copy link
Contributor

eemeli commented Aug 15, 2018

The feature you're looking for is called CSS Modules. Would recommend that you play with that, and have a look at what the compiled output looks like. To get that to work in CRA, you may need to use its v2 (alpha) branch, available on npm under the next tag.

@7mllm7
Copy link
Author

7mllm7 commented Aug 22, 2018

Thanks for your reply.
So far I've tried either updating CRA or ejecting, neither worked - it looks like I'd need to convert my entire project to CSS modules, which is A LOT of work.

Problem is that I made sure to use unique class names for my own classes, but react-flexbox-grid's row, col-* etc. are very common.
Is there any way to switch to using CSS modules only for react-flexbox-grid, and keep the rest of my project intact?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants