addCustomCSS changes the style for all instances of the element
I am looking for a way to change the CSS properties of 'ui5-button'. I am using the ui5-button component in 2 locations in my React App. I want to change different CSS properties for each occurrence of the ui5-button.
Currently when i say
addCustomCSS('ui5-button', 'sap_belize_hcb', .sapMBtn { background-color: var(--sapAccentColor4) !important})
it changes the background-color of all the ui5-buttons on the page. Is there a way to change the style for a specific instance of the button ?
Hello @akshaykmr080
In general, if you add a class to the ui5-button you want to change, you can alter the CSS variable, that defines its background colour, then only that button would change.
https://codesandbox.io/s/0on8215xnl?fontsize=14&module=%2Findex.html
.special {
--sapUiButtonBackground: red;
}
<ui5-button class=“special”>press me</ui5-button> // would be changed
<ui5-button>press me</ui5-button> // would not be changed
Written this way, would mean the CSS Variable "--sapUiButtonBackground" would be "red" in all themes. Do you need to change the background for this particular button only in HCB?
And a question from my side - do you need IE 11 support :D
Thanks a lot for resolving the issue. Yes, i do need IE 11 support