The useThemeEditor hook provides the core functionalities of HyperTheme Editor.
All the Editor Panels uses this hook to live edit the current theme.
It also provides undo/redo functionalities.
View source
If you want to create a custom theme editor, this is the hook you have to use.
@hypertheme-editor/chakra-ui-core leads to a known issue with recoil.@hypertheme-editor/chakra-ui or @hypertheme-editor-pro/chakra-ui.import { useThemeEditor } from '@hypertheme-editor/chakra-ui'
import { useThemeEditor } from '@hypertheme-editor-pro/chakra-ui'
The useThemeEditor hook returns an object containing everything you need to create a custom Chakra UI Theme Editor.
Here's a complete list of the returned object:
| Name | Type | Description | 
|---|---|---|
| theme | Theme | Current active theme | 
| initialTheme | Theme | the initial Theme provided by the ChakraProvider component | 
| setTheme | (theme: Theme) => void | set immediately a new theme, the themeparam must be a complete Chakra UI theme object | 
| canUndo | boolean | return truewhen undo history is not empty | 
| canRedo | boolean | return truewhen redo history is not empty | 
| undo | () => void | undo last theme change, calling this function causes a live edit | 
| redo | () => void | redo last theme undo, calling this function causes a live edit | 
In this example we're simulating a custom save button that saves the customized theme to an api.
As you have been noticed, this example is exactly the same of Retrieve current theme example:
In this example we're simply swapping the red.500 color with the blue.500 color.
This component is useless but it demonstrates that calling the setTheme causes an instant theme live edit:
This example explains how to create custom undo/redo buttons.
Prev
Next