chore(framework): apply css variables on custom element#12928
Merged
chore(framework): apply css variables on custom element#12928
Conversation
Collaborator
|
🧹 Preview deployment cleaned up: https://pr-12928--ui5-webcomponents.netlify.app |
pskelin
approved these changes
Jan 27, 2026
This was referenced Jan 28, 2026
Open
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.
Enable customization of --sap* theming CSS variables at the component level (part one: style preparation and loading mechanism).
Example:
To support all use cases, internal --ui5* CSS variables must be defined on the custom element using the
:hostselector, not on the document using the:rootselector.For the same reason, all content density–related variables and direction-related variables must also be defined on
:host.Direction-related variables are now set using the
:dir()selector.For content density–related variables, there was no fully working solution before. CSS container style queries are not fully supported, and the classes and attributes used by application developers are applied outside the shadow root. This PR adds a mechanism to handle this. CSS container style queries are now used and, at build time, they are transpiled into a working solution.
To define variables, use the following syntax:
All of this behavior is controlled by the
cssVariablesTargetflag (accepted values:"host"and"root"). The flag is configured at the package level viapackage-script.js.When this flag is enabled, all
*-parameters.cssfiles must be migrated to define variables on:hostinstead of:root.For direction-related CSS variables, the
:dir()selector is used. For content density–related variables, the new container style query syntax is used.Since CSS variables are now defined at the component level, CSS variable scoping is no longer needed. As a result, the
getScopedVarNamefunction is no longer required.Fixes: #12791