question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Chakra 1.6.12 now features color mode issues (now dark by default, even though docs promise light by default. Also, overrides appear not to work)

See original GitHub issue

Description

Docs tell me that Chakra will be light color mode: https://chakra-ui.com/docs/features/color-mode#setup, but the default is your system color mode. Overrides appear to not work

Link to Reproduction

https://codesandbox.io/s/dank-cloud-rymzh?file=/src/App.tsx

Steps to reproduce

  1. Install latest Chakra (1.6.12)
  2. Set your system color mode to ‘dark’
  3. Wrap something in a <ChakraProvider/>
  4. Notice that it is all black now, instead of light: image

Even if you set:

const config = {
  initialColorMode: "light",
  useSystemColorMode: false,
}

this now does not override the color mode. It always takes your system color mode

Chakra UI Version

1.6.12

Browser

All

Operating System

  • macOS
  • Windows
  • Linux

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:32
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

24reactions
stefvw93commented, Nov 10, 2021

For people who can’t wait for the next release for some reason, I temporarily solved it like this:

function ForceLightMode(props: { children: JSX.Element }) {
  const { colorMode, toggleColorMode } = useColorMode();

  useEffect(() => {
    if (colorMode === "light") return;
    toggleColorMode();
  }, [colorMode]);

  return props.children;
}
export function App() {
  return (
    <ChakraProvider theme={theme}>
      <ForceLightMode>
        ...
      </ForceLightMode>
    </ChakraProvider>
  );
}
19reactions
jnsdlscommented, Nov 4, 2021

yep, same issues here, worked around it for now by explicitly wrapping the app with a <LightMode> (directly after the provider) - since I only want light mode for right now

EDIT: actually that led to other issues, the real “fix” I’m applying now is to just resolve @chakra-ui/color-mode to a version smaller than in my package.json

"resolutions": {
    "@chakra-ui/color-mode": "<1.2.0"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Color Mode - Chakra UI
Color Mode. Chakra UI comes with built-in support for managing color mode in your apps. By default, most of Chakra's components are dark...
Read more >
Learn Chakra-ui by building a Todo Application with Local ...
Learn Chakra -ui by building a Todo Application with Local Storage, Dark Mode enabled.In this video, we will learn # chakra -ui by...
Read more >
Chakra UI Next Js - Color Mode Toggle takes 2 clicks on ...
Ie, text goes from black to light, but background stays from light to light, resulting in a screen with both light background and...
Read more >
Review of Chakra UI - Bits and Pieces
Chakra UI is a modern component library for React created by Segun ... the styles of components switching between dark and light theme...
Read more >
Dark-Mode Support with Chakra-UI and Next.js - gsdev
Chakra ships with dark-mode support built-in, even though we haven't taken a single step towards it, your boilerplate sandbox already has ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found