dark mode on fly
See original GitHub issueSummary
I want to change dark mode of the editor when user clicks on the button.
Screenshots

In the above picture, you can see i have added a dark mode button. I want to change mode from light to dark and dark to light when user click on the button.
Version
latest
Additional context
I am using ReactJS.
export default function App() {
const [theme, setTheme] = useState("light");
let darkModeOn = false;
console.log(darkModeOn,theme)
const toggleDarkMode=()=>{
darkModeOn = !darkModeOn;
setTheme(darkModeOn?"light":"dark");
}
return <Editor
initialValue="# hello react editor world!"
previewStyle={previewStyle}
height="400px"
initialEditType="markdown"
useCommandShortcut={true}
theme={theme}
toolbarItems={[
...items, [{
el: toggleFullScreen(editorRef),
tooltip: 'Toggle Full Screen'
}, {
el: previewStyleButton(),
tooltip: "Preview Style"
}, {
el: darkMode(toggleDarkMode),
tooltip: "Preview Style"
}],
['scrollSync']
]}
/>
}
/>
}
When user click on the button then toggleDarkMode function will be executed. Although, theme state variable is changeing, but UI is not updating.
live
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Switch between dark and light theme on the fly with Nightlight
Switch between dark and light theme on Windows with just two clicks using the open source program, Nightlight.
Read more >Dark theme - Android Developers
Dark theme applies to both the Android system UI and apps running on the device. There are three ways to enable Dark theme...
Read more >Designing for dark mode - Help Center - WordFly
Introduction to dark mode. Dark mode is a device or application setting that allows people to work with backgrounds that are dark.
Read more >Switch to dark mode — Flipboard Help Center
You can also flip your theme from light to dark on the fly. Just go to your Profile menu and toggle Dark on...
Read more >How to change messenger to dark mode in FLY Champ?, how to
How to activate Messenger Dark Mode in FLY Champ? · In the first step, tap on the Messenger app icon from the apps...
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 Free
Top 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

@ats1999 There are currently no APIs for changing themes. Your method is correct, and I will think about adding API. Thank you!
Current workaround is
It’s working perfectly, but still if there is any other way then let me know.