bug: user styles are not overriding scoped components
See original GitHub issueBug Report
Ionic version: 4.x
Current behavior: Try to override a card using the following:
ion-card {
font-size: 40px;
}
See that nothing changes
Expected behavior: User styles should take precedence over scoped styles, I believe this used to work. Now we have to write the following:
ion-card {
font-size: 40px !important;
}
We shouldn’t have to use !important
to override Ionic styles.
Steps to reproduce: See the following Codepen: https://codepen.io/brandyscarney/pen/xMpqgG
Remove the !important
s.
Ionic info:
Ionic 4.0.1
Here’s a full list of scoped components affected:
action-sheet
alert
back-button
buttons
card
input
label
loading
modal
picker
popover
searchbar
segment
select-popover
textarea
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Scoped Styles are always overwritten - css - Stack Overflow
Question: The profile.vue styles keep overriding the ones from sidebar.vue . The sidebar should keep it's red background with this setting, ...
Read more >Scoped style does not work with multi-root child components
The scoped data property is only inherited onto single root nodes because the intended use case is to add layout styles for that...
Read more >272653 - Scoped styles are not obeying CSS specificity rules
Issue 272653: Scoped styles are not obeying CSS specificity rules · 1. Create a scoped style underneath the body tag · 2. Create...
Read more >Overriding Child Component Styles — The Right Way
Overriding Child Component Styles — The Right Way ... Scoped CSS is fantastic for keeping things tidy, and not accidentally bleeding styles into...
Read more >scope - CSS: Cascading Style Sheets - MDN Web Docs
The :scope CSS pseudo-class represents elements that are a reference point for selectors to match against.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see, that makes some sense. I’m still trying to wrap my head around the shadow dom, and why styles can sometimes penetrate the boundary and sometimes cannot. Thanks.
This also happens with Ionic build in css utilities. Please see this issue: #22266 Here you can see two demos of a minimal Ionic setup. The first demo does not work, the second one works. Why? 😕 In both demos, I doing the same stuff. The only difference is the project setup of Angular multi-app. It’s weird, I cannot explain the reason. Any guess will help. Do you have an idea. I would be very pleased about any hint. Update: You’ll see a solution in this issue.