[SF][Text]: external styles not working on Text components
Describe the bug
When we add css styles through className property of Text component, the added styles are overridden by Text internal styles.
Isolated Example
https://stackblitz.com/edit/github-fwkd41-detgpv
Reproduction steps
- Go to stackblitz exmaple.
- Inspect the text element with styles added.
- See the added styles are overridden by internal styles.
Expected Behaviour
External styles should work properly on Text component.
Screenshots or Videos
UI5 Web Components for React Version
1.26.0
UI5 Web Components Version
1.23.1
Browser
Chrome
Operating System
MacOS
Additional Context
No response
Relevant log output
No response
Organization
No response
Declaration
- [X] I’m not disclosing any internal or sensitive information.
Hi @ksblklu
many of our components are still using react-jss for styling. Since these sources are created after css modules, they have precedence. We're currently in the process of refactoring all components to use css modules, but since this has not a high priority for us and "base" components like Text need to be the last components to be updated, it's best if you use a selector with a higher specificity (example).
Please also note that although we offer a way to overstyle components, internal styles are not subject to semantic versioning. So they can change without notice, which can lead to strange behavior when overstyling components without proper visual tests.
Hi @Lukas742 Thanks for the information, I'll use higher priority selectors to override the component styles as temporary solution.
Great :)
We'll keep the issue open until the Text is using css modules as well.
Hi @ksblklu
with v1.28.0, you can now more easily override internal styles of @ui5/webcomponents-react components. You can find more information about this here.
Please note, that if you're using Vite, to not import the static files inside the main.tsx file, as they would then be added last and therefore would override styles with the same specificity. Example