import {IconWidgetDemo} from '@site/src/doc-demos/widgets'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
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!')
})
]
});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!')
})
]
});import React from 'react';
import DeckGL, {IconWidget} from '@deck.gl/react';
import '@deck.gl/widgets/stylesheet.css';
function App() {
return (
<DeckGL>
<IconWidget
icon="./run.svg"
label="Run!"
onClick={() => alert('Running!')}
/>
</DeckGL>
);
}import {IconWidget, type IconWidgetProps} from '@deck.gl/widgets';
new IconWidget({} satisfies IconWidgetProps);The IconWidget accepts the generic WidgetProps and:
Data URL used as the button icon mask.
Tooltip message displayed while hovering over the widget.
- Default: value of
label
Custom tooltip content. Overrides the default label text in the tooltip. Pass false to disable.
CSS color applied to the icon.
() => voidCallback invoked when the button is clicked.
The IconWidget uses the shared button theme variables described in the styling guide.