Toolbar
A text-formatting toolbar combines toggle buttons, radio alignment, a font menu, a number input, a checkbox, and a link in one tab stop. Copy, cut, and paste use an example-local clipboard.
Example
Ready.
Formatting applies to this example text area. The clipboard stays in this page.
Keyboard interaction
Left/Right, Home/End move across controls. Up/Down moves within alignment radios without selecting, opens the font menu, or adjusts font size. Enter/Space activates buttons and selects radios. Tab leaves the toolbar; returning restores the last control.
Events
Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.
axxy-toolbar-change— Dispatched when a toolbar control is activated or toggled. (target:Active control, detail:{ item: HTMLElement })
Example HTML
<axxy-scope>
<div role="toolbar" aria-label="Editor tools">
<span role="group" aria-label="Clipboard">
<button value="copy">Copy</button>
<button value="paste" aria-disabled="true">Paste</button>
<button value="cut">Cut</button>
</span>
<span role="group" aria-label="Text style">
<button value="bold" aria-pressed="false" aria-describedby="bold-tip">Bold</button>
<button value="italic" aria-pressed="false" aria-describedby="italic-tip">Italic</button>
<button value="underline" aria-pressed="false" aria-describedby="underline-tip">Underline</button>
</span>
<span role="radiogroup" aria-label="Text alignment">
<button value="left" aria-checked="true">Left</button>
<button value="center">Center</button>
<button value="right">Right</button>
</span>
<span>
<button data-font-trigger>Sans serif</button>
<span role="menu">
<button role="menuitemradio" value="sans-serif" aria-checked="true">Sans serif</button>
<button role="menuitemradio" value="serif">Serif</button>
<button role="menuitemradio" value="monospace">Monospace</button>
</span>
</span>
<label>
Font size
<input data-font-size type="number" min="10" max="32" step="2" value="16">
</label>
<label>
<input data-night-mode type="checkbox">
Night mode
</label>
<a href="#toolbar-help">Help</a>
</div>
<span id="bold-tip" role="tooltip" hidden>Make the text bold</span>
<span id="italic-tip" role="tooltip" hidden>Italicize the text</span>
<span id="underline-tip" role="tooltip" hidden>Underline the text</span>
<p>
<label for="toolbar-editor">Editable text</label>
</p>
<textarea id="toolbar-editor" data-toolbar-editor rows="6" cols="50">Use the toolbar to format this editable example text.</textarea>
<p role="status" data-toolbar-status>Ready.</p>
<p id="toolbar-help">Formatting applies to this example text area. The clipboard stays in this page.</p>
</axxy-scope>