-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: user styles are not overriding scoped components #17425
Comments
Update: this is currently being worked on in Stencil |
Is this possibly related to: #17685 ? I've seen a number of these issues come up. |
@lincolnthree The content component is a shadow component so this doesn't apply to it. The problem there seems to be that the inner scroll div gets the scrollbar so we would need to expose CSS variables or move the scrollbar up a level. 🙂 |
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. |
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. Thank you for using Ionic! |
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. |
Hi everyone, I spoke with the team, and we have decided to close this issue as "Resolved". Some of our components use scoped styles so that the component styles do not interfere with your global application styles. The tradeoff here is that customizing the internal styles of these components requires using CSS with a higher specificity than what we are using internally. This is the intended behavior of scoped components. What we've done since this issue was opened
Our recommendation is to target a component based on a custom class. In most cases this should provide a higher specificity than what we have internally. Example: https://ionicframework.com/docs/api/action-sheet#theming
The Shadow DOM does not have this problem because the styles are not scoped. This means that A note for Angular developersIf your Angular components are using Scoped Encapsulation then you may need to take additional steps to customize the internals of Ionic components. Consider the following selector: ion-input.custom-class .native-input {
background: green;
} Angular will scope each part of this selector to look something like this: ion-input.custom-class[_ngcontent-ng-c2209613554] .native-input[_ngcontent-ng-c2209613554] {
background: green;
} However, the If you are using Angular scoped encapsulation and you need to customize deep inside an Ionic scoped component, we recommend moving these styles to a global stylesheet to prevent your selector from being processed incorrectly. I am going to close this, but let me know if there are any questions. Thank you! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version: 4.x
Current behavior:
Try to override a card using the following:
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:
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:
Here's a full list of scoped components affected:
action-sheet
alert
-(converted to use Shadow DOM)back-button
buttons
-(converted to use Shadow DOM)card
input
label
loading
-(converted to use Shadow DOM)modal
picker
-(converted to use Shadow DOM)popover
searchbar
-(converted to use Shadow DOM)segment
select-popover
textarea
The text was updated successfully, but these errors were encountered: