import BrowserOnly from '@docusaurus/BrowserOnly'; import {WidgetPreview} from '@site/src/doc-demos/widgets'; import {_ThemeWidget} from '@deck.gl/widgets';
This widget changes the theme of deck.gl between light mode and dark mode. Click the widget to toggle the theme.
:::info
- The
ThemeWidgetis mainly intended for minimal applications and to help developers test theme changes. More advanced applications that already support theming in their non-Deck UI will likely want to control change of deck themes using the same mechanism that is used for the remainder of their UI. :::
{() => }
import {_ThemeWidget as ThemeWidget} from '@deck.gl/widgets';
import {Deck} from '@deck.gl/core';
const deck = new Deck({
widgets: [new ThemeWidget()]
});The ThemeWidget accepts the generic WidgetProps:
id(default'theme') - Unique id for this widgetplacement(default'top-left') - Widget position within the view relative to the map containerviewId(defaultnull) - TheviewIdprop controls how a widget interacts with views.style(default{}) - Additional inline styles on the top HTML element.className(default'') - Additional classnames on the top HTML element.
Styles for light mode theme.
Default: Light Glass Theme
Styles for dark mode theme.
Default: Dark Glass Theme
Set the initial theme. 'auto' inspects window.matchMedia('(prefers-color-scheme: dark)'), and none prevents the widget from changing the theme on-mount.
Default: 'auto'
Tooltip message displayed while hovering a mouse over the widget when out of fullscreen.
Default: 'Light Theme'
Tooltip message displayed while hovering a mouse over the widget when fullscreen.
Default: 'Dark Theme'
| Name | Type | Default |
|---|---|---|
--icon-sun |
SVG Data Url | Material Symbol Add |
--icon-moon |
SVG Data Url | Material Symbol Remove |