Replies: 2 comments 4 replies
-
Layers is another possible solution to this problem. |
Beta Was this translation helpful? Give feedback.
4 replies
-
This proposal has been accepted and moved to stage 2! #540 The discussion has been summarized in the linked issue. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Body
Summary
Allow Astro styles to override global styles.
Background & Motivation
A common pattern in an application is to have some global styles in a global style file like so:
global.css
And then to use them in an Astro component.
The intent is to override the styles on this page (or component).
Due to chunking of shared dependencies, we cannot guarantee that CSS ordering will be correct. So we need a solution for this pattern.
Goals
Example
There are 2 solutions we have thought of so far:
Go back to non-
:where
selectors. This will cause a specificity bump of 1. So even if the styles are not ordered the way that you want, it will still cause Astro styles to override global styles.Provide a concept of "global styles". The user would mark some CSS files as being global (perhaps through configuration). We would bundle those styles into their own global bundle. it would always be placed before any page-specific styles.
An example of (2) might be:
Note that the above is only to illustrate the point! There is possibly another way other than configuration to achieve this.
Beta Was this translation helpful? Give feedback.
All reactions