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.

bug: user styles are not overriding scoped components

See original GitHub issue

Bug 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 !importants.

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:open
  • Created 5 years ago
  • Reactions:10
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lincolnthreecommented, Mar 21, 2019

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.

0reactions
infactocommented, Oct 15, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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