#getRootElement + cssVariablesSelector not working as expected

8 messages ยท Page 1 of 1 (latest)

steel schooner
#

Greetings team! ๐Ÿ‘‹ Great work on V7!

How do I have separation of concerns between nested Mantine providers? I have a use case where my npm library would have its own provider and its consumers may have their own provider. I used combination of getRootElement and cssVariablesSelector but no dice ๐Ÿ˜Ÿ

Trying to solve the following

  1. Parent's theme toggle should not change the theme for nested components because its using a separate root
  2. Select dropdown seems to have two sources of truth, parent and nested when used inside a nested provider. So the component's colour breaks when user changes the themes

Thanks again for creating such a good library!

Repro: https://codesandbox.io/p/sandbox/relaxed-stonebraker-w2tk25?file=%2Fsrc%2FApp.tsx%3A35%2C21

terse gale
steel schooner
#

re: #1 - any thoughts? Mantine supports nested providers but they're not isolated as you'd expect them to be. Shouldn't it pick the closest root to the provider? ๐Ÿค”

terse gale
steel schooner
#

Is this something that Mantine would support? ๐Ÿ™ I can help draft up a PR too with some guidance.

For context, our library is bringing in ~50K downloads a week so the impact of this would be great!. This would mean great user experience for the users using our library with Mantine.

terse gale
steel schooner
#

Hm I see what you mean. One approach could be to make this data-mantine-color-scheme customizable via props but that might be hard.

Another one could be to update data-mantine-color-scheme via postcss? Do you have any other ideas?