You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/knowledge-base/Styling.mdx
+38-14Lines changed: 38 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,36 +19,44 @@ You can apply CSS variables, use the `::part` pseudo-element selectors, or apply
19
19
Components currently only available in the `ui5/webcomponents-react` repo, are not necessarily web components. For these kind of components you can follow the standard styling approach of React.
20
20
21
21
<MessageStrip
22
-
design={MessageStripDesign.Critical}
23
-
hideCloseButton
24
-
children="While it's easily possible targeting DOM elements and CSS classes of components without a shadow root, modifying internal structures or styles is not officially supported and may break with future updates. Use such changes carefully."
22
+
design={MessageStripDesign.Critical}
23
+
hideCloseButton
24
+
children="While it's easily possible targeting DOM elements and CSS classes of components without a shadow root, modifying internal structures or styles is not officially supported and may break with future updates. Use such changes carefully."
25
25
/>
26
26
27
27
## Scrollbars
28
28
29
29
`@ui5/webcomponents` components come with globally applied scrollbar styles.
30
30
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/).
31
31
32
-
## Style your own components
32
+
## Changing CSS Variables
33
+
34
+
You can override SAP theming CSS variables on specific web component selectors to customize their appearance:
35
+
36
+
```css
37
+
[ui5-button] {
38
+
--sapButton_TextColor: purple;
39
+
}
40
+
```
33
41
34
-
It's quite likely you have to create some custom components when you are building an app.
35
-
In order to reuse our central styling approach, you can import the `ThemingParameters` that contain the various CSS variables used in our theming, or use the CSS variables directly.
42
+
<MessageStrip
43
+
design={MessageStripDesign.Information}
44
+
hideCloseButton
45
+
children="Whenever possible, override CSS variables through the SAP UI Theme Designer for consistent updates across all components."
46
+
/>
36
47
37
-
A full list of all supported CSS Variables can be found [here](https://github.com/UI5/webcomponents-react/blob/main/packages/base/src/styling/ThemingParameters.ts)
38
-
or in the [theming-base-content](https://github.com/SAP/theming-base-content/tree/master/content/Base/baseLib) repo.
48
+
## Style your own components
39
49
40
-
You can then create a custom component by following this recipe:
50
+
When building custom components, use SAP CSS variables directly to stay consistent with the Fiori design system.
51
+
A full list of all supported CSS variables can be found in the [theming-base-content](https://github.com/SAP/theming-base-content/tree/master/content/Base/baseLib) repo.
If you need to access CSS variable values in JavaScript, you can use [ThemingParameters](https://ui5.github.io/webcomponents-react/v2/?path=/docs/knowledge-base-public-utils--docs#theming-parameters) as well:
Almost all components allow setting `className` or `style` for custom styling. For standard elements like `div`, `span`, etc., you can easily override internal CSS properties and values, as our styles are encapsulated in a [CSS layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer).
77
91
For web components, this does **not** mean that styles are inherited by shadow root elements per default.
78
92
Only [inherited CSS properties](https://developer.mozilla.org/en-US/docs/Web/CSS/inheritance#inherited_properties) that are not set inside the shadow root or internally passed properties will change the styles of the internal elements.
79
-
Another special case are abstract components like the `SuggestionItem`. The `ui5-suggestion-item` element is mainly there to pass props to the actual component inside the shadow root and is therefore not stylable.
93
+
Another special case are [abstract](http://localhost:6007/?path=/docs/knowledge-base-faq--docs#what-are-abstract-ui5-web-components) components like the `SuggestionItem`. The `ui5-suggestion-item` element is mainly there to pass props to the actual component inside the shadow root and is therefore not stylable.
80
94
81
95
## Explicitly import CSS bundles
82
96
@@ -142,6 +156,16 @@ function MyComponent() {
142
156
143
157
</details>
144
158
159
+
## CSS Custom States
160
+
161
+
Some components expose custom states that you can target with the `:state()` pseudo-class for conditional styling:
162
+
163
+
```css
164
+
[ui5-toolbar-item]:state(overflowed) {
165
+
flex-direction: column;
166
+
}
167
+
```
168
+
145
169
## Common CSS
146
170
147
171
For applying common styling blocks based on SAP Fiori Design Guidelines, we recommend using the [@sap-ui/common-css](https://www.npmjs.com/package/@sap-ui/common-css) package. You can find out more about this [here](?path=/docs/knowledge-base-common-css--docs).
0 commit comments