|
| 1 | +--- |
| 2 | +menu: Active Proposals |
| 3 | +name: Toolbar Elements (Explainer) |
| 4 | +path: /components/toolbar.explainer |
| 5 | +layout: ../../layouts/ComponentLayout.astro |
| 6 | +--- |
| 7 | + |
| 8 | +- Authors: [@lukewarlow](https://github.com/lukewarlow) |
| 9 | + |
| 10 | +{/* START doctoc generated TOC please keep comment here to allow auto update */} |
| 11 | +{/* DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE */} |
| 12 | + |
| 13 | +## Table of Contents |
| 14 | + |
| 15 | +- [Table of Contents](#table-of-contents) |
| 16 | +- [Introduction](#introduction) |
| 17 | +- [New `<toolbar>` element](#new-toolbar-element) |
| 18 | +- [General questions](#general-questions) |
| 19 | +- [Examples in code](#examples-in-code) |
| 20 | +- [Reading List](#reading-list) |
| 21 | +- [Issues / Discussions](#issues--discussions) |
| 22 | + |
| 23 | +## Introduction |
| 24 | + |
| 25 | +A toolbar is a common user interface pattern used to provide quick access to a group of commands, represented using controls such as [press buttons](/components/press-button.explainer), [menus](/components/menu.explainer) and other such controls. |
| 26 | + |
| 27 | +This proposal introduces a new `<toolbar>` element. The `<toolbar>` will: |
| 28 | +- Represent a grouping of controls (e.g. buttons, select boxes, press buttons). |
| 29 | +- Provide the correct implicit ARIA role and keyboard interaction model out of the box. |
| 30 | +- Allow web developers to create consistent, accessible toolbars without re-implementing ARIA patterns. |
| 31 | + |
| 32 | +Use cases: |
| 33 | +- The formatting toolbar in a document editor (bold, italic, underline, font family). |
| 34 | +- The main command toolbar in a drawing or photo editing app. |
| 35 | +- A simple toolbar with a search field and filter buttons in a catalogue. |
| 36 | + |
| 37 | +## New `<toolbar>` element |
| 38 | + |
| 39 | +`<toolbar>` |
| 40 | + |
| 41 | +- Represents a **group of controls**. |
| 42 | +- Provides implicit `role="toolbar"`. |
| 43 | +- Toolbars are displayed horizontally by default. |
| 44 | +- Provides correct keyboard navigation behaviour. |
| 45 | + |
| 46 | +## General questions |
| 47 | + |
| 48 | +### What should be the keyboard behavior? |
| 49 | + |
| 50 | +This element will implicitly provide the same behaviour as a [toolbar focusgroup](/components/scoped-focusgroup.explainer#supported-behaviors). |
| 51 | + |
| 52 | +- It will contain a single tab-stop. |
| 53 | +- Arrow-keys can be used to navigate between focusable children. |
| 54 | +- Home keys can be used to jump to the beginning or end of the toolbar. |
| 55 | +- It should potentially support an orientation attribute. [Issue 1201](https://github.com/openui/open-ui/issues/1201) |
| 56 | + |
| 57 | +#### How should we handle conflicting keyboard behavior from children? |
| 58 | + |
| 59 | +There are many types of built-in HTML controls that already have existing keyboard behavior, |
| 60 | +we should ensure that these don't lead to keyboard traps where users can't escape. |
| 61 | + |
| 62 | +[Issue 1281](https://github.com/openui/open-ui/issues/1281) tracks a possible solution to these cases. It's possible |
| 63 | +that there's more specific interventions that we can make to avoid these issues in the first place. |
| 64 | + |
| 65 | +### How can users customize the UI of this toolbar element with CSS? |
| 66 | + |
| 67 | +We propose this element should not support the CSS appearance property and just have a "base" appearance by default like the `<dialog>` element. |
| 68 | + |
| 69 | +**Questions** |
| 70 | + |
| 71 | +* `<toolbar>` should display children horizontally, but support using CSS writing-mode. |
| 72 | + * Can have vertical case by: |
| 73 | + * Set CSS `writing-mode: vertical-lr` on the `<toolbar>` |
| 74 | + * Should this affect arrow-key directionality? |
| 75 | + * Should this also affect aria-orientation? |
| 76 | +* Does `<toolbar>` support separators? |
| 77 | + * If so, we should support `<hr>` for this. |
| 78 | +* Toolbars generally should be labelled, it is a MUST if there are multiple on a page. Should we support this via HTML, |
| 79 | + or still rely on aria? |
| 80 | + * Could use `<legend>` to do this? |
| 81 | + |
| 82 | +## Examples in code |
| 83 | + |
| 84 | + |
| 85 | +### Google Docs: Toolbar |
| 86 | + |
| 87 | + |
| 88 | +<img src="/images/toolbar-google-docs.png" alt="A toolbar element as seen in Google Docs." /> |
| 89 | + |
| 90 | +```html |
| 91 | +<toolbar aria-label="Main"> |
| 92 | + <button id="undoButton" aria-label="Undo"><img src="..." alt=""></button> |
| 93 | + <button id="redoButton" aria-label="Redo"><img src="..." alt=""></button> |
| 94 | + <button id="printButton" aria-label="Print"><img src="..." alt=""></button> |
| 95 | + <input id="zoomSelect" list="zoom" aria-label="Zoom"> |
| 96 | + ... |
| 97 | +</toolbar> |
| 98 | +<datalist id="zoom"> |
| 99 | + <option>Fit</option> |
| 100 | + <option>50%</option> |
| 101 | + ... |
| 102 | +</datalist> |
| 103 | + |
| 104 | +<script> |
| 105 | +undoButton.addEventListener("click", () => { |
| 106 | + undo(); |
| 107 | +}); |
| 108 | +</script> |
| 109 | +``` |
| 110 | + |
| 111 | +## Future enhancements |
| 112 | + |
| 113 | +We envision more advanced capabilities in the future that could enhance the usability of the toolbar |
| 114 | +designed in this explainer, but that are not necessarily in scope for our initial |
| 115 | +proposal. |
| 116 | + |
| 117 | +One such capability is keyboard shortcuts to invoke controls within the toolbar; see |
| 118 | +https://github.com/openui/open-ui/issues/1225. We envision that this could be provided by a more |
| 119 | +advanced version of the |
| 120 | +[`accesskey`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/accesskey) |
| 121 | +primitive, that would provide customizable key commands that apply outside the scope of our |
| 122 | +proposal. |
| 123 | + |
| 124 | +## Reading List |
| 125 | + |
| 126 | +### ARIA guidelines |
| 127 | +- the ARIA [toolbar role](https://w3c.github.io/aria/#toolbar) |
| 128 | +- the [Core AAM mappings](https://www.w3.org/TR/core-aam-1.2/#role-map-toolbar) |
| 129 | + |
| 130 | +### Relevant ARIA issues |
| 131 | +- [ARIA] [Allow posinset/setsize for toolbars](https://github.com/w3c/aria/issues/2158) |
| 132 | + |
| 133 | +### APG pattern recommendations (note these are not guidelines) |
| 134 | +- [toolbar](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/) |
| 135 | + - [toolbar example](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/examples/toolbar/) |
| 136 | + |
| 137 | +### Blog posts from accessibility community |
| 138 | +- Fill as and when they're discovered |
| 139 | + |
| 140 | +### Blog posts for Design System |
| 141 | +- https://developer.apple.com/design/human-interface-guidelines/toolbars |
| 142 | + |
| 143 | +## Issues / Discussions |
| 144 | + |
| 145 | +This section links to all of the relevant discussions and [issues](https://github.com/openui/open-ui/issues?q=is%3Aissue%20state%3Aopen%20label%3Atoolbar) related to `toolbar`: |
| 146 | + |
| 147 | +### OpenUI |
| 148 | +- [Toolbar element proposal](https://github.com/openui/open-ui/issues/1283) |
| 149 | +- [Explicitly mention whether reading-flow should impact arrow key navigation](https://github.com/openui/open-ui/issues/1187) |
| 150 | +- [Improve distinction between menubar and toolbar](https://github.com/openui/open-ui/issues/1188) |
| 151 | +- [Define orientation attribute](https://github.com/openui/open-ui/issues/1201) |
0 commit comments