René's URL Explorer Experiment


Title: provideCssVarNamespacing() breaks styling of third-party libraries themed by global CSS variables · Issue #70064 · angular/angular · GitHub

Open Graph Title: provideCssVarNamespacing() breaks styling of third-party libraries themed by global CSS variables · Issue #70064 · angular/angular

X Title: provideCssVarNamespacing() breaks styling of third-party libraries themed by global CSS variables · Issue #70064 · angular/angular

Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description #68846 CSS Variables namespacing, introduced in v22.1.0, rewrites custom property references inside a component's styles unconditionally...

Open Graph Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description #68846 CSS Variables namespacing, introduced in v22.1.0, rewrites custom property references ins...

X Description: Which @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description #68846 CSS Variables namespacing, introduced in v22.1.0, rewrites custom property references ins...

Opengraph URL: https://github.com/angular/angular/issues/70064

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"provideCssVarNamespacing() breaks styling of third-party libraries themed by global CSS variables","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\ncompiler\n\n### Is this a regression?\n\nNo\n\n### Description\n\n- https://github.com/angular/angular/pull/68846\n\nCSS Variables namespacing, introduced in v22.1.0, rewrites custom property references inside a component's `styles` unconditionally, while global stylesheets are left alone by design. For a library published with partial compilation that rewrite does not happen when the library is built. It happens during the **consuming application's** build, with the consumer's namespace.\n\nAs a result, calling `provideCssVarNamespacing()` breaks any third-party library that exposes theming through custom properties defined in a global stylesheet, which is the usual way libraries do it. Angular Material ends up completely unstyled.\n\nWith `provideCssVarNamespacing()`:\n\n\u003cimg width=\"620\" alt=\"with provideCssVarNamespacing\" src=\"https://raw.githubusercontent.com/lacolaco/angular-cssvar-namespacing-library-repro/main/screenshots/namespacing-on.png\" />\n\nWithout:\n\n\u003cimg width=\"620\" alt=\"without provideCssVarNamespacing\" src=\"https://raw.githubusercontent.com/lacolaco/angular-cssvar-namespacing-library-repro/main/screenshots/namespacing-off.png\" />\n\nWith `@angular/material` and the prebuilt `azure-blue` theme, a plain `\u003cbutton matButton=\"filled\">`:\n\n| computed | with `provideCssVarNamespacing()` | without |\n| --- | --- | --- |\n| `background-color` | `rgba(0, 0, 0, 0)` | `rgb(0, 92, 187)` |\n| `color` | `rgb(0, 0, 0)` | `rgb(255, 255, 255)` |\n| `border-radius` | `0px` | `9999px` |\n\nThe theme defines its tokens in the global stylesheet and the components reference them, so the two sides end up under different names:\n\n```\n$ grep -o -- \"--mat-sys-[a-z-]*:\" node_modules/@angular/material/prebuilt-themes/azure-blue.css | sort -u | wc -l\n157\n\n$ grep -o -- \"var(--mat-\" node_modules/@angular/material/fesm2022/button.mjs | wc -l\n832\n```\n\n```js\ngetComputedStyle(document.documentElement).getPropertyValue('--mat-sys-primary')       // \"#005cbb\"\ngetComputedStyle(document.documentElement).getPropertyValue('--myapp_mat-sys-primary') // \"\"\n```\n\nThis is not specific to Material. A minimal library component with `color: var(--brand)` is published as\n\n```js\n// dist/ui/fesm2022/ui.mjs\nstyles: [\"#lib{color:var(--brand);border:2px solid var(--brand);...}\"]\n```\n\nand comes out of the consuming application's build as\n\n```\n#lib[_ngcontent-%COMP%]{color:var(--%NS%brand)}\n```\n\nbecause `PartialComponentLinkerVersion1.linkPartialDeclaration` re-runs `compileComponentFromMetadata`, which applies `namespaceCssVariables` to `styles` unconditionally (`packages/compiler/src/render3/view/compiler.ts`).\n\n`--global--` is the designed opt-out, but it only helps in source you control. A library would have to spell every one of its tokens `--global--…` to defend itself against a decision its consumers make, and libraries published before v22.1 obviously cannot. A consuming application has no way to apply the opt-out to a dependency.\n\nSteps to reproduce:\n\n1. `ng new` an application on 22.1\n2. `npm i @angular/material @angular/cdk` and add `node_modules/@angular/material/prebuilt-themes/azure-blue.css` to the `styles` array in `angular.json`\n3. put `\u003cbutton matButton=\"filled\">Filled button\u003c/button>` in the template\n4. add `provideCssVarNamespacing()` to `appConfig.providers`\n5. build and open the page\n\n### Please provide a link to a minimal reproduction of the bug\n\nhttps://github.com/lacolaco/angular-cssvar-namespacing-library-repro\n\n### Please provide the exception or error you saw\n\n```true\nNo errors. The declarations are silently dropped.\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\nAngular CLI       : 22.1.2\nAngular           : 22.1.0\nNode.js           : 22.22.3\nPackage Manager   : npm 10.9.8\nOperating System  : darwin arm64\n\n┌───────────────────────────┬───────────────────┬───────────────────┐\n│ Package                   │ Installed Version │ Requested Version │\n├───────────────────────────┼───────────────────┼───────────────────┤\n│ @angular/build            │ 22.1.2            │ ^22.1.2           │\n│ @angular/cdk              │ 22.1.0            │ ^22.1.0           │\n│ @angular/cli              │ 22.1.2            │ ^22.1.2           │\n│ @angular/common           │ 22.1.0            │ ^22.1.0           │\n│ @angular/compiler         │ 22.1.0            │ ^22.1.0           │\n│ @angular/compiler-cli     │ 22.1.0            │ ^22.1.0           │\n│ @angular/core             │ 22.1.0            │ ^22.1.0           │\n│ @angular/forms            │ 22.1.0            │ ^22.1.0           │\n│ @angular/material         │ 22.1.0            │ ^22.1.0           │\n│ @angular/platform-browser │ 22.1.0            │ ^22.1.0           │\n│ @angular/router           │ 22.1.0            │ ^22.1.0           │\n│ ng-packagr                │ 22.1.0            │ ^22.1.0           │\n│ rxjs                      │ 7.8.2             │ ~7.8.0            │\n│ typescript                │ 6.0.3             │ ~6.0.2            │\n└───────────────────────────┴───────────────────┴───────────────────┘\n```\n\n### Anything else?\n\nFor context on prior art, in case this reads as already known: the closest discussion I found is #67362, where the mismatch between a `var()` reference and a declaration living in a global stylesheet was raised, and `--global--` was chosen as the answer.\n\nWhat doesn't appear in either PR is the distribution dimension. Neither discussion mentions partial compilation, the linker, or npm packages, and the single sentence about libraries in the description is about using `CssVarNamespacer` for JS references rather than a library's own `styles`. `--global--` only helps in source the author controls, which is what makes this case different from an application namespacing itself. I can't see the internal design doc linked from #67362, so this may well have been considered there.\n\nIf the answer here is that libraries need to adopt `--global--` for their tokens, then adopting this feature is gated on an ecosystem-wide source change rather than on an application-level provider. Every library published before 22.1 is incompatible with any consumer that turns the flag on, there is no version constraint or diagnostic that surfaces it, and the failure mode is styles silently not applying. That seems like a larger coordination problem than a minor release can carry. `--global-` with a single hyphen is already slated to become an error in v23, so parts of this are on a major track anyway.\n\nIt also seems worth asking whether linked library styles should be namespaced at all. The namespace is application-scoped (it defaults to `APP_ID`), so rewriting a dependency's `styles` during the consuming application's link step is a choice rather than a consequence. Leaving them alone would still give the feature what it is after, an application's own variables no longer colliding with another application's on the same page, while keeping libraries working.\n","author":{"url":"https://github.com/lacolaco","@type":"Person","name":"lacolaco"},"datePublished":"2026-08-04T05:51:28Z","url":"https://github.com/angular/angular/issues/70064"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d2234bb3-7ab8-04a6-3283-9e301202045d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id95C4:842EC:2F0AC90:3EBE328:6B01E151
html-safe-nonced470e0323e3689af8efa44efd892a8e901a43065d39327ad62c34507e15ab10f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUM0Ojg0MkVDOjJGMEFDOTA6M0VCRTMyODo2QjAxRTE1MSIsInZpc2l0b3JfaWQiOiI1NjYxMjYzNDM5MDkyMzc1ODkwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmaced168fdfdbb9140b5382e4b474af7fac1c225592e0c74d0c72a6ca6ac805d33b
hovercard-subject-tagissue:5057200099
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/70064/issue_layout
twitter:imagehttps://opengraph.githubassets.com/65c8b1833fe426f06da6247b7e5b5c0d3d5a0a5f4b4b7dc6317fcae897efcf56/angular/angular/issues/70064
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/65c8b1833fe426f06da6247b7e5b5c0d3d5a0a5f4b4b7dc6317fcae897efcf56/angular/angular/issues/70064
og:image:altWhich @angular/* package(s) are the source of the bug? compiler Is this a regression? No Description #68846 CSS Variables namespacing, introduced in v22.1.0, rewrites custom property references ins...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelacolaco
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/angular/angular git https://github.com/angular/angular.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id24195339
octolytics-dimension-repository_nwoangular/angular
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id24195339
octolytics-dimension-repository_network_root_nwoangular/angular
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angular/issues/70064#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F70064
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangular%2Fissues%2F70064
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangular
Reloadhttps://github.com/angular/angular/issues/70064
Reloadhttps://github.com/angular/angular/issues/70064
Reloadhttps://github.com/angular/angular/issues/70064
angularhttps://github.com/angular
angularhttps://github.com/angular/angular
Codehttps://github.com/angular/angular
Issues835 (835)https://github.com/angular/angular/issues
Pull requests142 (142)https://github.com/angular/angular/pulls
Discussionshttps://github.com/angular/angular/discussions
Actionshttps://github.com/angular/angular/actions
Projectshttps://github.com/angular/angular/projects
Security and quality40 (40)https://github.com/angular/angular/security
Insightshttps://github.com/angular/angular/insights
https://github.com/angular/angular
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/70064
New issuehttps://github.com/login?return_to=https://github.com/angular/angular/issues/70064
provideCssVarNamespacing() breaks styling of third-party libraries themed by global CSS variableshttps://github.com/angular/angular/issues/70064#top
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
core: CSS encapsulationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20CSS%20encapsulation%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
Backloghttps://github.com/angular/angular/milestone/82
https://github.com/lacolaco
lacolacohttps://github.com/lacolaco
on Aug 4, 2026https://github.com/angular/angular/issues/70064#issue-5057200099
CSS Variable Namespacing #68846https://github.com/angular/angular/pull/68846
https://raw.githubusercontent.com/lacolaco/angular-cssvar-namespacing-library-repro/main/screenshots/namespacing-on.png
https://raw.githubusercontent.com/lacolaco/angular-cssvar-namespacing-library-repro/main/screenshots/namespacing-off.png
https://github.com/lacolaco/angular-cssvar-namespacing-library-reprohttps://github.com/lacolaco/angular-cssvar-namespacing-library-repro
#67362https://github.com/angular/angular/pull/67362
#67362https://github.com/angular/angular/pull/67362
angular-robothttps://github.com/apps/angular-robot
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
gemini-triagedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Aug 4, 2026https://github.com/angular/angular/issues/70064#event-28929684810
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
on Aug 4, 2026https://github.com/angular/angular/issues/70064#event-28929685716
angular-robothttps://github.com/apps/angular-robot
needsTriagehttps://github.com/angular/angular/milestone/83
on Aug 4, 2026https://github.com/angular/angular/issues/70064#event-28929685787
angularhttps://github.com/angular
https://github.com/undefined
on Aug 4, 2026https://github.com/angular/angular/issues/70064#event-28967053295
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001263673
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001264517
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001265712
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001266759
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001267766
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001268910
angularhttps://github.com/angular
https://github.com/undefined
on Aug 5, 2026https://github.com/angular/angular/issues/70064#event-29001269951
JeanMechehttps://github.com/JeanMeche
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
gemini-triagedhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22gemini-triaged%22
on Aug 12, 2026https://github.com/angular/angular/issues/70064#event-29365823635
ngbothttps://github.com/apps/ngbot
needsTriagehttps://github.com/angular/angular/milestone/83
Backloghttps://github.com/angular/angular/milestone/82
on Aug 12, 2026https://github.com/angular/angular/issues/70064#event-29365824902
splincodehttps://github.com/splincode
on Sep 17, 2026https://github.com/angular/angular/issues/70064#event-31343640018
fix(compiler): preserve library CSS variable nameshttps://github.com/splincode/angular/commit/d8a6de2404170788a3da429178ab095b0b9770f9
https://docs.github.com/articles/closing-issues-via-commit-messages
d8a6de2https://github.com/splincode/angular/commit/d8a6de2404170788a3da429178ab095b0b9770f9
https://github.com/splincode
splincodehttps://github.com/splincode
on Sep 21, 2026https://github.com/angular/angular/issues/70064#issuecomment-5765958264
@JeanMechehttps://github.com/JeanMeche
#70477https://github.com/angular/angular/pull/70477
mattrbeckhttps://github.com/mattrbeck
core: CSS encapsulationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20CSS%20encapsulation%22
on Sep 29, 2026https://github.com/angular/angular/issues/70064#event-32096727468
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angular/issues/70064
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angular/issues/70064
area: compilerIssues related to `ngc`, Angular's template compilerhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22area%3A%20compiler%22
core: CSS encapsulationhttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22core%3A%20CSS%20encapsulation%22
featureLabel used to distinguish feature request from other issueshttps://github.com/angular/angular/issues?q=state%3Aopen%20label%3A%22feature%22
BacklogNo due datehttps://github.com/angular/angular/milestone/82
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.