Skip to content

feat(framework): move CSS variables to host element#12984

Merged
nnaydenow merged 3 commits intomainfrom
css-vars-host-part-2
Jan 29, 2026
Merged

feat(framework): move CSS variables to host element#12984
nnaydenow merged 3 commits intomainfrom
css-vars-host-part-2

Conversation

@nnaydenow
Copy link
Contributor

@nnaydenow nnaydenow commented Jan 29, 2026

With this PR, all component CSS variables are defined on the host element. This enables overriding --sap variables in a specific context.

For example:

<div style="--sapField_Background: red;">
   ...
</div>

In this case, --sapField_Background: red overrides the background of all fields within that context.

Also fixed in this PR:

  • Move CSS variable declarations from :root to :host
  • Replace density-aware selectors ([data-ui5-compact-size], .ui5-content-density-compact, .sapUiSizeCompact) with a container query:
    @container style(--ui5_content_density: compact) {
      :host { ... }
    }
  • Remove usage of getScopedVarName when components define CSS variables on the host with JavaScript
  • Revise overrides of --ui5-* variables (e.g. ui5-button overrides inside ui5-shellbar)
  • Fix several minor issues with incorrect style overrides
  • Add a test that verifies the correct values are applied based on content density

Follow-up to: #12928
Fixes: #12791

@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Jan 29, 2026

🧹 Preview deployment cleaned up: https://pr-12984--ui5-webcomponents.netlify.app

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 29, 2026 08:42 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 29, 2026 09:47 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 29, 2026 12:13 Inactive
@nnaydenow nnaydenow changed the title chore: move variables from root to host element chore: move CSS variables from root to host element Jan 29, 2026
@nnaydenow nnaydenow changed the title chore: move CSS variables from root to host element feat(framework): move CSS variables to host element Jan 29, 2026
@nnaydenow nnaydenow merged commit 3bd2b4a into main Jan 29, 2026
21 of 22 checks passed
@nnaydenow nnaydenow deleted the css-vars-host-part-2 branch January 29, 2026 14:47
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview January 29, 2026 14:47 Inactive
@ui5-webcomponents-bot
Copy link
Collaborator

🎉 This PR is included in version v2.19.0-rc.3 🎉

The release is available on v2.19.0-rc.3

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Move CSS Variables from :root to components shadow DOM

3 participants