Wrap responsive image styles in @layer astro.images to respect CSS cascade layers#17141
Merged
Conversation
…user layer styles
1 task
🦋 Changeset detectedLatest commit: 3b28996 The changes in this PR will be included in the next version bump. This PR includes changesets to release 409 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
I tried this and can confirm it works as expected. |
matthewp
approved these changes
Jun 23, 2026
Merged
dadezzz
pushed a commit
to dadezzz/university_notes
that referenced
this pull request
Jun 28, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [astro](https://astro.build) ([source](https://github.com/withastro/astro/tree/HEAD/packages/astro)) | [`7.0.0` → `7.0.2`](https://renovatebot.com/diffs/npm/astro/7.0.0/7.0.2) |  |  | --- ### Release Notes <details> <summary>withastro/astro (astro)</summary> ### [`v7.0.2`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#702) [Compare Source](https://github.com/withastro/astro/compare/astro@7.0.1...astro@7.0.2) ##### Patch Changes - Updated dependencies \[[`3b5e994`](withastro/astro@3b5e994)]: - [@​astrojs/markdown-satteri](https://github.com/astrojs/markdown-satteri)@​0.3.2 ### [`v7.0.1`](https://github.com/withastro/astro/blob/HEAD/packages/astro/CHANGELOG.md#701) [Compare Source](https://github.com/withastro/astro/compare/astro@7.0.0...astro@7.0.1) ##### Patch Changes - [#​17151](withastro/astro#17151) [`ccceda3`](withastro/astro@ccceda3) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `astro dev` incorrectly starting in background mode for Warp terminal users. Hybrid environments like Warp are no longer treated as AI agents for auto-background detection. - [#​17158](withastro/astro#17158) [`164df87`](withastro/astro@164df87) Thanks [@​ematipico](https://github.com/ematipico)! - Fixes `astro dev --background --host` not listing the network addresses. The background server start output and `astro dev status` now show every exposed network URL, matching the foreground dev server. - [#​17141](withastro/astro#17141) [`d785b9d`](withastro/astro@d785b9d) Thanks [@​astrobot-houston](https://github.com/astrobot-houston)! - Fixes responsive image CSS overriding user styles defined inside CSS `@layer` blocks. The generated image styles are now wrapped in `@layer astro.images`, ensuring they have lower cascade priority than user-defined layers. - [#​17150](withastro/astro#17150) [`1a61386`](withastro/astro@1a61386) Thanks [@​matthewp](https://github.com/matthewp)! - Fixes `astro dev --background` failing on Windows with "Failed to spawn background dev server process" </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](undefined) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMzQuMCIsInVwZGF0ZWRJblZlciI6IjQzLjIzNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17139
Changes
generateImageStylesCSS()in@layer astro.images { … }. Per the CSS cascade spec, unlayered styles always beat layered styles regardless of specificity — so the previous unlayered:where([data-astro-image=constrained]){max-width:100%}was silently overriding any usermax-widthdefined inside a@layer, even though:where()has zero specificity. Putting these defaults into a named layer restores the original intent of:where(): Astro's image styles should always be easy for users to override.astro.imagesuses a dotted namespace to avoid collisions with user-defined layer names while remaining valid for CSS processors (e.g. lightningcss).astro.imagessits below your own layers, declare the order explicitly:@layer astro.images, layout, page, components;. Without an explicit order declaration, the first-seen layer wins — which may or may not beastro.imagesdepending on stylesheet load order.Testing
packages/astro/test/units/assets/utils.test.tsto expect the@layer astro.images { … }wrapper around the generated CSS output.Docs
image.responsiveStylesis already documented as producing overridable defaults; this fix makes that promise actually true when users write CSS layers.