Skip to main content

IconWidget

from v9.3

This widget renders a single icon button. Use it for simple actions that should live alongside the other built-in deck.gl widgets.

import {Deck} from '@deck.gl/core';
import {IconWidget} from '@deck.gl/widgets';
import '@deck.gl/widgets/stylesheet.css';

new Deck({
widgets: [
new IconWidget({
icon: `./run.svg`,
label: 'Run!',
onClick: () => alert('Running!')
})
]
});

Constructor

import {IconWidget, type IconWidgetProps} from '@deck.gl/widgets';
new IconWidget({} satisfies IconWidgetProps);

Types

IconWidgetProps

The IconWidget accepts the generic WidgetProps and:

icon (string, required)

Data URL used as the button icon mask.

label (string, optional)

Tooltip message displayed while hovering over the widget.

color (string, optional)

CSS color applied to the icon.

onClick (function, optional)

() => void

Callback invoked when the button is clicked.

Styles

The IconWidget uses the shared button theme variables described in the styling guide.

Source

modules/widgets/src/icon-widget.tsx