← Back to release summary

CSS Linked Parameters for External SVGs

Category
Miscellaneous
Type
New or changed feature
Status
Proposed (Chrome Proposed)
Intent stage
None

WPT details: Some WPT coverage already exists. Additional WPTs will be added as the Chromium implementation proceeds. https://wpt.fyi/results/css/css-link-params https://wpt.fyi/results/svg/styling/css-linked-parameters

Summary

External SVGs referenced by an element or a CSS image property cannot be styled by the page that references them. CSS Linked Parameters lets a page pass named CSS values into such an SVG, so one cached file can be reused with different themes. Parameters are declared with 'param(<dashed-ident>, <declaration-value>?)' and supplied through either the new link-parameters CSS property, a link parameter directive in the URL, or a param() modifier in url(). The SVG reads each one as a custom environment variable through env(), which also provides a fallback when no value is passed. For example, the page writes: img { link-parameters: param(--color, green); } and the SVG writes: circle { fill: env(--color, black); } The circle is green when the page supplies --color, and black otherwise.

Motivation

External SVGs loaded by an element or referenced through a CSS image property cannot be styled by the page that references them, so adapting an icon to a site's theme is difficult. Developers work around this by inlining the SVG, which bloats the document and prevents independent caching. Another developer workaround creates a copy of the file per theme variant, which duplicates assets and cache entries for what is logically one image. Yet another developer workaround fetches and rewrites the SVG using JavaScript, which adds complexity and can be blocked by CSP. CSS Linked Parameters address these gaps: a single cached SVG file renders differently at each reference, driven by parameters the page provides.

Standards & signals

Ecosystem

Docs: https://docs.google.com/document/d/1Dn0v19ljsQD8EKSxsAj2JhoG7DbK_Y3kZc7z8Fu36jg/edit?pli=1&tab=t.0#heading=h.b7buxfvoh942

Explainers: https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/SVG/CSSLinkedParameters/explainer.md

View on chromestatus.com