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.

[Theme] Sync theme.config types with ColorMode

See original GitHub issue

Describe the bug Right now, the theme.config property is not typed which leads to theme.config.initialColorMode being string, which is incompatible when used against the ColorMode type.

image

Suggested solution(s)

Simply adding and exporting a ThemeConfig definition should solve this:

import { ColorMode } from '@chakra-ui/core';

export interface ChakraConfig {
  initialColorMode: ColorMode;
  useSystemColorMode: boolean;
}

const config: ChakraConfig = {
  initialColorMode: 'dark',
  useSystemColorMode: false,
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
jmiazgacommented, Jul 15, 2020

In use-color-mode-state.ts there is:

interface Options {
  initialColorMode?: ColorMode
  useSystemColorMode?: boolean
}

Should this just be exported and/or renamed so it’s more explicit?

2reactions
segunadebayocommented, Jul 15, 2020

@jmiazga. How about this:

  • Export it from color-mode
  • Import it from system in the theme package. Color mode is already bundled in the system package.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Color Mode - Chakra UI
For typescript, you need to explicitly describe the theme config type as ThemeConfig object. // theme.ts. // 1. import `extendTheme` function.
Read more >
Advanced Chakra UI - Custom Theme, config ... - YouTube
Learn 5 advanced Chakra UI features including how to use multiple theme files, useBreakpointValue, useMediaQuery, config, and how to create ...
Read more >
Color Mode - Chakra UI
Working with color mode (light and dark mode) in Chakra UI. ... To support this, extend the default theme with a config key...
Read more >
Chakra UI color mode changes on page refresh, because of ...
getItem('chakra-ui-color-mode') so create theme.js file ... const theme = extendTheme({ config: { initialColorMode: localStorage.
Read more >
Material-UI: How to Implement Dark Mode and Edit Theme ...
As a bonus, we'll also explore how to edit the theme colors. ... reset/normalizations to the app to keep the styling in sync...
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