question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

styling of ui5 webcomponents

See original GitHub issue

I would like to override some of the classes. e.g .sapWCSelect As Chrome decided to remove support of shadow-dom css selectors and /deep/ and ::shadow are not an option.

What would be the best way of styling an ui5-webcomponent?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
MapTo0commented, Apr 12, 2019

Hello @DamianLion

For now you can use the addCustomCSS as:

import "@ui5/webcomponents/dist/Select";
import { addCustomCSS } from "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/theming/CustomStyle";

addCustomCSS("ui5-select", "sap_fiori_3", `.sapWCSelect {
  height: 35px;
  border-radius: 4px;
}`);

from v0.10.0 we will change the base imports by removing /sap/ui/webcomponents/base/

0.9.0 "@ui5/webcomponents-base/src/sap/ui/webcomponents/base/theming/CustomStyle"

0.10.0 "@ui5/webcomponents-base/src/theming/CustomStyle"

We are currently reworking the theming and we will provide a better overstyling for the future. I will keep this open as we have some more work to do.

Regards!

1reaction
MapTo0commented, Jul 24, 2019

Hello all,

We did quite a lot of work in that direction:

Styling Root

Styling components using CSS on root - you can now style most of the components (for which it makes sense ofcourse) on root level

e.g. <ui5-input style="height: 200px; width: 10px; border: 1px solid blue"></ui5-input>

CSS Variables

We expose some `CSS custom properties for some parts of the components which make sense to have a public API

e.g. --ui5-panel-background-color of the ui5-panel

CSS Shadow Parts

CSS Shadow parts is not yet implemented in all major browsers, but we believe that this is the right direction for styling parts of Shadow DOM. Therefore, we provide some of parts of our composite components as an API. e.g. ui5-card - status part

ui5-card.online::part(status) {
  color: green;
  font-size: 2rem;
}

We are working on a polyfill until we got a full browser support on that feature. The polyfill is still in a review stage, but I believe it will be out for some testing and feedback very soon: https://github.com/SAP/ui5-webcomponents/pull/609

Global Theming

As all of our components are working with CSS Custom Variables we are also working in the direction of providing a way to make your own theme using a tool such as the SAP Theme Designer. So stay tuned!

If you have any other feedback or proposals feel free to contact us!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add Custom Styles and Components for UI5 Web ...
In this tutorial, you will learn how to apply styling to the UI5 Web Components. You can add custom styles and even overwrite...
Read more >
Developing Custom UI5 Web Components - SAP
Developing Custom UI5 Web Components. Note: All examples in this tutorial are taken from the Demo UI5 Web Component ( ui5-demo ), generated...
Read more >
Ui5 Webcomponents Theme Change - StackBlitz
A run-time theme change example for ui5-webcomponents. ... import '@ui5/webcomponents/dist/RadioButton'; ... document.body.style.backgroundColor = "#000";.
Read more >
Why cant I customize the styling of web component libraries ...
Not the answer you're looking for? Browse other questions tagged. javascript · html · reactjs · web-component · ui5-webcomponents. or ask your ...
Read more >
UI5 Web Components: Build Enterprise Ready UIs ... - YouTube
In this session we will explore the UI5 Web Components – the latest SAP UI Open Source offering. UI5 Web Components are lightweight...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found