feat(theming): add OS-adaptive auto themes (sap_horizon_auto, sap_horizon_hc_auto)#13300
Merged
feat(theming): add OS-adaptive auto themes (sap_horizon_auto, sap_horizon_hc_auto)#13300
Conversation
…themes
Add auto-switching themes that adapt to the user's OS light/dark preference
using CSS light-dark() for color values and space toggles for non-color values.
At build time, the light and dark theme CSS outputs are merged into a single
stylesheet. Color variables use the native CSS light-dark() function (Chrome 123+,
Firefox 120+, Safari 17.5+). Non-color variables use the space toggle pattern
with guaranteed-invalid custom properties, the same approach already used for
cozy/compact density switching.
The auto theme is self-contained: switching away from it removes the toggles.
No runtime code changes needed — it is purely CSS-driven.
Usage:
- URL: ?sap-ui-theme=sap_horizon_auto
- JS: setTheme("sap_horizon_auto")
- Config: <script data-ui5-config>{"theme":"sap_horizon_auto"}</script>
Collaborator
|
🧹 Preview deployment cleaned up: https://pr-13300--ui5-webcomponents.netlify.app |
…ptive themes Merge HCW (light) and HCB (dark) high contrast themes using the same light-dark() and space toggle mechanism as the existing auto themes, enabling automatic switching based on OS prefers-color-scheme.
Remove sap_fiori_3_auto and sap_fiori_3_hc_auto to reduce scope. Only sap_horizon_auto and sap_horizon_hc_auto are generated.
pskelin
approved these changes
Mar 19, 2026
Collaborator
|
🎉 This PR is included in version v2.21.0-rc.2 🎉 The release is available on v2.21.0-rc.2 Your semantic-release bot 📦🚀 |
Collaborator
|
🎉 This PR is included in version v2.21.0 🎉 The release is available on v2.21.0 Your semantic-release bot 📦🚀 |
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.
Summary
sap_horizon_autotheme that automatically switches between light and dark based on the user's OS preferencesap_horizon_hc_autotheme that automatically switches between high contrast white (HCW) and high contrast black (HCB)light-dark()for color values and space toggles for non-color values — purely CSS-driven, no runtime changesHow it works
At build time, the existing light and dark theme CSS outputs are merged into a single stylesheet:
light-dark(lightVal, darkVal)(native CSS function)--_ui5-light-scheme/--_ui5-dark-scheme(same guaranteed-invalid trick as cozy/compact density):rootoutput getscolor-scheme: light darkand a@media (prefers-color-scheme: dark)rule to flip the togglesThe same mechanism applies to high contrast themes — HCW maps to light mode, HCB maps to dark mode.
Usage
Theme pairs
sap_horizon_autosap_horizonsap_horizon_darksap_horizon_hc_autosap_horizon_hcwsap_horizon_hcbFiles changed
packages/tools/assets-meta.js— register new theme namespackages/tools/lib/css-processors/css-processor-themes.mjs— merge light+dark after processing, add toggle setup for theming packagepackages/tools/lib/css-processors/merge-light-dark.mjs— new: merge two CSS strings usinglight-dark()and space togglesparameters-bundle.cssfiles — enable theme directory discovery by the build systemTest plan
yarn generate && yarn startthen open?sap-ui-theme=sap_horizon_auto?sap-ui-theme=sap_horizon_hc_autoswitches between HCW/HCB based on OS color schemesap_horizon) removes the auto behavior