Skip to content

Commit 4de4e07

Browse files
committed
docs: add forced colors mode section & simplify SB forced-color-adjust rule
1 parent c296cac commit 4de4e07

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

.storybook/preview-head.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<style>
2-
html[data-sap-theme]:not([data-sap-theme*='hc']),
3-
/*fallback*/
4-
html:not([data-sap-theme]) {
5-
forced-color-adjust: none;
2+
@media (forced-colors: active) {
3+
html {
4+
forced-color-adjust: none;
5+
}
66
}
77

88
body {

docs/knowledge-base/Styling.mdx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ Components currently only available in the `ui5/webcomponents-react` repo, are n
2929
`@ui5/webcomponents` components come with globally applied scrollbar styles.
3030
If you want to opt-out of this behavior, you can add the `.ui5-content-native-scrollbars` class to the `body` of the page. You can find out more about this in the [ui5/webcomponents documentation](https://ui5.github.io/webcomponents/docs/advanced/scrollbars-customization/).
3131

32+
## Forced Colors Mode
33+
34+
In [forced colors mode](https://developer.mozilla.org/en-US/docs/Web/CSS/forced-color-adjust) (e.g. Windows High Contrast), the user agent automatically overrides component colors to meet accessibility needs.
35+
If you need to opt out of this behavior for specific elements, you can use the `forced-color-adjust` CSS property:
36+
37+
```css
38+
html {
39+
forced-color-adjust: none;
40+
}
41+
```
42+
43+
By setting `forced-color-adjust` to `none`, the element's colors will not be adjusted by the user agent in forced colors mode.
44+
You can also scope this to individual components instead of the entire page. Wrapping the rule in a `@media (forced-colors: active)` query is functionally equivalent, but makes the intent more explicit in your code:
45+
46+
```css
47+
@media (forced-colors: active) {
48+
.myComponent {
49+
forced-color-adjust: none;
50+
}
51+
}
52+
```
53+
3254
## Changing CSS Variables
3355

3456
You can override SAP theming CSS variables on specific web component selectors to customize their appearance:

0 commit comments

Comments
 (0)