[Theme] Sync theme.config types with ColorMode
See original GitHub issueDescribe 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.
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:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In
use-color-mode-state.ts
there is:Should this just be exported and/or renamed so it’s more explicit?
@jmiazga. How about this:
color-mode
system
in the theme package. Color mode is already bundled in the system package.