Use CSS files for Global styles #324
-
Is it possible to create global styles with stylex so I can have reset styles? (similar to |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Use a CSS file for this. StyleX is encapsulated component styles only. And global styles should never be shared with components, as they break encapsulation. |
Beta Was this translation helpful? Give feedback.
-
@nmn Does Facebook use some global styles or reset or both? Thank you |
Beta Was this translation helpful? Give feedback.
-
This issue has been discussed a couple of times before. From what I understand this library was originally developed for Meta apps, which are based on components. So, the way of thinking -as far as I understand- is that all styles should be declared or overridden at a component scope. From my short experience so far, this works very well... until you want to set styles for commonly used elements like For example, you need to tell every
I find option 2 to be a bit too much, especially when those elements may be retrieved from an API (text editor). On the other hand, option 1 is not a complete disaster; but in case you make a change to your design system you have to remember to update those values in the I assume in facbook.com everything is a component but there is also some global styles like fonts. |
Beta Was this translation helpful? Give feedback.
Use a CSS file for this. StyleX is encapsulated component styles only. And global styles should never be shared with components, as they break encapsulation.