Closes #18006: Dispatch event when toggling color mode & document for plugin use (#20031)

This commit is contained in:
Jeremy Stretch
2025-08-06 11:47:06 -04:00
committed by GitHub
parent 3ecb904e37
commit 4ce47e778b
6 changed files with 26 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
# User Interface
## Light & Dark Mode
The NetBox user interface supports toggling between light and dark versions of the theme. If needed, a plugin can determine the currently active color theme by inspecting `window.localStorage['netbox-color-mode']`, which will indicate either `light` or `dark`.
Additionally, when the color scheme is toggled by the user, a custom event `netbox.colorModeChanged` indicating the new scheme is dispatched. A plugin can listen for this event if needed to react to the change:
```typescript
window.addEventListener('netbox.colorModeChanged', e => {
const customEvent = e as CustomEvent<ColorModeData>;
console.log('New color mode:', customEvent.detail.netboxColorMode);
});
```