You just handle it the same way you handle any shared code. You can keep files in a file scope, in a package / folder scope, or in the top-level global scope (in a small app that's totally fine). But removing globals-by-default removes a lot of "gotcha's" from working with CSS.
Why don't you write all your applications code in a global scope and just use a BEM-like naming scheme for your functions?
[0]: http://getbem.com/
[1]: https://medium.com/@jdan/css-is-fine-its-just-really-hard-63...
The framework scope has all the composeable classes and standard forms like lists, shadows, colors, grids, cards etc.
Then, when the framework doesn't cover everything, I use component scoped css to complete it, without having to worry about a naming scheme like BEM. It just makes things easier when you have css that is really only relevant to one component. Just like programming, I can always make the code abstract and move it up to the framework.
I do the exact same thing (I don't use BEM either) by isolating specific component styling to it's own SASS file.
As for css-in-js, there isn't much of an advantage to using it vs importing sass files as scoped.
With Sass you get:
- Familiare Syntax
- Avoids inline styles
- All benefits of the Sass community
vs with css-in-js you primarily gain:
- Dynamic and regular styles together
- One less compiler dependency
- Benefits of full JS for style generation
So I think this really depends on the project and your preference, I don't think there's a massive benefit either way.
You can totally create a style library and include pieces of it as mixins for the styles of each component.
Or until your designer wants the corporate website and the internal dashboard to have buttons that look different.
The idea that "globals" in CSS are bad is counter intuitive to my experience that globals in CSS encourage consistency
Maybe when you're facebook size and you have many product teams all expected to produce something that all works together - I can see how the global namespace would be impossible to manage. For your average website or app? Not even close. It'll be awhile before you run into the limitations of CSS that Facebook is running into.