|
| 1 | +--- |
| 2 | +title: Toolbar Button |
| 3 | +--- |
| 4 | + |
| 5 | +import Demo from "@components/Demo.astro"; |
| 6 | +import PageSwitcher from "@components/PageSwitcher.astro"; |
| 7 | +import ExperimentalComponent from "@components/experimental-component.md"; |
| 8 | +import IconsInfo from "@components/icons-info.md"; |
| 9 | + |
| 10 | +import Imports from "@components/examples/toolbar-button/Imports.astro"; |
| 11 | +import ToggleableExample from "@components/examples/toolbar-button/ToggleableExample.astro"; |
| 12 | + |
| 13 | +<Imports /> |
| 14 | +<PageSwitcher /> |
| 15 | +<ExperimentalComponent /> |
| 16 | + |
| 17 | +## Basic example |
| 18 | + |
| 19 | +<IconsInfo /> |
| 20 | + |
| 21 | +In icon-only mode, a label for screen readers can be defined using the `label` attribute. |
| 22 | + |
| 23 | +<Demo> |
| 24 | + <vscode-toolbar-button icon="account" label="Account"></vscode-toolbar-button> |
| 25 | + <Fragment slot="html"> |
| 26 | + ```html 'label="Account"' |
| 27 | + <vscode-toolbar-button |
| 28 | + icon="account" |
| 29 | + label="Account" |
| 30 | + ></vscode-toolbar-button> |
| 31 | + ``` |
| 32 | + </Fragment> |
| 33 | +</Demo> |
| 34 | + |
| 35 | +## With caption |
| 36 | + |
| 37 | +<Demo> |
| 38 | + <vscode-toolbar-button icon="account">Account</vscode-toolbar-button> |
| 39 | + <Fragment slot="html"> |
| 40 | + ```html |
| 41 | + <vscode-toolbar-button icon="account">Account</vscode-toolbar-button> |
| 42 | + ``` |
| 43 | + </Fragment> |
| 44 | +</Demo> |
| 45 | + |
| 46 | +## Text-only |
| 47 | + |
| 48 | +<Demo> |
| 49 | + <vscode-toolbar-button>Account</vscode-toolbar-button> |
| 50 | + <Fragment slot="html"> |
| 51 | + ```html |
| 52 | + <vscode-toolbar-button>Account</vscode-toolbar-button> |
| 53 | + ``` |
| 54 | + </Fragment> |
| 55 | +</Demo> |
| 56 | + |
| 57 | +## Toggleable |
| 58 | + |
| 59 | +<Demo> |
| 60 | + <ToggleableExample /> |
| 61 | + <Fragment slot="html"> |
| 62 | + ```html |
| 63 | + <vscode-toolbar-button |
| 64 | + icon="account" |
| 65 | + label="Account" |
| 66 | + toggleable |
| 67 | + id="toggle-example" |
| 68 | + ></vscode-toolbar-button> |
| 69 | + ``` |
| 70 | + </Fragment> |
| 71 | + <Fragment slot="js"> |
| 72 | + ```javascript |
| 73 | + const el = document.querySelector("#toggle-example"); |
| 74 | + |
| 75 | + el.addEventListener("change", () => { |
| 76 | + console.log("Checked:", el.checked); |
| 77 | + }); |
| 78 | + ``` |
| 79 | + </Fragment> |
| 80 | +</Demo> |
| 81 | + |
| 82 | +<vscode-toolbar-button><b>B</b></vscode-toolbar-button> |
| 83 | +<vscode-toolbar-button><em>I</em></vscode-toolbar-button> |
| 84 | +<vscode-toolbar-button><ins>U</ins></vscode-toolbar-button> |
| 85 | +<vscode-toolbar-button><del>S</del></vscode-toolbar-button> |
0 commit comments