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

ColorMode ignoring config set in code and following the setting on other Chakra sites. #8246

Open
1 of 3 tasks
olibpool opened this issue Feb 1, 2024 · 1 comment
Open
1 of 3 tasks
Labels
Topic: Color Mode 🌓 Issue or PR related to color mode

Comments

@olibpool
Copy link

olibpool commented Feb 1, 2024

Description

I'm building a webapp but only making use of the "light" colour mode. The problem is that even when setting the "light" mode using the code below:

const extendedTheme = extendTheme({ ...theme, config: { initialColorMode: "light", useSystemColorMode: false, }, });

The colour mode is reverts back to whatever colour mode has been picked on other Chakra UI sites that I've visited due to the shared local state for the color mode.

Link to Reproduction

https://codesandbox.io/p/sandbox/relaxed-jennings-gg58sr?file=%2Fsrc%2Findex.tsx%3A24%2C11

Steps to reproduce

  1. Open a Chakra UI website - select dark mode.
  2. Open another Chakra UI website.
  3. This website will be using the color mode selected on the other website.

Chakra UI Version

2.8.2

Browser

Microsoft Edge

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

@CarterMcAlister
Copy link

@olibpool I am handling this by setting a custom color mode key for the color mode manager

Example:

import { ChakraProvider, createLocalStorageManager } from '@chakra-ui/react'

export const COLOR_MODE_MANAGER_KEY = 'mysite-color-theme'
const manager = createLocalStorageManager(COLOR_MODE_MANAGER_KEY)

export function ThemeProvider({ children }) {
  return (
    <ChakraProvider colorModeManager={manager}>
      {children}
    </ChakraProvider>
  )
}

@segunadebayo segunadebayo added the Topic: Color Mode 🌓 Issue or PR related to color mode label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic: Color Mode 🌓 Issue or PR related to color mode
Projects
None yet
Development

No branches or pull requests

3 participants