Toolbar Button
This component is in the experimental phase, and its API is subject to change at any time. Any changes will be announced in the changelog. Please review it carefully with each library upgrade.
To use the icons, the codicons.css file must be included in the page:
<link rel="stylesheet" href="path/to/codicon.css" id="vscode-codicon-stylesheet">
Note the required id
on the link element!
To use web fonts in web components, the component needs to include
the font stylesheet in addition to the page. This id serves as a lookup so
the icon component can automatically create and insert it’s own link tag.
Basic example
Section titled “Basic example”In icon-only mode, a label for screen readers can be defined using the label
attribute.
<vscode-toolbar-button icon="account" label="Account"></vscode-toolbar-button>
With caption
Section titled “With caption”<vscode-toolbar-button icon="account">Account</vscode-toolbar-button>
Text-only
Section titled “Text-only”<vscode-toolbar-button>Account</vscode-toolbar-button>
Toggleable
Section titled “Toggleable”<vscode-toolbar-button icon="account" label="Account" toggleable id="toggle-example"></vscode-toolbar-button>
const el = document.querySelector("#toggle-example");
el.addEventListener("change", () => { console.log("Checked:", el.checked); });