Replies: 5 comments 20 replies
-
Use nested MantineProvider:
|
Beta Was this translation helpful? Give feedback.
-
The following seems to have worked for me:
With the caveat that text elements were still getting their
|
Beta Was this translation helpful? Give feedback.
-
This is the complete solution if someone is still struggling, import { MantineProvider } from '@mantine/core';
import { useId } from 'react';
const ColorSchemedChildren = ({
children,
colorScheme,
}: {
children: React.ReactNode;
colorScheme: 'light' | 'dark';
}) => {
const id = useId().replace(/:/g, '');
const selector = `#${id}`;
return (
<div id={id}>
<MantineProvider
getRootElement={() => document.querySelector<HTMLElement>(selector)!}
cssVariablesSelector={selector}
forceColorScheme={colorScheme}
>
{children}
</MantineProvider>
</div>
);
};
export const DarkSchemedChildren = ({
children,
}: {
children: React.ReactNode;
}) => (
<ColorSchemedChildren colorScheme="dark">{children}</ColorSchemedChildren>
);
export const LightSchemedChildren = ({
children,
}: {
children: React.ReactNode;
}) => (
<ColorSchemedChildren colorScheme="light">{children}</ColorSchemedChildren>
); The extra |
Beta Was this translation helpful? Give feedback.
-
I can see from the doc that there's a |
Beta Was this translation helpful? Give feedback.
-
Hi @rtivital And you answered, as I quote
So this WAS possible but impossible now? |
Beta Was this translation helpful? Give feedback.
-
In V6 we used nested
MantineProvider
to force partial of the UI to always be with dark mode. For example, the header will always remain dark no matter the app theme is dark or light. It is convenient because all components within the header will adapt automatically.In V7 if I use force color scheme, it will overwrite app level color scheme, causing the whole app always to be dark.
Is there a way to force partial of the UI to always be dark without affecting the app theme?
Beta Was this translation helpful? Give feedback.
All reactions