Skip to content

Conversation

@mantine-contrib
Copy link

Closes: #8101
glowing-guide-pj6xg995v47wc66g-7545 app github dev_theming_color-schemes_

@@ -0,0 +1,32 @@
.root-background {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classes must use camelCase

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this change per your request.
I would beg to differ this decision, though.
Eversince I starting doing web development the naming of css classes have always been in kebab casing.
If we want the imported class name in camel case, we may want to borrow some ideas from here instead:
vercel/next.js#11267

}

.dark {
@mixin dark {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use light-dark function instead of @mixin light and @mixin dark

Comment on lines 87 to 88
Users may interact with the color scheme toggle assuming that the site will continue to follow their operating system's color preferences on future visits.
To address this, in addition to calling `clearColorScheme` when the root component mounts, you can also use a `SegmentedControl` with three options—such as `Light`, `Dark`, and `Auto`—allowing users to revert to automatic color scheme detection at any time.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this description, replace with title: "Example: auto 3 state scheme toggle".

Comment on lines 34 to 39
function Demo({
iconSizeInRem,
iconStroke = 2.5,
transitionDuration = 200,
...restProp
}: ColorSchemeSegmentedControl) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Demo components must not accept props.

const theme = useMantineTheme();
const { colorScheme, setColorScheme } = useMantineColorScheme();
const [colorSchemeSegmentedControlValue, setColorSchemeSegmentedControlValue] = useState(
'auto' as MantineColorScheme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use useState<MantineColorScheme> instead.

const { colorScheme, setColorScheme } = useMantineColorScheme();
const [colorSchemeSegmentedControlValue, setColorSchemeSegmentedControlValue] = useState(
'auto' as MantineColorScheme
); // Allow the state of SegmentedControl to change immediately, before the color scheme actually changes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless comment.

const lightIcon = (
<IconSun
style={{ width: iconSize, height: iconSize }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use size prop for icon instead of style with width and height.

@sshahriazz
Copy link

sshahriazz commented Nov 10, 2025

Mantine UI light dark mode switching for Next.js is a pain to setup. If there is a official guideline for this that would be great. Now, It flickers and hydration error occurs when we do light dark mode switching in Next.js. Other library provides official support for this. Why it's so hard for Mantine then?

NB. Official guide only mentions problems with the SSR/Nextjs it's not suggesting any solution.

@rtivital
Copy link
Member

This PR is not a place to provide feedback or ask questions. If you want to get help, submit an issue or ask a question in GitHub discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Documentation] Add a demo for 3 states color scheme toggle with an additional Auto state

3 participants