feat: Emit custom event when theme changes (#723)
* Emit custom event when theme changes * Type themechange custom event * Update darkmode docs
This commit is contained in:
parent
1ce12fc1fc
commit
0a76707062
3 changed files with 22 additions and 7 deletions
|
@ -12,3 +12,12 @@ Quartz supports darkmode out of the box that respects the user's theme preferenc
|
|||
- Component: `quartz/components/Darkmode.tsx`
|
||||
- Style: `quartz/components/styles/darkmode.scss`
|
||||
- Script: `quartz/components/scripts/darkmode.inline.ts`
|
||||
|
||||
You can also listen to the `themechange` event to perform any custom logic when the theme changes.
|
||||
|
||||
```js
|
||||
document.addEventListener("themechange", (e) => {
|
||||
console.log("Theme changed to " + e.detail.theme) // either "light" or "dark"
|
||||
// your logic here
|
||||
})
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue