Skip to content
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

feat: add css reset scope #7464

Merged
merged 1 commit into from
Mar 19, 2023
Merged

feat: add css reset scope #7464

merged 1 commit into from
Mar 19, 2023

Conversation

segunadebayo
Copy link
Member

Closes #6946

📝 Description

Add support for scoping the css reset to a specific selector.

To use this feature, pass the resetScope prop to the ChakraProvider or
ChakraBaseProvider component.

import { ChakraProvider } from "@chakra-ui/react"
function App() {
  return (
    <ChakraProvider resetScope=".ck-reset">
      <App />
    </ChakraProvider>
  )
}

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2023

🦋 Changeset detected

Latest commit: efebc94

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@chakra-ui/css-reset Minor
@chakra-ui/provider Minor
@chakra-ui/theme Minor
@chakra-ui/react Patch
@chakra-ui/test-utils Patch
@chakra-ui/toast Patch
@chakra-ui/system Patch
@chakra-ui/theme-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 19, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
chakra-ui-storybook ✅ Ready (Inspect) Visit Preview Mar 19, 2023 at 7:53PM (UTC)

@selbekk
Copy link
Contributor

selbekk commented Mar 20, 2023

👏 Thanks a ton for this, this will mean so much for adoption across large orgs with existing code bases.

@posabsolute
Copy link

Has this been released yet?

@TylerAPfledderer
Copy link
Collaborator

@posabsolute
Copy link

@TylerAPfledderer

I think there are still some issues with the scoped CSS, most is scoped but some of the reset still leaks globally.

I would expect HTML would not receive any styling, at least things like font and line height should not be affected.

Screenshot 2023-04-04 at 7 19 23 PM

@posabsolute
Copy link

The other thing that would help for this feature is where the CSS is added, with styled-components you can define where the styles are added.

In micro front-ends its very possible we load multiple apps, so it's less error prone to have the CSS leave when the app is unloaded. This is the target option in StyleSheetManager from styled-component

@simowaer
Copy link

@segunadebayo this is breaking in chrome browsers below version 88 because it changes to using the :where() selector (https://developer.mozilla.org/en-US/docs/Web/CSS/:where#browser_compatibility)

@posabsolute
Copy link

Hey @TylerAPfledderer,

I gave it a go, it's almost there but if you add a ck-reset parent, then it overrides styles from the main components, example below:

Screenshot 2023-07-13 at 9 45 05 AM

@Andrei-Ist
Copy link

Do you have any updates how to fix this?
Have you tried the disableGlobalStyle feature release of ChakraProvider, in Chakra version 2.7.1.
I'm trying to use this new feature, as an alternative to resetScope. So far it seems to have no effect, or I'm using it wrong. I'm trying it in chrome v 115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scoping global CSS reset
6 participants