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.

isolate styles to reduce collisions

See original GitHub issue

Is your feature request related to a problem? Please describe.

When using Hope UI in parallel with other components, the other components are affected by Hope UI’s global CSS reset, even if they are not directly wrapped with <HopeProvider>.

 
Describe the solution you’d like

Apply the CSS reset starting from a .hope-root container (or something similar), rather than the document root.

For example, Svelte Materialify implements this to some degree and applies most of its styles starting at .s-app; and there can be multiple .s-app roots.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
fabien-mlcommented, May 3, 2022

This is possible, however this will require <HopeProvider> to render an extra div element to apply the .hope-root class.

0reactions
Enteleformcommented, May 4, 2022

Or just a scopedCssReset props which is false by default (for global reset) and when you set it to true HopeProvider wrap it’s children with the <ScopedCssReset> for you.

That seems like a pretty good implementation 👍

 

For example .hope-root a selector break css classes applied to the <Anchor> component which have a lower specificity (11 vs 10).

Just checked out how the CSS was being implemented and saw that you’re using stitches, which I’m not familiar with. Is this something that can be overcome with their style API?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to isolate component styles in React using CSS modules
How to isolate component styles in React using CSS modules ... and you need to work harder to prevent collisions between components styles....
Read more >
isolation - CSS: Cascading Style Sheets - MDN Web Docs
The isolation CSS property determines whether an element must create a new stacking context.
Read more >
How to isolate component styles in React using CSS modules
When using a separate style file, by default, all styles are global, as demonstrated later in this post, and you need to work...
Read more >
How to isolate my javascript code to prevent collisions?
You are headed in the right direction. You can use the module pattern to create an object with private members and methods like...
Read more >
ASP.NET Core Blazor CSS isolation - Microsoft Learn
Isolate CSS styles to individual pages, views, and components to reduce or avoid: Dependencies on global styles that can be challenging to ...
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