admin 管理员组文章数量: 1086019
Mantine has robust theming capabilities, including color schemes. Nevertheless, I have not been able to figure out how to force a particular color scheme for a section of the page (a component and its children, for instance) independently from the rest of the page.
MantineProvider
"must be rendered at the root of your application and should be used only once", so I can't wrap a component with another MantineProvider
deep down into the layout and use forceColorScheme
only from that point in the tree onwards. Even if it was possible to use multiple MantineProvider
s, since the library uses CSS variables in :root
to define the default values and :root[data-mantine-color-scheme="dark"]
and :root[data-mantine-color-scheme="light"]
to override them, the color scheme is not localized but set for the whole document.
If the variables were defined in classes (i.e. mantine-light
and mantine-dark
) instead using :root
, that would be easy. I would just have to apply one of the classes to the component to override locally, but that's not the case.
The case in hand is that I want the header (and everything in it) to always use the dark color scheme no matter if the whole page is using light, dark or auto. I don't want to override all CSS variables manually in the header, though. Any ideas?
本文标签: reactjsForce color scheme for a component independently from MantineProviderStack Overflow
版权声明:本文标题:reactjs - Force color scheme for a component independently from MantineProvider - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744053828a2525503.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论