a11y-elements 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1382 -10
- package/dist/a11y.css +346 -12
- package/dist/browser/components/anchor/define.js +328 -0
- package/dist/browser/components/anchor/define.js.map +1 -0
- package/dist/browser/components/avatar/define.js +264 -0
- package/dist/browser/components/avatar/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/checkbox/define.js +104 -7
- package/dist/browser/components/checkbox/define.js.map +1 -0
- package/dist/browser/components/checkbox-group/define.js +394 -0
- package/dist/browser/components/checkbox-group/define.js.map +1 -0
- package/dist/browser/components/file-input/define.js +1069 -0
- package/dist/browser/components/file-input/define.js.map +1 -0
- package/dist/browser/components/focusable/define.js +211 -0
- package/dist/browser/components/focusable/define.js.map +1 -0
- package/dist/browser/components/input/define.js +697 -0
- package/dist/browser/components/input/define.js.map +1 -0
- package/dist/browser/components/label/define.js +274 -0
- package/dist/browser/components/label/define.js.map +1 -0
- package/dist/browser/components/picture/define.js +411 -0
- package/dist/browser/components/picture/define.js.map +1 -0
- package/dist/browser/components/progress/define.js +239 -0
- package/dist/browser/components/progress/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/radio-group/define.js +106 -6
- package/dist/browser/components/radio-group/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/select/define.js +104 -6
- package/dist/browser/components/select/define.js.map +1 -0
- package/dist/browser/components/skeleton/define.js +234 -0
- package/dist/browser/components/skeleton/define.js.map +1 -0
- package/dist/browser/components/spinner/define.js +260 -0
- package/dist/browser/components/spinner/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/switch/define.js +104 -6
- package/dist/browser/components/switch/define.js.map +1 -0
- package/dist/browser/components/textarea/define.js +697 -0
- package/dist/browser/components/textarea/define.js.map +1 -0
- package/dist/browser/components/visually-hidden/define.js +195 -0
- package/dist/browser/components/visually-hidden/define.js.map +1 -0
- package/dist/browser/overlays/blocking-loader/define.js +182 -13
- package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
- package/dist/browser/overlays/context-menu/define.js +300 -122
- package/dist/browser/overlays/context-menu/define.js.map +1 -1
- package/dist/browser/overlays/drawer/define.js +207 -14
- package/dist/browser/overlays/drawer/define.js.map +1 -1
- package/dist/browser/overlays/dropdown/define.js +300 -122
- package/dist/browser/overlays/dropdown/define.js.map +1 -1
- package/dist/browser/overlays/emergency-dialog/define.js +207 -14
- package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/browser/overlays/modal/define.js +207 -15
- package/dist/browser/overlays/modal/define.js.map +1 -1
- package/dist/browser/overlays/notification-banner/define.js +183 -15
- package/dist/browser/overlays/notification-banner/define.js.map +1 -1
- package/dist/browser/overlays/popover/define.js +189 -12
- package/dist/browser/overlays/popover/define.js.map +1 -1
- package/dist/browser/overlays/snackbar/define.js +160 -15
- package/dist/browser/overlays/snackbar/define.js.map +1 -1
- package/dist/browser/overlays/tooltip/define.js +206 -15
- package/dist/browser/overlays/tooltip/define.js.map +1 -1
- package/dist/{accessibility-components → components}/anchor/anchor.element.d.ts +12 -4
- package/dist/{accessibility-components → components}/anchor/anchor.element.js +56 -11
- package/dist/components/anchor/anchor.element.js.map +1 -0
- package/dist/{accessibility-components → components}/anchor/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/anchor/define.js +2 -0
- package/dist/components/anchor/define.js.map +1 -0
- package/dist/{accessibility-components → components}/avatar/avatar.element.d.ts +2 -0
- package/dist/{accessibility-components → components}/avatar/avatar.element.js +10 -3
- package/dist/components/avatar/avatar.element.js.map +1 -0
- package/dist/{accessibility-components → components}/avatar/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/avatar/define.js +2 -0
- package/dist/components/avatar/define.js.map +1 -0
- package/dist/{accessibility-components → components}/checkbox/checkbox.element.js +0 -2
- package/dist/components/checkbox/checkbox.element.js.map +1 -0
- package/dist/{accessibility-components → components}/checkbox/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/checkbox/define.js +2 -0
- package/dist/components/checkbox/define.js.map +1 -0
- package/dist/components/checkbox-group/checkbox-group.element.d.ts +51 -0
- package/dist/components/checkbox-group/checkbox-group.element.js +189 -0
- package/dist/components/checkbox-group/checkbox-group.element.js.map +1 -0
- package/dist/components/checkbox-group/define.d.ts +8 -0
- package/dist/components/checkbox-group/define.js +8 -0
- package/dist/components/checkbox-group/define.js.map +1 -0
- package/dist/components/file-input/define.d.ts +9 -0
- package/dist/components/file-input/define.js +9 -0
- package/dist/components/file-input/define.js.map +1 -0
- package/dist/components/file-input/file-input.element.d.ts +95 -0
- package/dist/components/file-input/file-input.element.js +471 -0
- package/dist/components/file-input/file-input.element.js.map +1 -0
- package/dist/{accessibility-components → components}/focusable/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/focusable/define.js +2 -0
- package/dist/components/focusable/define.js.map +1 -0
- package/dist/components/focusable/focusable.element.js.map +1 -0
- package/dist/components/input/define.d.ts +9 -0
- package/dist/components/input/define.js +9 -0
- package/dist/components/input/define.js.map +1 -0
- package/dist/components/input/input.element.d.ts +22 -0
- package/dist/components/input/input.element.js +23 -0
- package/dist/components/input/input.element.js.map +1 -0
- package/dist/components/label/define.d.ts +8 -0
- package/dist/components/label/define.js +8 -0
- package/dist/components/label/define.js.map +1 -0
- package/dist/components/label/label.element.d.ts +32 -0
- package/dist/components/label/label.element.js +62 -0
- package/dist/components/label/label.element.js.map +1 -0
- package/dist/{accessibility-components → components}/picture/define.d.ts +2 -0
- package/dist/{accessibility-components → components}/picture/define.js +2 -0
- package/dist/components/picture/define.js.map +1 -0
- package/dist/components/picture/picture.element.d.ts +89 -0
- package/dist/components/picture/picture.element.js +235 -0
- package/dist/components/picture/picture.element.js.map +1 -0
- package/dist/{accessibility-components → components}/progress/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/progress/define.js +2 -0
- package/dist/components/progress/define.js.map +1 -0
- package/dist/{accessibility-components → components}/progress/progress.element.d.ts +1 -0
- package/dist/{accessibility-components → components}/progress/progress.element.js +5 -1
- package/dist/components/progress/progress.element.js.map +1 -0
- package/dist/{accessibility-components → components}/radio-group/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/radio-group/define.js +2 -0
- package/dist/components/radio-group/define.js.map +1 -0
- package/dist/{accessibility-components → components}/radio-group/radio-group.element.js +4 -1
- package/dist/components/radio-group/radio-group.element.js.map +1 -0
- package/dist/{accessibility-components → components}/select/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/select/define.js +2 -0
- package/dist/components/select/define.js.map +1 -0
- package/dist/{accessibility-components → components}/select/select.element.js +0 -1
- package/dist/components/select/select.element.js.map +1 -0
- package/dist/{accessibility-components → components}/skeleton/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/skeleton/define.js +2 -0
- package/dist/components/skeleton/define.js.map +1 -0
- package/dist/components/skeleton/skeleton.element.js.map +1 -0
- package/dist/{accessibility-components → components}/spinner/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/spinner/define.js +2 -0
- package/dist/components/spinner/define.js.map +1 -0
- package/dist/{accessibility-components → components}/spinner/spinner.element.d.ts +1 -0
- package/dist/{accessibility-components → components}/spinner/spinner.element.js +5 -1
- package/dist/components/spinner/spinner.element.js.map +1 -0
- package/dist/{accessibility-components → components}/switch/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/switch/define.js +2 -0
- package/dist/components/switch/define.js.map +1 -0
- package/dist/{accessibility-components → components}/switch/switch.element.js +0 -1
- package/dist/components/switch/switch.element.js.map +1 -0
- package/dist/components/textarea/define.d.ts +9 -0
- package/dist/components/textarea/define.js +9 -0
- package/dist/components/textarea/define.js.map +1 -0
- package/dist/components/textarea/textarea.element.d.ts +18 -0
- package/dist/components/textarea/textarea.element.js +19 -0
- package/dist/components/textarea/textarea.element.js.map +1 -0
- package/dist/{accessibility-components → components}/visually-hidden/define.d.ts +1 -0
- package/dist/{accessibility-components → components}/visually-hidden/define.js +2 -0
- package/dist/components/visually-hidden/define.js.map +1 -0
- package/dist/components/visually-hidden/visually-hidden.element.js.map +1 -0
- package/dist/core/a11y-element.d.ts +29 -1
- package/dist/core/a11y-element.js +65 -2
- package/dist/core/a11y-element.js.map +1 -1
- package/dist/core/a11y-field-element.d.ts +86 -0
- package/dist/core/a11y-field-element.js +240 -0
- package/dist/core/a11y-field-element.js.map +1 -0
- package/dist/core/a11y-overlay-element.d.ts +3 -1
- package/dist/core/a11y-overlay-element.js +12 -4
- package/dist/core/a11y-overlay-element.js.map +1 -1
- package/dist/core/a11y-wrapper-element.js +1 -0
- package/dist/core/a11y-wrapper-element.js.map +1 -1
- package/dist/core/dom-sync.d.ts +6 -0
- package/dist/core/dom-sync.js +13 -0
- package/dist/core/dom-sync.js.map +1 -1
- package/dist/core/field.d.ts +80 -0
- package/dist/core/field.js +256 -0
- package/dist/core/field.js.map +1 -0
- package/dist/core/focus-trap.d.ts +22 -0
- package/dist/core/focus-trap.js +98 -5
- package/dist/core/focus-trap.js.map +1 -1
- package/dist/core/ids.d.ts +2 -0
- package/dist/core/ids.js +18 -0
- package/dist/core/ids.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/overlay-registry.d.ts +12 -0
- package/dist/core/overlay-registry.js +29 -1
- package/dist/core/overlay-registry.js.map +1 -1
- package/dist/core/strings.d.ts +63 -0
- package/dist/core/strings.js +59 -0
- package/dist/core/strings.js.map +1 -0
- package/dist/overlays/blocking-loader/blocking-loader.element.d.ts +1 -0
- package/dist/overlays/blocking-loader/blocking-loader.element.js +8 -2
- package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -1
- package/dist/overlays/blocking-loader/define.d.ts +3 -2
- package/dist/overlays/blocking-loader/define.js +4 -3
- package/dist/overlays/blocking-loader/define.js.map +1 -1
- package/dist/overlays/context-menu/define.d.ts +2 -1
- package/dist/overlays/context-menu/define.js +3 -2
- package/dist/overlays/context-menu/define.js.map +1 -1
- package/dist/overlays/core/a11y-menu-overlay-element.js +3 -2
- package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-modal-overlay-element.d.ts +7 -0
- package/dist/overlays/core/a11y-modal-overlay-element.js +19 -2
- package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +11 -3
- package/dist/overlays/core/a11y-passive-overlay-element.js +40 -13
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/drawer/define.d.ts +2 -1
- package/dist/overlays/drawer/define.js +3 -2
- package/dist/overlays/drawer/define.js.map +1 -1
- package/dist/overlays/drawer/drawer.element.js +0 -1
- package/dist/overlays/drawer/drawer.element.js.map +1 -1
- package/dist/overlays/dropdown/define.d.ts +2 -1
- package/dist/overlays/dropdown/define.js +3 -2
- package/dist/overlays/dropdown/define.js.map +1 -1
- package/dist/overlays/emergency-dialog/define.d.ts +2 -1
- package/dist/overlays/emergency-dialog/define.js +3 -2
- package/dist/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/overlays/emergency-dialog/emergency-dialog.element.js +0 -1
- package/dist/overlays/emergency-dialog/emergency-dialog.element.js.map +1 -1
- package/dist/overlays/modal/define.d.ts +2 -1
- package/dist/overlays/modal/define.js +3 -2
- package/dist/overlays/modal/define.js.map +1 -1
- package/dist/overlays/modal/modal.element.js +0 -2
- package/dist/overlays/modal/modal.element.js.map +1 -1
- package/dist/overlays/notification-banner/define.d.ts +2 -0
- package/dist/overlays/notification-banner/define.js +3 -0
- package/dist/overlays/notification-banner/define.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +11 -0
- package/dist/overlays/notification-banner/notification-banner.element.js +27 -1
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/popover/define.d.ts +2 -1
- package/dist/overlays/popover/define.js +3 -2
- package/dist/overlays/popover/define.js.map +1 -1
- package/dist/overlays/popover/popover.element.js +0 -1
- package/dist/overlays/popover/popover.element.js.map +1 -1
- package/dist/overlays/snackbar/define.d.ts +2 -0
- package/dist/overlays/snackbar/define.js +3 -0
- package/dist/overlays/snackbar/define.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +1 -1
- package/dist/overlays/tooltip/define.d.ts +2 -1
- package/dist/overlays/tooltip/define.js +3 -2
- package/dist/overlays/tooltip/define.js.map +1 -1
- package/dist/overlays/tooltip/tooltip.element.js +2 -7
- package/dist/overlays/tooltip/tooltip.element.js.map +1 -1
- package/package.json +10 -10
- package/dist/accessibility-components/anchor/anchor.element.js.map +0 -1
- package/dist/accessibility-components/anchor/define.js.map +0 -1
- package/dist/accessibility-components/avatar/avatar.element.js.map +0 -1
- package/dist/accessibility-components/avatar/define.js.map +0 -1
- package/dist/accessibility-components/checkbox/checkbox.element.js.map +0 -1
- package/dist/accessibility-components/checkbox/define.js.map +0 -1
- package/dist/accessibility-components/focusable/define.js.map +0 -1
- package/dist/accessibility-components/focusable/focusable.element.js.map +0 -1
- package/dist/accessibility-components/picture/define.js.map +0 -1
- package/dist/accessibility-components/picture/picture.element.d.ts +0 -23
- package/dist/accessibility-components/picture/picture.element.js +0 -43
- package/dist/accessibility-components/picture/picture.element.js.map +0 -1
- package/dist/accessibility-components/progress/define.js.map +0 -1
- package/dist/accessibility-components/progress/progress.element.js.map +0 -1
- package/dist/accessibility-components/radio-group/define.js.map +0 -1
- package/dist/accessibility-components/radio-group/radio-group.element.js.map +0 -1
- package/dist/accessibility-components/select/define.js.map +0 -1
- package/dist/accessibility-components/select/select.element.js.map +0 -1
- package/dist/accessibility-components/skeleton/define.js.map +0 -1
- package/dist/accessibility-components/skeleton/skeleton.element.js.map +0 -1
- package/dist/accessibility-components/spinner/define.js.map +0 -1
- package/dist/accessibility-components/spinner/spinner.element.js.map +0 -1
- package/dist/accessibility-components/switch/define.js.map +0 -1
- package/dist/accessibility-components/switch/switch.element.js.map +0 -1
- package/dist/accessibility-components/visually-hidden/define.js.map +0 -1
- package/dist/accessibility-components/visually-hidden/visually-hidden.element.js.map +0 -1
- package/dist/browser/accessibility-components/anchor/define.js +0 -192
- package/dist/browser/accessibility-components/anchor/define.js.map +0 -1
- package/dist/browser/accessibility-components/avatar/define.js +0 -159
- package/dist/browser/accessibility-components/avatar/define.js.map +0 -1
- package/dist/browser/accessibility-components/checkbox/define.js.map +0 -1
- package/dist/browser/accessibility-components/focusable/define.js +0 -113
- package/dist/browser/accessibility-components/focusable/define.js.map +0 -1
- package/dist/browser/accessibility-components/picture/define.js +0 -156
- package/dist/browser/accessibility-components/picture/define.js.map +0 -1
- package/dist/browser/accessibility-components/progress/define.js +0 -135
- package/dist/browser/accessibility-components/progress/define.js.map +0 -1
- package/dist/browser/accessibility-components/radio-group/define.js.map +0 -1
- package/dist/browser/accessibility-components/select/define.js.map +0 -1
- package/dist/browser/accessibility-components/skeleton/define.js +0 -136
- package/dist/browser/accessibility-components/skeleton/define.js.map +0 -1
- package/dist/browser/accessibility-components/spinner/define.js +0 -156
- package/dist/browser/accessibility-components/spinner/define.js.map +0 -1
- package/dist/browser/accessibility-components/switch/define.js.map +0 -1
- package/dist/browser/accessibility-components/visually-hidden/define.js +0 -97
- package/dist/browser/accessibility-components/visually-hidden/define.js.map +0 -1
- /package/dist/{accessibility-components → components}/checkbox/checkbox.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/focusable/focusable.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/focusable/focusable.element.js +0 -0
- /package/dist/{accessibility-components → components}/radio-group/radio-group.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/select/select.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/skeleton/skeleton.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/skeleton/skeleton.element.js +0 -0
- /package/dist/{accessibility-components → components}/switch/switch.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/visually-hidden/visually-hidden.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/visually-hidden/visually-hidden.element.js +0 -0
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Framework-agnostic accessibility Custom Elements (Web Components). A behavior la
|
|
|
4
4
|
|
|
5
5
|
Every element is Light DOM only (no Shadow DOM), so you always style real markup with your own CSS.
|
|
6
6
|
|
|
7
|
+
See a [demo of the elements](https://nutin.org/a11y-elements/elements) - See a [demo of the overlays](https://nutin.org/a11y-elements/overlays)
|
|
8
|
+
|
|
7
9
|
## Usage
|
|
8
10
|
|
|
9
11
|
### Zero-build
|
|
@@ -12,7 +14,7 @@ Load a component's standalone browser bundle directly, no bundler required:
|
|
|
12
14
|
|
|
13
15
|
```html
|
|
14
16
|
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
|
|
15
|
-
<script type="module" src="node_modules/a11y-elements/dist/browser/
|
|
17
|
+
<script type="module" src="node_modules/a11y-elements/dist/browser/components/spinner/define.js"></script>
|
|
16
18
|
|
|
17
19
|
<a11y-spinner></a11y-spinner>
|
|
18
20
|
```
|
|
@@ -35,40 +37,1152 @@ Import via the package's `exports` map, which exposes real per-component ESM out
|
|
|
35
37
|
|
|
36
38
|
```js
|
|
37
39
|
import 'a11y-elements/a11y.css';
|
|
38
|
-
import 'a11y-elements/
|
|
40
|
+
import 'a11y-elements/components/checkbox';
|
|
39
41
|
import 'a11y-elements/overlays/modal';
|
|
40
42
|
import { A11yElement } from 'a11y-elements/core';
|
|
41
43
|
```
|
|
42
44
|
|
|
43
45
|
* There's no default export: `import 'a11y-elements'` alone will fail.
|
|
44
46
|
* Import the component you want: `/element` gets you the class itself when you need it
|
|
45
|
-
* See
|
|
47
|
+
* See [Elements](#elements) for every component.
|
|
48
|
+
|
|
49
|
+
Importing a component's subpath also adds its tag to TypeScript's `HTMLElementTagNameMap`, so exact-tag lookups such as `document.createElement('a11y-checkbox')` or `document.querySelector('a11y-checkbox')` come back typed as `CheckboxElement` without a cast.
|
|
50
|
+
|
|
51
|
+
### Translating built-in strings
|
|
52
|
+
|
|
53
|
+
A few English strings end up in accessible names and announcements. Replace them page-wide with `setStrings()`, exported from `a11y-elements/core` and from every zero-build `define.js`:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { setStrings } from 'a11y-elements/core';
|
|
57
|
+
// or: import { setStrings } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
58
|
+
|
|
59
|
+
setStrings({
|
|
60
|
+
closeDialog: 'Fermer la boîte de dialogue',
|
|
61
|
+
opensInNewTab: '(nouvel onglet)',
|
|
62
|
+
navigatedTo: 'Aller à {name}',
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
| Key | Default | Used by | Per-instance override |
|
|
67
|
+
| --- | --- | --- | --- |
|
|
68
|
+
| `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
|
|
69
|
+
| `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
|
|
70
|
+
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>` | `close-label` |
|
|
71
|
+
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item | `dismiss-label` |
|
|
72
|
+
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
73
|
+
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
74
|
+
| `avatar` | `Avatar` | `<a11y-avatar>` with no `alt` or `initials` | `alt` / `initials` |
|
|
75
|
+
| `characterCount` | `{count} / {max}` | the visible text of an `<a11y-counter>` | — |
|
|
76
|
+
| `charactersRemaining` | `{count} characters remaining` | what an `<a11y-counter>` announces near the limit | — |
|
|
77
|
+
| `characterRemaining` | `{count} character remaining` | the same, with one character left | — |
|
|
78
|
+
| `selectAll` | `Select all` | the generated checkbox of `<a11y-checkbox-group select-all>` | `select-all-label` |
|
|
79
|
+
| `browseFiles` | `Browse files` | the browse button of `<a11y-file-input>` | `browse-label` |
|
|
80
|
+
| `dropFiles` | `or drop files here` | the drag & drop prompt of `<a11y-file-input>` | `drop-label` |
|
|
81
|
+
| `selectedFiles` | `Selected files` | the name of `<a11y-file-input>`'s file list | — |
|
|
82
|
+
| `remove` / `removeFile` | `Remove` / `Remove {name}` | the visible text / accessible name of each remove button of `<a11y-file-input>` | — |
|
|
83
|
+
| `fileAdded` / `filesAdded` | `{name} added` / `{count} files added` | what `<a11y-file-input>` announces after a pick or a drop | — |
|
|
84
|
+
| `fileRemoved` | `{name} removed` | what `<a11y-file-input>` announces after a removal | — |
|
|
85
|
+
| `fileTypeRejected` | `{name} wasn’t added: this type of file isn’t allowed` | a file `accept` rules out | `type-rejected-message` |
|
|
86
|
+
| `fileSizeRejected` | `{name} wasn’t added: it’s larger than {maxSize}` | a file over `max-size` | `size-rejected-message` |
|
|
87
|
+
| `fileCountRejected` | `{name} wasn’t added: too many files (maximum {max})` | a file past `max-files` | `count-rejected-message` |
|
|
88
|
+
|
|
89
|
+
* An instance attribute wins over `setStrings()`, which wins over the default. Keys you leave out keep their current value.
|
|
90
|
+
* Elements already on the page update right away, so calling it again on a language switch is enough.
|
|
91
|
+
* `resetStrings()` restores the English defaults.
|
|
92
|
+
|
|
93
|
+
## Elements
|
|
94
|
+
|
|
95
|
+
Each section shows an example, the element's own attributes/properties/methods, and its CSS variables (collapsed).
|
|
96
|
+
|
|
97
|
+
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
98
|
+
|
|
99
|
+
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<a11y-checkbox>`](#a11y-checkbox) · [`<a11y-checkbox-group>`](#a11y-checkbox-group) · [`<a11y-file-input>`](#a11y-file-input) · [`<a11y-focusable>`](#a11y-focusable) · [`<a11y-input>`](#a11y-input) · [`<a11y-label>`](#a11y-label) · [`<a11y-picture>`](#a11y-picture) · [`<a11y-progress>`](#a11y-progress) · [`<a11y-radio-group>`](#a11y-radio-group) · [`<a11y-select>`](#a11y-select) · [`<a11y-skeleton>`](#a11y-skeleton) · [`<a11y-spinner>`](#a11y-spinner) · [`<a11y-switch>`](#a11y-switch) · [`<a11y-textarea>`](#a11y-textarea) · [`<a11y-visually-hidden>`](#a11y-visually-hidden)
|
|
100
|
+
|
|
101
|
+
**Overlays:** [`<a11y-blocking-loader>`](#a11y-blocking-loader) · [`<a11y-context-menu>`](#a11y-context-menu) · [`<a11y-drawer>`](#a11y-drawer) · [`<a11y-dropdown>`](#a11y-dropdown) · [`<a11y-emergency-dialog>`](#a11y-emergency-dialog) · [`<a11y-modal>`](#a11y-modal) · [`<a11y-notification-banner>`](#a11y-notification-banner) · [`<a11y-popover>`](#a11y-popover) · [`<a11y-snackbar>`](#a11y-snackbar) · [`<a11y-tooltip>`](#a11y-tooltip)
|
|
102
|
+
|
|
103
|
+
Import paths follow the folder names: `a11y-elements/components/<name>` or `a11y-elements/overlays/<name>` (add `/element` for the class), and `dist/browser/<group>/<name>/define.js` for zero-build.
|
|
104
|
+
|
|
105
|
+
Attributes that set a CSS variable (spinner `size`/`color`/…, avatar `size`, skeleton `width`/`height`) win over your own inline value for that variable only while they're set. See [Scope to one instance](#scope-to-one-instance).
|
|
106
|
+
|
|
107
|
+
### Accessibility components
|
|
108
|
+
|
|
109
|
+
#### `a11y-anchor`
|
|
110
|
+
|
|
111
|
+
Enhances a real `<a href>`:
|
|
112
|
+
|
|
113
|
+
* **Same-page links** (`href="#id"`) smooth-scroll to the target (instantly under `prefers-reduced-motion: reduce`), move focus to it, and announce the navigation to screen readers by the target's `aria-label`, `aria-labelledby` or heading, falling back to its `id`. The target is made focusable with `tabindex="-1"` while focused; a `tabindex` it already had is restored on blur. Space activates too.
|
|
114
|
+
* **New-tab links** (`target="_blank"` or a named target) get `rel="noopener noreferrer"` and "(opens in new tab)" appended to their accessible name.
|
|
115
|
+
|
|
116
|
+
Both strings can be [translated](#translating-built-in-strings).
|
|
117
|
+
|
|
118
|
+
```html
|
|
119
|
+
<a11y-anchor><a href="#section-2">Jump to section 2</a></a11y-anchor>
|
|
120
|
+
<a11y-anchor><a href="https://example.com" target="_blank">External site</a></a11y-anchor>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
| Name | Kind | Default | Description |
|
|
124
|
+
| --- | --- | --- | --- |
|
|
125
|
+
| `new-tab-label` | attribute | `(opens in new tab)` | Suffix added to new-tab links' accessible name. |
|
|
126
|
+
| `navigated-label` | attribute | `Navigated to {name}` | Jump announcement; `{name}` is replaced by the target's name. |
|
|
127
|
+
|
|
128
|
+
No CSS variables of its own: style the `<a>` directly.
|
|
46
129
|
|
|
47
|
-
|
|
130
|
+
#### `a11y-avatar`
|
|
131
|
+
|
|
132
|
+
An avatar image with an initials fallback. When the image is missing or fails to load, the initials show instead and the element gets `role="img"` with an `aria-label`.
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<a11y-avatar alt="Jane Doe" src="jane.jpg" initials="JD" size="3rem"></a11y-avatar>
|
|
136
|
+
<a11y-avatar alt="John Roe" initials="JR" shape="square"></a11y-avatar>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
| Name | Kind | Default | Description |
|
|
140
|
+
| --- | --- | --- | --- |
|
|
141
|
+
| `src` | attribute | — | Image URL. |
|
|
142
|
+
| `alt` | attribute / property | `''` | Image alt text; also the accessible name of the initials fallback (then `initials`, then `Avatar`). |
|
|
143
|
+
| `initials` | attribute | — | Text shown when there's no image, or it fails to load. |
|
|
144
|
+
| `size` | attribute | — | Sets `--a11y-avatar-size`. |
|
|
145
|
+
| `shape` | attribute / property | `circle` | `circle` or `square`. |
|
|
146
|
+
|
|
147
|
+
<details>
|
|
148
|
+
<summary>CSS variables</summary>
|
|
149
|
+
|
|
150
|
+
| Variable | Default |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `--a11y-avatar-border-radius-circle` | `9999px` |
|
|
153
|
+
| `--a11y-avatar-border-radius-square` | `4px` |
|
|
154
|
+
| `--a11y-avatar-color-surface` | `#f3f4f6` |
|
|
155
|
+
| `--a11y-avatar-color-text-muted` | `#6b7280` |
|
|
156
|
+
| `--a11y-avatar-font-family` | `Arial, sans-serif` |
|
|
157
|
+
| `--a11y-avatar-font-size-ratio` | `0.38` |
|
|
158
|
+
| `--a11y-avatar-font-weight` | `600` |
|
|
159
|
+
| `--a11y-avatar-initials-letter-spacing` | `0.05em` |
|
|
160
|
+
| `--a11y-avatar-size` | `2.5rem` |
|
|
161
|
+
|
|
162
|
+
</details>
|
|
163
|
+
|
|
164
|
+
#### `a11y-checkbox`
|
|
165
|
+
|
|
166
|
+
Wraps a real `<input type="checkbox">` in a `<label>` with a visible label text. The input stays yours: `name`, `checked`, `disabled`, `required` are plain HTML attributes on it.
|
|
48
167
|
|
|
49
168
|
```html
|
|
50
169
|
<a11y-checkbox id="terms" label="Accept terms">
|
|
51
|
-
<input type="checkbox" name="terms">
|
|
170
|
+
<input type="checkbox" name="terms" required>
|
|
52
171
|
</a11y-checkbox>
|
|
53
172
|
```
|
|
54
173
|
|
|
55
174
|
```ts
|
|
56
|
-
import 'a11y-elements/
|
|
57
|
-
import type { CheckboxElement } from 'a11y-elements/
|
|
175
|
+
import 'a11y-elements/components/checkbox';
|
|
176
|
+
import type { CheckboxElement } from 'a11y-elements/components/checkbox/element';
|
|
58
177
|
|
|
59
178
|
const checkbox = document.getElementById('terms') as CheckboxElement;
|
|
60
179
|
checkbox.onChange = (checked) => console.log('accepted:', checked);
|
|
61
180
|
```
|
|
62
181
|
|
|
63
|
-
|
|
182
|
+
| Name | Kind | Default | Description |
|
|
183
|
+
| --- | --- | --- | --- |
|
|
184
|
+
| `label` | attribute | — | Visible label text. |
|
|
185
|
+
| `indeterminate` | attribute | absent | Sets the input's `indeterminate` state (it has no HTML attribute of its own). |
|
|
186
|
+
| `onChange` | callback | — | `(checked: boolean) => void`, called on every `change`. |
|
|
187
|
+
| `getValue()` / `setValue(checked)` | method | — | Reads / sets `checked`. |
|
|
188
|
+
|
|
189
|
+
<details>
|
|
190
|
+
<summary>CSS variables</summary>
|
|
191
|
+
|
|
192
|
+
| Variable | Default |
|
|
193
|
+
| --- | --- |
|
|
194
|
+
| `--a11y-checkbox-border-radius` | `2px` |
|
|
195
|
+
| `--a11y-checkbox-checkmark-background-size` | `75%` |
|
|
196
|
+
| `--a11y-checkbox-color-background` | `#ffffff` |
|
|
197
|
+
| `--a11y-checkbox-color-border` | `#d1d5db` |
|
|
198
|
+
| `--a11y-checkbox-color-border-strong` | `#9ca3af` |
|
|
199
|
+
| `--a11y-checkbox-color-disabled-bg` | `#e5e7eb` |
|
|
200
|
+
| `--a11y-checkbox-color-primary` | `#2563eb` |
|
|
201
|
+
| `--a11y-checkbox-color-text` | `#111827` |
|
|
202
|
+
| `--a11y-checkbox-disabled-opacity` | `0.6` |
|
|
203
|
+
| `--a11y-checkbox-focus-outline-offset` | `2px` |
|
|
204
|
+
| `--a11y-checkbox-focus-outline-width` | `2px` |
|
|
205
|
+
| `--a11y-checkbox-gap` | `0.5rem` |
|
|
206
|
+
| `--a11y-checkbox-input-border-width` | `2px` |
|
|
207
|
+
| `--a11y-checkbox-input-size` | `1.125rem` |
|
|
208
|
+
| `--a11y-checkbox-label-font-size` | `1rem` |
|
|
209
|
+
| `--a11y-checkbox-label-line-height` | `1.4` |
|
|
210
|
+
| `--a11y-checkbox-transition-duration` | `0.2s` |
|
|
211
|
+
|
|
212
|
+
</details>
|
|
213
|
+
|
|
214
|
+
#### `a11y-checkbox-group`
|
|
215
|
+
|
|
216
|
+
Wraps your checkboxes in a `<fieldset>` with a `<legend>`, styled like `<a11y-checkbox>`. Add `select-all` for a "Select all" checkbox: it's checked when every option is, partly checked when some are, and checks or unchecks them all. It has no `name`, so it's never submitted, and disabled options keep their own state.
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<a11y-checkbox-group id="toppings" legend="Toppings" select-all>
|
|
220
|
+
<label><input type="checkbox" name="toppings" value="cheese"> Cheese</label>
|
|
221
|
+
<label><input type="checkbox" name="toppings" value="ham"> Ham</label>
|
|
222
|
+
</a11y-checkbox-group>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
import 'a11y-elements/components/checkbox-group';
|
|
227
|
+
import type { CheckboxGroupElement } from 'a11y-elements/components/checkbox-group/element';
|
|
228
|
+
|
|
229
|
+
const group = document.getElementById('toppings') as CheckboxGroupElement;
|
|
230
|
+
group.onChange = (values) => console.log('toppings:', values);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
| Name | Kind | Default | Description |
|
|
234
|
+
| --- | --- | --- | --- |
|
|
235
|
+
| `legend` | attribute | — | Visible group label. |
|
|
236
|
+
| `aria-label` | attribute | — | Group name when there's no `legend`. |
|
|
237
|
+
| `disabled` | attribute | absent | Disables every option (through the fieldset). |
|
|
238
|
+
| `select-all` | attribute | absent | Adds the "Select all" checkbox after the legend. |
|
|
239
|
+
| `select-all-label` | attribute | `Select all` | Its text; also `setStrings({ selectAll })`. |
|
|
240
|
+
| `onChange` | callback | — | `(values: string[]) => void`, called once per user action, a "Select all" click included. |
|
|
241
|
+
| `getValue()` / `setValue(values)` | method | — | Reads the checked values / checks exactly those values. |
|
|
242
|
+
| `selectAll()` / `unselectAll()` | method | — | Checks / unchecks every enabled option. Like `setValue()`, fires no events. |
|
|
243
|
+
|
|
244
|
+
A "Select all" click fires `input` and `change` on every option it changes.
|
|
245
|
+
|
|
246
|
+
Options use the `--a11y-checkbox-*` variables above.
|
|
247
|
+
|
|
248
|
+
<details>
|
|
249
|
+
<summary>CSS variables</summary>
|
|
250
|
+
|
|
251
|
+
| Variable | Default |
|
|
252
|
+
| --- | --- |
|
|
253
|
+
| `--a11y-checkbox-group-color-text-muted` | `#6b7280` |
|
|
254
|
+
| `--a11y-checkbox-group-disabled-opacity` | `0.6` |
|
|
255
|
+
| `--a11y-checkbox-group-legend-font-size` | `0.875rem` |
|
|
256
|
+
| `--a11y-checkbox-group-legend-margin-bottom` | `0.5rem` |
|
|
257
|
+
| `--a11y-checkbox-group-options-gap` | `0.5rem` |
|
|
258
|
+
| `--a11y-checkbox-group-select-all-border` | `1px solid #e5e7eb` |
|
|
259
|
+
| `--a11y-checkbox-group-select-all-padding-bottom` | `0.5rem` |
|
|
260
|
+
|
|
261
|
+
</details>
|
|
262
|
+
|
|
263
|
+
#### `a11y-file-input`
|
|
264
|
+
|
|
265
|
+
A file picker built from a real `<input type="file">`, with the same parts as [`a11y-input`](#a11y-input). Files can be browsed for or dropped onto the element. It only picks files: the input keeps its `name` and submits them with the form, or you read `getValue()` and upload them yourself.
|
|
266
|
+
|
|
267
|
+
```html
|
|
268
|
+
<a11y-file-input max-size="5MB" max-files="3" previews value-missing-message="Add at least one file">
|
|
269
|
+
<a11y-label>Attachments</a11y-label>
|
|
270
|
+
<input type="file" name="attachments" multiple accept=".pdf,image/*" required>
|
|
271
|
+
<a11y-hint>PDF or images, up to 5 MB each.</a11y-hint>
|
|
272
|
+
<a11y-error></a11y-error>
|
|
273
|
+
</a11y-file-input>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
It adds, after the input, a drop zone with a "Browse files" button, then (after your parts) the list of selected files, the list of files that weren't added, and a status region for announcements.
|
|
277
|
+
|
|
278
|
+
**Accessibility.**
|
|
279
|
+
|
|
280
|
+
* The native input is visually hidden, not removed. It's still the control that gets focus, is announced as a file button, carries `required`, and gets the field's `aria-describedby` and `aria-invalid`. The focus ring shows on "Browse files".
|
|
281
|
+
* "Browse files" is a real `<label>` for the input, so it opens the picker without script, and its text is part of the input's accessible name (voice control users can say "click Browse files").
|
|
282
|
+
* Dragging is a shortcut, never the only way: everything works from the keyboard. The drop prompt is hidden from assistive tech.
|
|
283
|
+
* Each file has a "Remove" button named "Remove report.pdf". After a removal, focus moves to the next file's button, else the previous one, else the input.
|
|
284
|
+
* What was added, removed or not added is announced politely. Files that weren't added are also listed on screen with the reason, until the next change.
|
|
285
|
+
* Errors show with the same timing as `<a11y-input>`, plus right after a drop or a removal: removing the last file of a `required` field shows the error at once.
|
|
286
|
+
|
|
287
|
+
**Rules.** `accept` (checked on drop too, which the browser doesn't do), `max-size` and `max-files` are checked as files come in. A file that fails one is not added, so these rules never make the field invalid. `required` and `validators` still do: validators get the input as their second argument, so they can read `control.files`.
|
|
288
|
+
|
|
289
|
+
With `multiple`, browsing or dropping again adds to the selection (duplicates are skipped) instead of replacing it. Without it, the new file replaces the current one, unless it's rejected.
|
|
290
|
+
|
|
291
|
+
Style the drag-over state with `a11y-file-input:state(dragover)` or `.a11y-file-input__dropzone[data-dragover]`. The `:state(touched)`, `:state(dirty)` and `:state(user-invalid)` states work as on `<a11y-input>`.
|
|
292
|
+
|
|
293
|
+
| Name | Kind | Default | Description |
|
|
294
|
+
| --- | --- | --- | --- |
|
|
295
|
+
| `max-size` | attribute | — | Largest file accepted: `500KB`, `5MB`, `1GB` or bytes (1 KB = 1024 bytes). |
|
|
296
|
+
| `max-files` | attribute | — | Most files the selection can hold, with `multiple`. |
|
|
297
|
+
| `previews` | attribute | `false` | Shows a thumbnail next to image files. |
|
|
298
|
+
| `browse-label` / `drop-label` | attribute | see [strings](#translating-built-in-strings) | Text of the browse button / of the drop prompt. |
|
|
299
|
+
| `type-rejected-message` / `size-rejected-message` / `count-rejected-message` | attribute | see [strings](#translating-built-in-strings) | Why a file wasn't added. `{name}`, `{maxSize}` and `{max}` are filled in. |
|
|
300
|
+
| `value-missing-message`, … | attribute | browser's | As on [`a11y-input`](#a11y-input). |
|
|
301
|
+
| `validators` | property | `[]` | As on `a11y-input`; the second argument is the input. |
|
|
302
|
+
| `onChange` / `onInput` | callback | — | `(files: File[]) => void`, called once per pick, drop or removal. |
|
|
303
|
+
| `getValue()` | method | — | The selected files. |
|
|
304
|
+
| `setValue(files)` | method | — | Replaces the selection, silently: no events, no announcement. The rules still apply. |
|
|
305
|
+
| `addFiles(files)` | method | — | Adds files as a drop would: checked, announced, then `input` and `change` fire. Handy for a paste handler. |
|
|
306
|
+
| `removeFile(fileOrIndex)` / `clear()` | method | — | Removes one file / all of them, silently. |
|
|
307
|
+
| `checkValidity()` / `reportValidity()` | method | — | As on `a11y-input`. |
|
|
308
|
+
|
|
309
|
+
Sizes are formatted with `Intl` in the language of the closest `lang` attribute (`1.5 MB`, `1,5 Mo`, …).
|
|
310
|
+
|
|
311
|
+
<details>
|
|
312
|
+
<summary>CSS variables</summary>
|
|
313
|
+
|
|
314
|
+
| Variable | Default |
|
|
315
|
+
| --- | --- |
|
|
316
|
+
| `--a11y-file-input-button-border-radius` | `4px` |
|
|
317
|
+
| `--a11y-file-input-button-font-weight` | `600` |
|
|
318
|
+
| `--a11y-file-input-button-padding-x` | `1rem` |
|
|
319
|
+
| `--a11y-file-input-button-padding-y` | `0.5rem` |
|
|
320
|
+
| `--a11y-file-input-color-background` | `#ffffff` |
|
|
321
|
+
| `--a11y-file-input-color-border` | `#d1d5db` |
|
|
322
|
+
| `--a11y-file-input-color-disabled-bg` | `#e5e7eb` |
|
|
323
|
+
| `--a11y-file-input-color-disabled-text` | `#9ca3af` |
|
|
324
|
+
| `--a11y-file-input-color-dragover-bg` | `#eff6ff` |
|
|
325
|
+
| `--a11y-file-input-color-error` | `#b91c1c` |
|
|
326
|
+
| `--a11y-file-input-color-primary` | `#2563eb` |
|
|
327
|
+
| `--a11y-file-input-color-text` | `#111827` |
|
|
328
|
+
| `--a11y-file-input-color-text-muted` | `#6b7280` |
|
|
329
|
+
| `--a11y-file-input-dropzone-border-radius` | `8px` |
|
|
330
|
+
| `--a11y-file-input-dropzone-border-width` | `2px` |
|
|
331
|
+
| `--a11y-file-input-dropzone-gap` | `0.5rem` |
|
|
332
|
+
| `--a11y-file-input-dropzone-padding` | `1.5rem 1rem` |
|
|
333
|
+
| `--a11y-file-input-focus-outline-offset` | `2px` |
|
|
334
|
+
| `--a11y-file-input-focus-outline-width` | `2px` |
|
|
335
|
+
| `--a11y-file-input-gap` | `0.25rem` |
|
|
336
|
+
| `--a11y-file-input-item-border-radius` | `4px` |
|
|
337
|
+
| `--a11y-file-input-item-gap` | `0.75rem` |
|
|
338
|
+
| `--a11y-file-input-item-padding` | `0.5rem 0.75rem` |
|
|
339
|
+
| `--a11y-file-input-list-gap` | `0.5rem` |
|
|
340
|
+
| `--a11y-file-input-list-margin-top` | `0.25rem` |
|
|
341
|
+
| `--a11y-file-input-preview-border-radius` | `4px` |
|
|
342
|
+
| `--a11y-file-input-preview-size` | `2.5rem` |
|
|
343
|
+
| `--a11y-file-input-transition-duration` | `0.2s` |
|
|
344
|
+
|
|
345
|
+
The hint and error use the [shared field variables](#a11y-input).
|
|
346
|
+
|
|
347
|
+
</details>
|
|
348
|
+
|
|
349
|
+
#### `a11y-focusable`
|
|
350
|
+
|
|
351
|
+
Makes a non-button element behave like a button: `role="button"`, `tabindex="0"`, and Enter/Space fire a real `click`, so one `click` listener covers mouse and keyboard. Prefer a real `<button>` whenever you can.
|
|
352
|
+
|
|
353
|
+
```html
|
|
354
|
+
<a11y-focusable aria-label="Expand menu">
|
|
355
|
+
<svg aria-hidden="true">…</svg> Menu
|
|
356
|
+
</a11y-focusable>
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
| Name | Kind | Default | Description |
|
|
360
|
+
| --- | --- | --- | --- |
|
|
361
|
+
| `aria-label` | attribute | — | Accessible name. Without it (or visible text), a console warning is logged. |
|
|
362
|
+
|
|
363
|
+
No CSS variables.
|
|
364
|
+
|
|
365
|
+
#### `a11y-input`
|
|
366
|
+
|
|
367
|
+
A text field built from a real `<input>` and optional parts, wired together for you:
|
|
368
|
+
|
|
369
|
+
* `<a11y-label>`: the visible label, linked with `for`. See [`a11y-label`](#a11y-label).
|
|
370
|
+
* `<a11y-hint>`: help text, any number of them, added to the input's `aria-describedby`.
|
|
371
|
+
* `<a11y-error>`: where the validation message is shown. It's hidden, and left out of `aria-describedby`, until there's an error to show.
|
|
372
|
+
* `<a11y-counter>`: a length counter, see [`a11y-textarea`](#a11y-textarea).
|
|
373
|
+
|
|
374
|
+
```html
|
|
375
|
+
<form>
|
|
376
|
+
<a11y-input type-mismatch-message="Enter an email like name@example.com">
|
|
377
|
+
<a11y-label>Email</a11y-label>
|
|
378
|
+
<input type="email" name="email" required>
|
|
379
|
+
<a11y-hint>We never share it.</a11y-hint>
|
|
380
|
+
<a11y-error></a11y-error>
|
|
381
|
+
</a11y-input>
|
|
382
|
+
</form>
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
The input stays yours and is never regenerated.
|
|
386
|
+
|
|
387
|
+
It keeps its `name` and submits its own value, so the form works before the script loads, and native constraints (`required`, `type`, `pattern`, `minlength`, `min`, …) do the validating.
|
|
388
|
+
|
|
389
|
+
Ids you set are kept; missing ones are generated.
|
|
390
|
+
|
|
391
|
+
- **When errors show.**
|
|
392
|
+
|
|
393
|
+
Like `:user-invalid`, a field isn't flagged while it's first being filled in.
|
|
394
|
+
|
|
395
|
+
Its error shows when it's left after an edit, or when a submit attempt finds it invalid.
|
|
396
|
+
|
|
397
|
+
From then on it updates as the user types, and a form reset hides it again.
|
|
398
|
+
|
|
399
|
+
While shown, the input has `aria-invalid="true"` and the message is in its `aria-describedby`.
|
|
400
|
+
|
|
401
|
+
- **Submitting.**
|
|
402
|
+
|
|
403
|
+
With an `<a11y-error>`, the message is shown there instead of in the browser's bubble, and the form's first invalid field is focused. Without one, the browser's bubble is left alone.
|
|
404
|
+
|
|
405
|
+
- **Why the submit button stays enabled.**
|
|
406
|
+
|
|
407
|
+
Nothing here disables your submit button while fields are invalid, and doing it yourself is best avoided.
|
|
408
|
+
|
|
409
|
+
A disabled button doesn't say what's wrong, leaves the Tab order (screen reader and keyboard users may not find it at all), is often too faint to read, and makes a form look invalid before anything has been typed.
|
|
410
|
+
|
|
411
|
+
Instead, let the submit happen: it's blocked, each error shows next to its field, and focus moves to the first invalid one.
|
|
412
|
+
|
|
413
|
+
Disabling the button *while a submission is in flight*, to prevent double submits, is a different matter and is fine as long as the busy state is announced.
|
|
414
|
+
|
|
415
|
+
**Empty fields.** Validation follows the browser's rules, which have two consequences:
|
|
416
|
+
|
|
417
|
+
* Every constraint except `required` skips an empty value. `minlength`, `pattern`, `type="email"`, `min`, … all pass on `""`, so a field without `required` is valid when empty: the form submits and no error shows. Add `required` (and `value-missing-message`) when the field must be filled.
|
|
418
|
+
* `minlength` / `maxlength` only flag a value the user typed. A value set from code (`control.value`, `setValue()`) passes them until it's edited.
|
|
419
|
+
|
|
420
|
+
`validators` do run on an empty value. To keep an optional field optional, return `null` for `""`.
|
|
421
|
+
|
|
422
|
+
**Custom rules.** `validators` run in order once the native constraints pass; the first message returned is the error. It goes through `setCustomValidity()`, so it blocks submission like a native one. Set `validators` instead of calling `setCustomValidity()` yourself, which the next validation would clear.
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
import 'a11y-elements/components/input';
|
|
426
|
+
import type { InputElement } from 'a11y-elements/components/input/element';
|
|
427
|
+
|
|
428
|
+
const username = document.getElementById('username') as InputElement;
|
|
429
|
+
username.validators = [(value) => (takenNames.has(value) ? 'That name is taken' : null)];
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**The host is form-associated.** It mirrors the input through `ElementInternals`: its validity follows the input's (anchored to it), and it exposes custom states for styling:
|
|
433
|
+
|
|
434
|
+
```css
|
|
435
|
+
a11y-input:state(user-invalid) { background: #fef2f2; } /* the error is shown */
|
|
436
|
+
a11y-input:state(touched) { … } /* left at least once */
|
|
437
|
+
a11y-input:state(dirty) { … } /* edited at least once */
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Where `:state()` isn't supported, style `input[aria-invalid="true"]` instead.
|
|
441
|
+
|
|
442
|
+
Checkbox, radio, range, color, file, hidden and button inputs are left alone: use `<a11y-checkbox>`, `<a11y-checkbox-group>`, `<a11y-radio-group>`, … for those.
|
|
443
|
+
|
|
444
|
+
| Name | Kind | Default | Description |
|
|
445
|
+
| --- | --- | --- | --- |
|
|
446
|
+
| `value-missing-message` | attribute | browser's | Message when `required` isn't met. |
|
|
447
|
+
| `type-mismatch-message` | attribute | browser's | Message when the value doesn't match `type` (`email`, `url`). |
|
|
448
|
+
| `pattern-mismatch-message` | attribute | browser's | Message when the value doesn't match `pattern`. |
|
|
449
|
+
| `too-short-message` / `too-long-message` | attribute | browser's | Messages for `minlength` / `maxlength`. |
|
|
450
|
+
| `range-underflow-message` / `range-overflow-message` | attribute | browser's | Messages for `min` / `max`. |
|
|
451
|
+
| `step-mismatch-message` / `bad-input-message` | attribute | browser's | Messages for `step`, and for input the browser can't parse (e.g. text in a number field). |
|
|
452
|
+
| `validators` | property | `[]` | `((value, control) => string \| null)[]`, run after the native constraints. |
|
|
453
|
+
| `onInput` / `onChange` | callback | — | `(value: string) => void`, called on every `input` / `change`. |
|
|
454
|
+
| `getValue()` / `setValue(value)` | method | — | Reads / sets the value. `setValue` re-validates without marking the field as edited. |
|
|
455
|
+
| `checkValidity()` | method | — | Returns whether the field is valid, without showing anything. |
|
|
456
|
+
| `reportValidity()` | method | — | Shows the error and focuses the input when it's invalid. |
|
|
457
|
+
| `validity` / `validationMessage` / `willValidate` / `form` | property | — | Same as on the input; `validationMessage` includes your overrides. |
|
|
458
|
+
|
|
459
|
+
Message attributes can use `{min}`, `{max}`, `{minlength}` and `{maxlength}`, filled from the input's attributes: `too-short-message="At least {minlength} characters"`.
|
|
460
|
+
|
|
461
|
+
<details>
|
|
462
|
+
<summary>CSS variables</summary>
|
|
463
|
+
|
|
464
|
+
| Variable | Default |
|
|
465
|
+
| --- | --- |
|
|
466
|
+
| `--a11y-input-color-background` | `#ffffff` |
|
|
467
|
+
| `--a11y-input-color-border` | `#d1d5db` |
|
|
468
|
+
| `--a11y-input-color-border-strong` | `#9ca3af` |
|
|
469
|
+
| `--a11y-input-color-disabled-bg` | `#e5e7eb` |
|
|
470
|
+
| `--a11y-input-color-disabled-text` | `#9ca3af` |
|
|
471
|
+
| `--a11y-input-color-error` | `#b91c1c` |
|
|
472
|
+
| `--a11y-input-color-primary` | `#2563eb` |
|
|
473
|
+
| `--a11y-input-color-text` | `#111827` |
|
|
474
|
+
| `--a11y-input-control-border-radius` | `4px` |
|
|
475
|
+
| `--a11y-input-control-border-width` | `1px` |
|
|
476
|
+
| `--a11y-input-control-font-family` | `inherit` |
|
|
477
|
+
| `--a11y-input-control-font-size` | `1rem` |
|
|
478
|
+
| `--a11y-input-control-line-height` | `1.4` |
|
|
479
|
+
| `--a11y-input-control-padding-x` | `0.75rem` |
|
|
480
|
+
| `--a11y-input-control-padding-y` | `0.5rem` |
|
|
481
|
+
| `--a11y-input-focus-outline-offset` | `2px` |
|
|
482
|
+
| `--a11y-input-focus-outline-width` | `2px` |
|
|
483
|
+
| `--a11y-input-gap` | `0.25rem` |
|
|
484
|
+
| `--a11y-input-transition-duration` | `0.2s` |
|
|
485
|
+
|
|
486
|
+
Shared by the parts of every field:
|
|
487
|
+
|
|
488
|
+
| Variable | Default |
|
|
489
|
+
| --- | --- |
|
|
490
|
+
| `--a11y-field-color-error` | `#b91c1c` |
|
|
491
|
+
| `--a11y-field-color-text-muted` | `#6b7280` |
|
|
492
|
+
| `--a11y-field-error-font-weight` | `600` |
|
|
493
|
+
| `--a11y-field-part-font-size` | `0.875rem` |
|
|
494
|
+
| `--a11y-field-part-line-height` | `1.4` |
|
|
495
|
+
|
|
496
|
+
</details>
|
|
497
|
+
|
|
498
|
+
##### Building your own field: `bindField()`
|
|
499
|
+
|
|
500
|
+
The same wiring, without the custom elements: `bindField()` takes the control and its parts as any elements you like, for example from a framework component. It's exported from `a11y-elements/core`, and from the input and textarea `define.js` bundles.
|
|
501
|
+
|
|
502
|
+
```ts
|
|
503
|
+
import { bindField } from 'a11y-elements/core';
|
|
504
|
+
|
|
505
|
+
const field = bindField(
|
|
506
|
+
{ control: input, label: labelEl, hints: [hintEl], error: errorEl, counter: counterEl },
|
|
507
|
+
{
|
|
508
|
+
validators: [(value) => (value.includes(' ') ? 'No spaces' : null)],
|
|
509
|
+
messages: { valueMissing: 'Required', tooShort: 'At least {minlength} characters' },
|
|
510
|
+
onStateChange: ({ valid, message, touched, dirty, showError }) => { /* mirror it in your state */ },
|
|
511
|
+
},
|
|
512
|
+
);
|
|
513
|
+
|
|
514
|
+
field.sync({ control: input, label: labelEl, hints: [], error: errorEl }); // after parts change
|
|
515
|
+
field.show(); // show the error now, as a submit attempt would
|
|
516
|
+
field.reset(); // back to pristine (also happens on its own on form reset)
|
|
517
|
+
field.destroy(); // on unmount: removes its listeners and the ARIA it added
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
A real `<label>` is linked with `for`; any other element with `aria-labelledby`. Tokens you put in `aria-describedby` / `aria-labelledby` yourself are kept.
|
|
521
|
+
|
|
522
|
+
#### `a11y-label`
|
|
523
|
+
|
|
524
|
+
Renders a real `<label class="a11y-label">` around its content. A custom element can't itself be a `<label>`, and only a real one gives click-to-focus and native naming. Inside `<a11y-input>` / `<a11y-textarea>` it's linked automatically; on its own, `for` is forwarded:
|
|
525
|
+
|
|
526
|
+
```html
|
|
527
|
+
<a11y-label for="search">Search</a11y-label>
|
|
528
|
+
<input id="search" type="search">
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
A `*` marks a required field. It's CSS only and hidden from screen readers, which already announce the control's `required`.
|
|
532
|
+
|
|
533
|
+
| Name | Kind | Default | Description |
|
|
534
|
+
| --- | --- | --- | --- |
|
|
535
|
+
| `for` | attribute | — | Id of the control to label, when used outside a field. |
|
|
536
|
+
| `required` | attribute | absent | Shows the required marker outside a field (inside one, it follows the control's `required`). |
|
|
537
|
+
| `label` | property | — | The rendered `<label>` element. |
|
|
538
|
+
|
|
539
|
+
<details>
|
|
540
|
+
<summary>CSS variables</summary>
|
|
541
|
+
|
|
542
|
+
| Variable | Default |
|
|
543
|
+
| --- | --- |
|
|
544
|
+
| `--a11y-label-color-required` | `#b91c1c` |
|
|
545
|
+
| `--a11y-label-color-text` | `#111827` |
|
|
546
|
+
| `--a11y-label-font-size` | `0.875rem` |
|
|
547
|
+
| `--a11y-label-font-weight` | `600` |
|
|
548
|
+
| `--a11y-label-line-height` | `1.4` |
|
|
549
|
+
| `--a11y-label-required-gap` | `0.25em` |
|
|
550
|
+
| `--a11y-label-required-marker` | `"*"` |
|
|
551
|
+
|
|
552
|
+
</details>
|
|
553
|
+
|
|
554
|
+
#### `a11y-picture`
|
|
555
|
+
|
|
556
|
+
Wraps a `<picture>`/`<img>` and optional `<figcaption>`, yours or generated from attributes, as `role="figure"`. An image with `alt=""` and no caption is treated as decorative and hidden from assistive tech (`aria-hidden="true"`).
|
|
557
|
+
|
|
558
|
+
```html
|
|
559
|
+
<a11y-picture>
|
|
560
|
+
<picture>
|
|
561
|
+
<source srcset="hero.webp" type="image/webp">
|
|
562
|
+
<img src="hero.jpg" alt="Sunset over the Rockies" loading="lazy" decoding="async">
|
|
563
|
+
</picture>
|
|
564
|
+
<figcaption>Sunset over the Rockies</figcaption>
|
|
565
|
+
</a11y-picture>
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
**Several formats.** Instead of writing the markup, give the element a `src` (the fallback image) and it builds the `<picture>` itself: one `<source>` per format, then the `<img>`, plus a `<figcaption>` for `caption`. The browser uses the first source whose `type` it supports, else the fallback, so list the most efficient format first. A source without a `type` is always used, so give each one its type.
|
|
569
|
+
|
|
570
|
+
```html
|
|
571
|
+
<a11y-picture
|
|
572
|
+
src="s.jpg"
|
|
573
|
+
alt="S illustration"
|
|
574
|
+
sources="s.avif image/avif, s.webp image/webp"
|
|
575
|
+
caption="An illustration of S">
|
|
576
|
+
</a11y-picture>
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
The same from JavaScript, in one object:
|
|
580
|
+
|
|
581
|
+
```js
|
|
582
|
+
const base = './assets/images/s';
|
|
583
|
+
document.querySelector('a11y-picture').image = {
|
|
584
|
+
sources: [
|
|
585
|
+
{ src: `${base}.avif`, type: 'image/avif' },
|
|
586
|
+
{ src: `${base}.webp`, type: 'image/webp' },
|
|
587
|
+
],
|
|
588
|
+
fallback: `${base}.jpg`,
|
|
589
|
+
alt: 'S illustration',
|
|
590
|
+
};
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
* The `sources` attribute takes `url type` pairs. For srcset descriptors (`s.avif 1x, s@2x.avif 2x`), `media` or `sizes`, set the `sources` property in JavaScript.
|
|
594
|
+
* Use one way or the other: with a `src`, children you wrote are ignored.
|
|
595
|
+
* The same accessibility rule applies: with `alt=""` and no caption, the figure is hidden. Without any `alt`, the image is treated as decorative and a console warning asks for one.
|
|
596
|
+
|
|
597
|
+
| Name | Kind | Default | Description |
|
|
598
|
+
| --- | --- | --- | --- |
|
|
599
|
+
| `src` | attribute / property | — | The fallback image. Setting it switches to a generated picture. |
|
|
600
|
+
| `alt` | attribute / property | — | The image's text alternative; `""` for a decorative image. |
|
|
601
|
+
| `sources` | attribute | — | `url type` pairs, comma-separated: `"s.avif image/avif, s.webp image/webp"`. |
|
|
602
|
+
| `sources` | property | — | `{ src, type?, media?, sizes? }[]`; `src` can be a full srcset. Wins over the attribute until the attribute changes. |
|
|
603
|
+
| `caption` | attribute / property | — | Text of a generated `<figcaption>`. |
|
|
604
|
+
| `width` / `height` | attribute / property | — | The image's intrinsic size, to avoid layout shift. |
|
|
605
|
+
| `loading` | attribute / property | `lazy` | `lazy` or `eager`. The image is always `decoding="async"`. |
|
|
606
|
+
| `sizes` | attribute | — | `sizes` of the `<img>`. |
|
|
607
|
+
| `image` | property | — | Sets it all at once: `{ sources?, fallback, alt, caption?, width?, height?, loading? }`. |
|
|
608
|
+
|
|
609
|
+
The `PictureSource` and `PictureImage` types are exported with the element.
|
|
610
|
+
|
|
611
|
+
<details>
|
|
612
|
+
<summary>CSS variables</summary>
|
|
613
|
+
|
|
614
|
+
| Variable | Default |
|
|
615
|
+
| --- | --- |
|
|
616
|
+
| `--a11y-picture-caption-font-size` | `0.875rem` |
|
|
617
|
+
| `--a11y-picture-caption-line-height` | `1.4` |
|
|
618
|
+
| `--a11y-picture-caption-margin-top` | `0.25rem` |
|
|
619
|
+
| `--a11y-picture-color-text-muted` | `#6b7280` |
|
|
620
|
+
|
|
621
|
+
</details>
|
|
622
|
+
|
|
623
|
+
#### `a11y-progress`
|
|
624
|
+
|
|
625
|
+
A labelled progress bar around a native `<progress>`. Without `value`, it shows an indeterminate animation.
|
|
626
|
+
|
|
627
|
+
```html
|
|
628
|
+
<a11y-progress value="50" max="100" label="Uploading…"></a11y-progress>
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
| Name | Kind | Default | Description |
|
|
632
|
+
| --- | --- | --- | --- |
|
|
633
|
+
| `value` | attribute / property | — | Current value; absent means indeterminate. |
|
|
634
|
+
| `max` | attribute / property | `100` | Maximum value. |
|
|
635
|
+
| `label` | attribute | — | Visible label, used as the accessible name. |
|
|
636
|
+
| `aria-label` | attribute | `Progress` | Accessible name when there's no visible `label`. The default can be [translated](#translating-built-in-strings). |
|
|
637
|
+
|
|
638
|
+
<details>
|
|
639
|
+
<summary>CSS variables</summary>
|
|
640
|
+
|
|
641
|
+
| Variable | Default |
|
|
642
|
+
| --- | --- |
|
|
643
|
+
| `--a11y-progress-bar-border-radius` | `9999px` |
|
|
644
|
+
| `--a11y-progress-bar-height` | `0.5rem` |
|
|
645
|
+
| `--a11y-progress-bar-transition-duration` | `0.3s` |
|
|
646
|
+
| `--a11y-progress-color-primary` | `#2563eb` |
|
|
647
|
+
| `--a11y-progress-color-surface` | `#f3f4f6` |
|
|
648
|
+
| `--a11y-progress-color-text-muted` | `#6b7280` |
|
|
649
|
+
| `--a11y-progress-gap` | `0.25rem` |
|
|
650
|
+
| `--a11y-progress-indeterminate-duration` | `1.5s` |
|
|
651
|
+
| `--a11y-progress-label-font-size` | `0.875rem` |
|
|
652
|
+
| `--a11y-progress-label-font-weight` | `500` |
|
|
653
|
+
|
|
654
|
+
</details>
|
|
655
|
+
|
|
656
|
+
#### `a11y-radio-group`
|
|
657
|
+
|
|
658
|
+
Wraps your radios in a `<fieldset>` with a `<legend>`. Give every radio the same `name`; that's what makes them one native group.
|
|
659
|
+
|
|
660
|
+
```html
|
|
661
|
+
<a11y-radio-group legend="Choose a plan">
|
|
662
|
+
<label><input type="radio" name="plan" value="basic"> Basic</label>
|
|
663
|
+
<label><input type="radio" name="plan" value="pro"> Pro</label>
|
|
664
|
+
</a11y-radio-group>
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
| Name | Kind | Default | Description |
|
|
668
|
+
| --- | --- | --- | --- |
|
|
669
|
+
| `legend` | attribute | — | Visible group label. |
|
|
670
|
+
| `aria-label` | attribute | — | Group name when there's no `legend`. |
|
|
671
|
+
| `disabled` | attribute | absent | Disables every option (through the fieldset). |
|
|
672
|
+
| `onChange` | callback | — | `(value: string) => void`, called when an option is checked. |
|
|
673
|
+
| `getValue()` / `setValue(value)` | method | — | Reads the checked value / checks the option with that value. |
|
|
674
|
+
|
|
675
|
+
<details>
|
|
676
|
+
<summary>CSS variables</summary>
|
|
677
|
+
|
|
678
|
+
| Variable | Default |
|
|
679
|
+
| --- | --- |
|
|
680
|
+
| `--a11y-radio-group-checked-inner-ring` | `0.2rem` |
|
|
681
|
+
| `--a11y-radio-group-checked-outer-ring` | `0.5rem` |
|
|
682
|
+
| `--a11y-radio-group-color-background` | `#ffffff` |
|
|
683
|
+
| `--a11y-radio-group-color-border` | `#d1d5db` |
|
|
684
|
+
| `--a11y-radio-group-color-border-strong` | `#9ca3af` |
|
|
685
|
+
| `--a11y-radio-group-color-disabled-bg` | `#e5e7eb` |
|
|
686
|
+
| `--a11y-radio-group-color-primary` | `#2563eb` |
|
|
687
|
+
| `--a11y-radio-group-color-text` | `#111827` |
|
|
688
|
+
| `--a11y-radio-group-color-text-muted` | `#6b7280` |
|
|
689
|
+
| `--a11y-radio-group-disabled-opacity` | `0.6` |
|
|
690
|
+
| `--a11y-radio-group-focus-outline-offset` | `2px` |
|
|
691
|
+
| `--a11y-radio-group-focus-outline-width` | `2px` |
|
|
692
|
+
| `--a11y-radio-group-input-border-width` | `2px` |
|
|
693
|
+
| `--a11y-radio-group-input-size` | `1.125rem` |
|
|
694
|
+
| `--a11y-radio-group-input-transition-duration` | `0.2s` |
|
|
695
|
+
| `--a11y-radio-group-label-font-size` | `1rem` |
|
|
696
|
+
| `--a11y-radio-group-label-line-height` | `1.4` |
|
|
697
|
+
| `--a11y-radio-group-legend-font-size` | `0.875rem` |
|
|
698
|
+
| `--a11y-radio-group-legend-margin-bottom` | `0.5rem` |
|
|
699
|
+
| `--a11y-radio-group-option-gap` | `0.5rem` |
|
|
700
|
+
| `--a11y-radio-group-options-gap` | `0.5rem` |
|
|
701
|
+
|
|
702
|
+
</details>
|
|
703
|
+
|
|
704
|
+
#### `a11y-select`
|
|
705
|
+
|
|
706
|
+
Wraps a real `<select>` in a `<label>` with a visible label text. Options and keyboard handling stay native.
|
|
707
|
+
|
|
708
|
+
```html
|
|
709
|
+
<a11y-select label="Country">
|
|
710
|
+
<select name="country">
|
|
711
|
+
<option value="us">United States</option>
|
|
712
|
+
<option value="ca">Canada</option>
|
|
713
|
+
</select>
|
|
714
|
+
</a11y-select>
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
| Name | Kind | Default | Description |
|
|
718
|
+
| --- | --- | --- | --- |
|
|
719
|
+
| `label` | attribute | — | Visible label text. |
|
|
720
|
+
| `onChange` | callback | — | `(value: string) => void`, called on every `change`. |
|
|
721
|
+
| `getValue()` / `setValue(value)` | method | — | Reads / sets the selected value. |
|
|
722
|
+
|
|
723
|
+
<details>
|
|
724
|
+
<summary>CSS variables</summary>
|
|
725
|
+
|
|
726
|
+
| Variable | Default |
|
|
727
|
+
| --- | --- |
|
|
728
|
+
| `--a11y-select-color-border` | `#d1d5db` |
|
|
729
|
+
| `--a11y-select-color-border-strong` | `#9ca3af` |
|
|
730
|
+
| `--a11y-select-color-disabled-bg` | `#e5e7eb` |
|
|
731
|
+
| `--a11y-select-color-disabled-text` | `#9ca3af` |
|
|
732
|
+
| `--a11y-select-color-primary` | `#2563eb` |
|
|
733
|
+
| `--a11y-select-color-surface` | `#f3f4f6` |
|
|
734
|
+
| `--a11y-select-color-text` | `#111827` |
|
|
735
|
+
| `--a11y-select-color-text-muted` | `#6b7280` |
|
|
736
|
+
| `--a11y-select-control-border-radius` | `4px` |
|
|
737
|
+
| `--a11y-select-control-border-width` | `1px` |
|
|
738
|
+
| `--a11y-select-control-font-family` | `Arial, sans-serif` |
|
|
739
|
+
| `--a11y-select-control-font-size` | `1rem` |
|
|
740
|
+
| `--a11y-select-control-line-height` | `1.4` |
|
|
741
|
+
| `--a11y-select-control-padding-x` | `1rem` |
|
|
742
|
+
| `--a11y-select-control-padding-y` | `0.5rem` |
|
|
743
|
+
| `--a11y-select-control-transition-duration` | `0.2s` |
|
|
744
|
+
| `--a11y-select-focus-outline-offset` | `2px` |
|
|
745
|
+
| `--a11y-select-focus-outline-width` | `2px` |
|
|
746
|
+
| `--a11y-select-gap` | `0.25rem` |
|
|
747
|
+
| `--a11y-select-label-font-size` | `0.875rem` |
|
|
748
|
+
| `--a11y-select-label-font-weight` | `600` |
|
|
749
|
+
|
|
750
|
+
</details>
|
|
751
|
+
|
|
752
|
+
#### `a11y-skeleton`
|
|
753
|
+
|
|
754
|
+
A loading placeholder, hidden from assistive tech.
|
|
755
|
+
|
|
756
|
+
```html
|
|
757
|
+
<a11y-skeleton variant="text" lines="3"></a11y-skeleton>
|
|
758
|
+
<a11y-skeleton variant="circle" width="3rem"></a11y-skeleton>
|
|
759
|
+
<a11y-skeleton width="100%" height="10rem"></a11y-skeleton>
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
| Name | Kind | Default | Description |
|
|
763
|
+
| --- | --- | --- | --- |
|
|
764
|
+
| `variant` | attribute / property | `rect` | `rect`, `circle` or `text`. |
|
|
765
|
+
| `lines` | attribute / property | `1` | Number of lines, for `variant="text"`. |
|
|
766
|
+
| `width` | attribute | — | Sets `--a11y-skeleton-width`. |
|
|
767
|
+
| `height` | attribute | — | Sets `--a11y-skeleton-height`. |
|
|
768
|
+
|
|
769
|
+
<details>
|
|
770
|
+
<summary>CSS variables</summary>
|
|
771
|
+
|
|
772
|
+
| Variable | Default |
|
|
773
|
+
| --- | --- |
|
|
774
|
+
| `--a11y-skeleton-border-radius` | `4px` |
|
|
775
|
+
| `--a11y-skeleton-circle-default-size` | `2.5rem` |
|
|
776
|
+
| `--a11y-skeleton-color-surface` | `#f3f4f6` |
|
|
777
|
+
| `--a11y-skeleton-default-height` | `1em` |
|
|
778
|
+
| `--a11y-skeleton-height` | `1em` (`--a11y-skeleton-default-height`); circle: same as width |
|
|
779
|
+
| `--a11y-skeleton-last-line-width` | `70%` |
|
|
780
|
+
| `--a11y-skeleton-line-border-radius` | `2px` |
|
|
781
|
+
| `--a11y-skeleton-multiline-gap` | `0.5rem` |
|
|
782
|
+
| `--a11y-skeleton-pulse-duration` | `1.5s` |
|
|
783
|
+
| `--a11y-skeleton-pulse-min-opacity` | `0.45` |
|
|
784
|
+
| `--a11y-skeleton-stagger-delay` | `0.1s` |
|
|
785
|
+
| `--a11y-skeleton-text-border-radius` | `2px` |
|
|
786
|
+
| `--a11y-skeleton-width` | `100%`; circle: `2.5rem` (`--a11y-skeleton-circle-default-size`) |
|
|
787
|
+
|
|
788
|
+
</details>
|
|
64
789
|
|
|
65
|
-
|
|
790
|
+
#### `a11y-spinner`
|
|
791
|
+
|
|
792
|
+
A loading spinner with `role="status"`. No JS needed beyond the define.
|
|
793
|
+
|
|
794
|
+
```html
|
|
795
|
+
<a11y-spinner label="Saving…" size="3rem" color="#16a34a"></a11y-spinner>
|
|
796
|
+
<a11y-spinner class="a11y-spinner--lg"></a11y-spinner>
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
| Name | Kind | Default | Description |
|
|
800
|
+
| --- | --- | --- | --- |
|
|
801
|
+
| `label` | attribute / property | `Loading` | Accessible name. The default can be [translated](#translating-built-in-strings). |
|
|
802
|
+
| `size` | attribute / property | — | Sets `--a11y-spinner-size`. |
|
|
803
|
+
| `color` | attribute / property | — | Sets `--a11y-spinner-color`. |
|
|
804
|
+
| `duration` | attribute / property | — | Sets `--a11y-spinner-duration`. |
|
|
805
|
+
| `thickness` | attribute / property | — | Sets `--a11y-spinner-thickness`. |
|
|
806
|
+
|
|
807
|
+
Size presets: add `a11y-spinner--sm`, `a11y-spinner--lg` or `a11y-spinner--xl` to `class`.
|
|
808
|
+
|
|
809
|
+
<details>
|
|
810
|
+
<summary>CSS variables</summary>
|
|
811
|
+
|
|
812
|
+
| Variable | Default |
|
|
813
|
+
| --- | --- |
|
|
814
|
+
| `--a11y-spinner-border-radius` | `50%` |
|
|
815
|
+
| `--a11y-spinner-color` | `#2563eb` |
|
|
816
|
+
| `--a11y-spinner-duration` | `1s` |
|
|
817
|
+
| `--a11y-spinner-size` | `2rem` |
|
|
818
|
+
| `--a11y-spinner-size-lg` | `3rem` |
|
|
819
|
+
| `--a11y-spinner-size-sm` | `1rem` |
|
|
820
|
+
| `--a11y-spinner-size-xl` | `4rem` |
|
|
821
|
+
| `--a11y-spinner-thickness` | `3px` |
|
|
822
|
+
| `--a11y-spinner-thickness-lg` | `4px` |
|
|
823
|
+
| `--a11y-spinner-thickness-sm` | `2px` |
|
|
824
|
+
| `--a11y-spinner-thickness-xl` | `5px` |
|
|
825
|
+
|
|
826
|
+
</details>
|
|
827
|
+
|
|
828
|
+
#### `a11y-switch`
|
|
829
|
+
|
|
830
|
+
Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
831
|
+
|
|
832
|
+
```html
|
|
833
|
+
<a11y-switch label="Enable notifications">
|
|
834
|
+
<input type="checkbox" name="notifications">
|
|
835
|
+
</a11y-switch>
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
| Name | Kind | Default | Description |
|
|
839
|
+
| --- | --- | --- | --- |
|
|
840
|
+
| `label` | attribute | — | Visible label text. |
|
|
841
|
+
| `onChange` | callback | — | `(checked: boolean) => void`, called on every `change`. |
|
|
842
|
+
| `getValue()` / `setValue(checked)` | method | — | Reads / sets `checked`. |
|
|
843
|
+
|
|
844
|
+
<details>
|
|
845
|
+
<summary>CSS variables</summary>
|
|
846
|
+
|
|
847
|
+
| Variable | Default |
|
|
848
|
+
| --- | --- |
|
|
849
|
+
| `--a11y-switch-border-radius` | `9999px` |
|
|
850
|
+
| `--a11y-switch-color-background` | `#ffffff` |
|
|
851
|
+
| `--a11y-switch-color-border-strong` | `#9ca3af` |
|
|
852
|
+
| `--a11y-switch-color-disabled-bg` | `#e5e7eb` |
|
|
853
|
+
| `--a11y-switch-color-disabled-text` | `#9ca3af` |
|
|
854
|
+
| `--a11y-switch-color-primary` | `#2563eb` |
|
|
855
|
+
| `--a11y-switch-color-text` | `#111827` |
|
|
856
|
+
| `--a11y-switch-disabled-opacity` | `0.6` |
|
|
857
|
+
| `--a11y-switch-focus-outline-offset` | `2px` |
|
|
858
|
+
| `--a11y-switch-focus-outline-width` | `2px` |
|
|
859
|
+
| `--a11y-switch-gap` | `0.5rem` |
|
|
860
|
+
| `--a11y-switch-label-font-size` | `1rem` |
|
|
861
|
+
| `--a11y-switch-label-line-height` | `1.4` |
|
|
862
|
+
| `--a11y-switch-thumb-offset` | `calc((var(--a11y-switch-track-height, 1.5rem) - var(--a11y-switch-thumb-size, 1.125rem)) / 2)` |
|
|
863
|
+
| `--a11y-switch-thumb-shadow-blur` | `3px` |
|
|
864
|
+
| `--a11y-switch-thumb-shadow-color` | `rgba(0 0 0 / 25%)` |
|
|
865
|
+
| `--a11y-switch-thumb-shadow-offset-y` | `1px` |
|
|
866
|
+
| `--a11y-switch-thumb-size` | `1.125rem` |
|
|
867
|
+
| `--a11y-switch-track-height` | `1.5rem` |
|
|
868
|
+
| `--a11y-switch-track-width` | `2.75rem` |
|
|
869
|
+
| `--a11y-switch-transition-duration` | `0.2s` |
|
|
870
|
+
|
|
871
|
+
</details>
|
|
872
|
+
|
|
873
|
+
#### `a11y-textarea`
|
|
874
|
+
|
|
875
|
+
`<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
|
|
876
|
+
|
|
877
|
+
An `<a11y-counter>` shows the length against `maxlength` (`12 / 200`; hidden without `maxlength`). Screen readers don't hear it on every keystroke: once 20 characters or fewer are left, "5 characters remaining" is announced when typing pauses, and read with the field's description.
|
|
878
|
+
|
|
879
|
+
```html
|
|
880
|
+
<a11y-textarea value-missing-message="Tell us a bit more">
|
|
881
|
+
<a11y-label>Bio</a11y-label>
|
|
882
|
+
<textarea name="bio" required maxlength="200"></textarea>
|
|
883
|
+
<a11y-counter></a11y-counter>
|
|
884
|
+
<a11y-error></a11y-error>
|
|
885
|
+
</a11y-textarea>
|
|
886
|
+
```
|
|
887
|
+
|
|
888
|
+
The counter's strings can be [translated](#translating-built-in-strings).
|
|
889
|
+
|
|
890
|
+
<details>
|
|
891
|
+
<summary>CSS variables</summary>
|
|
892
|
+
|
|
893
|
+
The same as [`a11y-input`](#a11y-input), prefixed `--a11y-textarea-` instead of `--a11y-input-`, plus:
|
|
894
|
+
|
|
895
|
+
| Variable | Default |
|
|
896
|
+
| --- | --- |
|
|
897
|
+
| `--a11y-textarea-min-height` | `6rem` |
|
|
898
|
+
| `--a11y-textarea-resize` | `vertical` |
|
|
899
|
+
|
|
900
|
+
</details>
|
|
901
|
+
|
|
902
|
+
#### `a11y-visually-hidden`
|
|
903
|
+
|
|
904
|
+
Content for screen readers only, hidden visually.
|
|
905
|
+
|
|
906
|
+
```html
|
|
907
|
+
<button>
|
|
908
|
+
<svg aria-hidden="true">…</svg>
|
|
909
|
+
<a11y-visually-hidden>Delete item</a11y-visually-hidden>
|
|
910
|
+
</button>
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
No attributes or CSS variables. The class `a11y-visually-hidden` is also usable on its own.
|
|
914
|
+
|
|
915
|
+
### Overlays
|
|
916
|
+
|
|
917
|
+
#### Common to all overlays
|
|
918
|
+
|
|
919
|
+
* **Open/close** with the `open` attribute or property, or `show()` / `close()`.
|
|
920
|
+
* **Before the element is defined** (lazy-loaded bundles), setting `.open = true`, `onClose` or any other property works: it's applied once the element upgrades. `setAttribute('open', '')` works too.
|
|
921
|
+
* **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on `document`, with `event.detail.name` set to the tag name.
|
|
922
|
+
* **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
923
|
+
* **Body mounting:** every overlay (including the snackbar and notification-banner regions) moves itself to `<body>` when connected, so a `position: fixed` layer isn't clipped by an ancestor. See [Overlays in a framework](#overlays-in-a-framework) below.
|
|
924
|
+
|
|
925
|
+
##### Overlays in a framework
|
|
926
|
+
|
|
927
|
+
###### Removing them is up to you.
|
|
928
|
+
|
|
929
|
+
An overlay authored inside a component isn't inside that component's DOM any more, so when your framework removes the component's subtree (an unmount, a SPA navigation), the overlay stays in `<body>`, and the next render adds a second copy with the same `id`. Call `removeOverlaysWithin(host)` on unmount. It removes every overlay authored inside `host`, even after `host` has left the document, and returns how many it removed. It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
930
|
+
|
|
931
|
+
```js
|
|
932
|
+
import { removeOverlaysWithin } from 'a11y-elements/core';
|
|
933
|
+
// or: import { removeOverlaysWithin } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
934
|
+
|
|
935
|
+
onUnmount(() => removeOverlaysWithin(hostElement)); // your framework's unmount hook
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
Nothing is removed automatically, so subtrees your framework detaches and reattaches later (keep-alive caches, keyed moves) keep their overlays.
|
|
939
|
+
|
|
940
|
+
##### Don't reach overlay content through the host.
|
|
941
|
+
|
|
942
|
+
If the overlay's bundle is already loaded, `host.innerHTML = '…<a11y-modal>…'` upgrades the overlay and moves it to `<body>` during that same assignment, so a later `host.querySelectorAll(...)` finds nothing inside it.
|
|
943
|
+
|
|
944
|
+
If the bundle loads after rendering, the same query does find it, so the result depends on load order.
|
|
945
|
+
|
|
946
|
+
**Instead:**
|
|
947
|
+
|
|
948
|
+
* get the overlay by `id` (`document.getElementById`) and query inside it;
|
|
949
|
+
* bind events on the overlay element itself, or delegate from it;
|
|
950
|
+
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
951
|
+
|
|
952
|
+
<a id="dialogs"></a>
|
|
953
|
+
|
|
954
|
+
##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
955
|
+
|
|
956
|
+
They also share:
|
|
957
|
+
|
|
958
|
+
* A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`).
|
|
959
|
+
* Escape, a click on the backdrop, or the × close button close it, unless it's `non-dismissible`.
|
|
960
|
+
* The dialog is named after its first heading (`aria-labelledby`), or `dialog-label`.
|
|
961
|
+
|
|
962
|
+
| Name | Kind | Default | Description |
|
|
963
|
+
| --- | --- | --- | --- |
|
|
964
|
+
| `non-dismissible` | attribute | absent | No close button, no Escape, no backdrop click: close it from code. |
|
|
965
|
+
| `dialog-label` | attribute | — | Accessible name (`aria-label`) when there's no heading. |
|
|
966
|
+
| `close-label` | attribute | `Close dialog` | Accessible name of the × close button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
967
|
+
| `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
|
|
968
|
+
| `onClose` | callback | — | Called once the close transition has finished. |
|
|
969
|
+
|
|
970
|
+
<a id="anchored-overlays"></a>
|
|
971
|
+
|
|
972
|
+
##### Anchored overlays (`<a11y-popover>`, `<a11y-tooltip>`, `<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
973
|
+
|
|
974
|
+
They are positioned next to an anchor. They flip to the opposite side when there isn't room, and close on a click outside or Escape.
|
|
975
|
+
|
|
976
|
+
| Name | Kind | Default | Description |
|
|
977
|
+
| --- | --- | --- | --- |
|
|
978
|
+
| `anchor` | attribute | — | `id` of the anchor element. |
|
|
979
|
+
| `anchorElement` | property | — | The anchor element itself (takes precedence over `anchor`). |
|
|
980
|
+
| `placement` | attribute | `bottom` | `top`, `bottom`, `left` or `right`, optionally with `-start` / `-end` (e.g. `bottom-start`). |
|
|
981
|
+
| `offset` | attribute | `8` | Gap to the anchor, in px. |
|
|
982
|
+
| `updatePosition()` | method | — | Recomputes the position (it already follows scroll, resize and size changes). |
|
|
983
|
+
|
|
984
|
+
<a id="menus"></a>
|
|
985
|
+
|
|
986
|
+
##### Menus (`<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
987
|
+
|
|
988
|
+
Items are your own children with `role="menuitem"`. Arrow keys, Home and End move between them, and Enter/Space fire a real `click`. The menu closes after an item is clicked or when focus leaves it. Mark an item `aria-disabled="true"` to skip it.
|
|
989
|
+
|
|
990
|
+
<details>
|
|
991
|
+
<summary>CSS variables shared by anchored overlays and menus</summary>
|
|
992
|
+
|
|
993
|
+
| Variable | Default |
|
|
994
|
+
| --- | --- |
|
|
995
|
+
| `--a11y-anchored-overlay-initial-scale` | `0.97` |
|
|
996
|
+
| `--a11y-anchored-overlay-transition-duration` | `0.15s` |
|
|
997
|
+
| `--a11y-menu-item-color-background` | `#ffffff` |
|
|
998
|
+
| `--a11y-menu-item-color-secondary-hover` | `#4b5563` |
|
|
999
|
+
| `--a11y-menu-item-color-text` | `#111827` |
|
|
1000
|
+
| `--a11y-menu-item-disabled-opacity` | `0.5` |
|
|
1001
|
+
| `--a11y-menu-item-padding` | `0.5rem 1rem` |
|
|
1002
|
+
|
|
1003
|
+
</details>
|
|
1004
|
+
|
|
1005
|
+
#### `a11y-blocking-loader`
|
|
1006
|
+
|
|
1007
|
+
A full-screen loading overlay that can't be dismissed. While open, the rest of the page is `inert` and focus moves onto the loader; both are restored on close. Contains an `<a11y-spinner>` (registered automatically).
|
|
1008
|
+
|
|
1009
|
+
```html
|
|
1010
|
+
<a11y-blocking-loader id="saving" message="Saving your changes…"></a11y-blocking-loader>
|
|
1011
|
+
```
|
|
1012
|
+
|
|
1013
|
+
```js
|
|
1014
|
+
const loader = document.getElementById('saving');
|
|
1015
|
+
loader.show();
|
|
1016
|
+
await save();
|
|
1017
|
+
loader.close();
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
| Name | Kind | Default | Description |
|
|
1021
|
+
| --- | --- | --- | --- |
|
|
1022
|
+
| `message` | attribute | — | Visible message, also the spinner's label (`Loading` without it, [translatable](#translating-built-in-strings)). |
|
|
1023
|
+
|
|
1024
|
+
See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1025
|
+
|
|
1026
|
+
<details>
|
|
1027
|
+
<summary>CSS variables</summary>
|
|
1028
|
+
|
|
1029
|
+
| Variable | Default |
|
|
1030
|
+
| --- | --- |
|
|
1031
|
+
| `--a11y-blocking-loader-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
1032
|
+
| `--a11y-blocking-loader-color-text` | `#111827` |
|
|
1033
|
+
| `--a11y-blocking-loader-gap` | `1rem` |
|
|
1034
|
+
| `--a11y-blocking-loader-message-font-size` | `1rem` |
|
|
1035
|
+
| `--a11y-blocking-loader-message-font-weight` | `600` |
|
|
1036
|
+
|
|
1037
|
+
</details>
|
|
1038
|
+
|
|
1039
|
+
#### `a11y-context-menu`
|
|
1040
|
+
|
|
1041
|
+
A menu that opens at the pointer on right-click of a trigger element, replacing the browser's own menu there. See [Menus](#menus) and [Anchored overlays](#anchored-overlays).
|
|
1042
|
+
|
|
1043
|
+
```html
|
|
1044
|
+
<div id="canvas">Right-click me</div>
|
|
1045
|
+
<a11y-context-menu trigger="canvas">
|
|
1046
|
+
<div role="menuitem">Copy</div>
|
|
1047
|
+
<div role="menuitem">Paste</div>
|
|
1048
|
+
</a11y-context-menu>
|
|
1049
|
+
```
|
|
1050
|
+
|
|
1051
|
+
| Name | Kind | Default | Description |
|
|
1052
|
+
| --- | --- | --- | --- |
|
|
1053
|
+
| `trigger` | attribute | — | `id` of the element to right-click. |
|
|
1054
|
+
| `triggerElement` | property | — | The trigger element itself (takes precedence over `trigger`). |
|
|
1055
|
+
| `dispose()` | method | — | Detaches from the trigger for good (`close()` only hides the current menu). |
|
|
1056
|
+
|
|
1057
|
+
Also takes the shared [anchored-overlay](#anchored-overlays) options `placement` and `offset`, measured from the pointer, and `updatePosition()`; not `anchor` / `anchorElement`, since it opens where the `trigger` is right-clicked. Items follow the [menu](#menus) keyboard behavior. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1058
|
+
|
|
1059
|
+
<details>
|
|
1060
|
+
<summary>CSS variables</summary>
|
|
1061
|
+
|
|
1062
|
+
| Variable | Default |
|
|
1063
|
+
| --- | --- |
|
|
1064
|
+
| `--a11y-context-menu-border-radius` | `0.5rem` |
|
|
1065
|
+
| `--a11y-context-menu-color-background` | `#ffffff` |
|
|
1066
|
+
| `--a11y-context-menu-color-text` | `#111827` |
|
|
1067
|
+
| `--a11y-context-menu-content-padding` | `0.25rem 0` |
|
|
1068
|
+
| `--a11y-context-menu-min-width` | `160px` |
|
|
1069
|
+
| `--a11y-context-menu-shadow-blur` | `10px` |
|
|
1070
|
+
| `--a11y-context-menu-shadow-fade` | `85%` |
|
|
1071
|
+
| `--a11y-context-menu-shadow-offset-y` | `2px` |
|
|
1072
|
+
|
|
1073
|
+
</details>
|
|
1074
|
+
|
|
1075
|
+
#### `a11y-drawer`
|
|
1076
|
+
|
|
1077
|
+
A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dialogs](#dialogs)).
|
|
1078
|
+
|
|
1079
|
+
```html
|
|
1080
|
+
<a11y-drawer id="filters" edge="left">
|
|
1081
|
+
<h2>Filters</h2>
|
|
1082
|
+
…
|
|
1083
|
+
</a11y-drawer>
|
|
1084
|
+
```
|
|
1085
|
+
|
|
1086
|
+
| Name | Kind | Default | Description |
|
|
1087
|
+
| --- | --- | --- | --- |
|
|
1088
|
+
| `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
|
|
1089
|
+
|
|
1090
|
+
Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1091
|
+
|
|
1092
|
+
<details>
|
|
1093
|
+
<summary>CSS variables</summary>
|
|
1094
|
+
|
|
1095
|
+
The close button uses the modal's `--a11y-modal-close-button-size` and `--a11y-modal-color-secondary(-hover)`.
|
|
1096
|
+
|
|
1097
|
+
| Variable | Default |
|
|
1098
|
+
| --- | --- |
|
|
1099
|
+
| `--a11y-drawer-color-background` | `#ffffff` |
|
|
1100
|
+
| `--a11y-drawer-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
1101
|
+
| `--a11y-drawer-color-text` | `#111827` |
|
|
1102
|
+
| `--a11y-drawer-content-padding` | `1.5rem` |
|
|
1103
|
+
| `--a11y-drawer-height` | `min(480px, 90vh)` |
|
|
1104
|
+
| `--a11y-drawer-shadow-blur` | `10px` |
|
|
1105
|
+
| `--a11y-drawer-shadow-fade` | `80%` |
|
|
1106
|
+
| `--a11y-drawer-shadow-offset-y` | `2px` |
|
|
1107
|
+
| `--a11y-drawer-transition-duration` | `0.3s` |
|
|
1108
|
+
| `--a11y-drawer-width` | `min(400px, 90vw)` |
|
|
1109
|
+
|
|
1110
|
+
</details>
|
|
1111
|
+
|
|
1112
|
+
#### `a11y-dropdown`
|
|
1113
|
+
|
|
1114
|
+
A menu attached to a trigger button. The anchor is the trigger: clicking it toggles the menu, and it gets `aria-haspopup`, `aria-controls` and `aria-expanded`. See [Anchored overlays](#anchored-overlays) and [Menus](#menus).
|
|
1115
|
+
|
|
1116
|
+
```html
|
|
1117
|
+
<button id="actions-btn">Actions</button>
|
|
1118
|
+
<a11y-dropdown anchor="actions-btn" placement="bottom-start">
|
|
1119
|
+
<div role="menuitem">Edit</div>
|
|
1120
|
+
<div role="menuitem" aria-disabled="true">Share</div>
|
|
1121
|
+
<div role="menuitem">Delete</div>
|
|
1122
|
+
</a11y-dropdown>
|
|
1123
|
+
```
|
|
1124
|
+
|
|
1125
|
+
No attributes of its own. It takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` / `anchorElement`, `placement`, `offset` and `updatePosition()`, so e.g. `placement="top-end" offset="4"` opens it above the trigger, right-aligned, 4px away. Items follow the [menu](#menus) keyboard behavior. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1126
|
+
|
|
1127
|
+
<details>
|
|
1128
|
+
<summary>CSS variables</summary>
|
|
1129
|
+
|
|
1130
|
+
| Variable | Default |
|
|
1131
|
+
| --- | --- |
|
|
1132
|
+
| `--a11y-dropdown-border-radius` | `0.5rem` |
|
|
1133
|
+
| `--a11y-dropdown-color-background` | `#ffffff` |
|
|
1134
|
+
| `--a11y-dropdown-color-text` | `#111827` |
|
|
1135
|
+
| `--a11y-dropdown-content-padding` | `0.25rem 0` |
|
|
1136
|
+
| `--a11y-dropdown-min-width` | `160px` |
|
|
1137
|
+
| `--a11y-dropdown-shadow-blur` | `10px` |
|
|
1138
|
+
| `--a11y-dropdown-shadow-fade` | `85%` |
|
|
1139
|
+
| `--a11y-dropdown-shadow-offset-y` | `2px` |
|
|
1140
|
+
|
|
1141
|
+
</details>
|
|
1142
|
+
|
|
1143
|
+
#### `a11y-emergency-dialog`
|
|
1144
|
+
|
|
1145
|
+
A modal the user can't dismiss: no close button, no Escape, no backdrop click, whatever its attributes say. For things that must be resolved on purpose, e.g. "your session is about to expire". Close it from code.
|
|
1146
|
+
|
|
1147
|
+
```html
|
|
1148
|
+
<a11y-emergency-dialog id="session">
|
|
1149
|
+
<h2>Session expiring</h2>
|
|
1150
|
+
<p>You'll be signed out in 2 minutes.</p>
|
|
1151
|
+
<div class="a11y-modal-buttons">
|
|
1152
|
+
<button id="stay">Stay signed in</button>
|
|
1153
|
+
</div>
|
|
1154
|
+
</a11y-emergency-dialog>
|
|
1155
|
+
```
|
|
1156
|
+
|
|
1157
|
+
```js
|
|
1158
|
+
document.getElementById('stay').addEventListener('click', () => {
|
|
1159
|
+
document.getElementById('session').close();
|
|
1160
|
+
});
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
From the shared [dialog](#dialogs) options, only `dialog-label` and `onClose` apply. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`. It uses the modal's CSS variables, plus:
|
|
1164
|
+
|
|
1165
|
+
<details>
|
|
1166
|
+
<summary>CSS variables</summary>
|
|
1167
|
+
|
|
1168
|
+
| Variable | Default |
|
|
1169
|
+
| --- | --- |
|
|
1170
|
+
| `--a11y-emergency-dialog-accent-width` | `4px` |
|
|
1171
|
+
|
|
1172
|
+
</details>
|
|
1173
|
+
|
|
1174
|
+
#### `a11y-modal`
|
|
1175
|
+
|
|
1176
|
+
A centered dialog. Your content is its children. See [Dialogs](#dialogs).
|
|
66
1177
|
|
|
67
1178
|
```html
|
|
68
1179
|
<button id="open-settings">Open settings</button>
|
|
69
1180
|
<a11y-modal id="settings">
|
|
70
1181
|
<h2>Settings</h2>
|
|
71
1182
|
<p>Press Escape, click the backdrop, or the close button to dismiss.</p>
|
|
1183
|
+
<div class="a11y-modal-buttons">
|
|
1184
|
+
<button type="button">Save</button>
|
|
1185
|
+
</div>
|
|
72
1186
|
</a11y-modal>
|
|
73
1187
|
```
|
|
74
1188
|
|
|
@@ -80,7 +1194,263 @@ document.getElementById('open-settings').addEventListener('click', () => {
|
|
|
80
1194
|
});
|
|
81
1195
|
```
|
|
82
1196
|
|
|
83
|
-
|
|
1197
|
+
| Name | Kind | Default | Description |
|
|
1198
|
+
| --- | --- | --- | --- |
|
|
1199
|
+
| `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
|
|
1200
|
+
|
|
1201
|
+
Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1202
|
+
|
|
1203
|
+
`.a11y-modal-buttons` is an optional footer-row class for your own buttons.
|
|
1204
|
+
|
|
1205
|
+
<details>
|
|
1206
|
+
<summary>CSS variables</summary>
|
|
1207
|
+
|
|
1208
|
+
| Variable | Default |
|
|
1209
|
+
| --- | --- |
|
|
1210
|
+
| `--a11y-modal-border-radius` | `1rem` |
|
|
1211
|
+
| `--a11y-modal-close-button-size` | `1.5rem` |
|
|
1212
|
+
| `--a11y-modal-color-background` | `#ffffff` |
|
|
1213
|
+
| `--a11y-modal-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
1214
|
+
| `--a11y-modal-color-secondary` | `#6b7280` |
|
|
1215
|
+
| `--a11y-modal-color-secondary-hover` | `#4b5563` |
|
|
1216
|
+
| `--a11y-modal-color-text` | `#111827` |
|
|
1217
|
+
| `--a11y-modal-content-padding` | `1.5rem` |
|
|
1218
|
+
| `--a11y-modal-footer-button-padding` | `0.5rem 1rem` |
|
|
1219
|
+
| `--a11y-modal-footer-gap` | `1rem` |
|
|
1220
|
+
| `--a11y-modal-footer-margin-top` | `1.5rem` |
|
|
1221
|
+
| `--a11y-modal-initial-scale` | `0.95` |
|
|
1222
|
+
| `--a11y-modal-overlay-padding` | `clamp(1rem, 10vmin, 6rem)` |
|
|
1223
|
+
| `--a11y-modal-shadow-blur` | `2px` |
|
|
1224
|
+
| `--a11y-modal-shadow-fade` | `80%` |
|
|
1225
|
+
| `--a11y-modal-shadow-offset-y` | `2px` |
|
|
1226
|
+
| `--a11y-modal-transition-duration` | `0.3s` |
|
|
1227
|
+
|
|
1228
|
+
</details>
|
|
1229
|
+
|
|
1230
|
+
#### `a11y-notification-banner`
|
|
1231
|
+
|
|
1232
|
+
Full-width banners that stay until the user dismisses them (or you call `dismissAll()`). Place one region in the page, or skip it and use `showNotificationBanner()`, which finds or creates one.
|
|
1233
|
+
|
|
1234
|
+
```html
|
|
1235
|
+
<a11y-notification-banner id="banners" max-stack="2"></a11y-notification-banner>
|
|
1236
|
+
```
|
|
1237
|
+
|
|
1238
|
+
```js
|
|
1239
|
+
import { showNotificationBanner } from 'a11y-elements/overlays/notification-banner';
|
|
1240
|
+
|
|
1241
|
+
showNotificationBanner('Your trial ends in 3 days.', {
|
|
1242
|
+
type: 'info',
|
|
1243
|
+
actionText: 'Upgrade',
|
|
1244
|
+
onAction: () => location.assign('/billing'),
|
|
1245
|
+
});
|
|
1246
|
+
|
|
1247
|
+
// e.g. clear them on navigation
|
|
1248
|
+
window.addEventListener('popstate', () => document.getElementById('banners').dismissAll());
|
|
1249
|
+
```
|
|
1250
|
+
|
|
1251
|
+
| Name | Kind | Default | Description |
|
|
1252
|
+
| --- | --- | --- | --- |
|
|
1253
|
+
| `max-stack` | attribute | `3` | How many banners show at once; the rest wait in a queue and show as earlier ones are dismissed. |
|
|
1254
|
+
| `dismiss-label` | attribute | `Dismiss` | Accessible name of each banner's × button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1255
|
+
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1256
|
+
| `show(message, options)` | method | — | Shows a banner (or queues it). |
|
|
1257
|
+
| `dismissAll()` | method | — | Closes every banner (calling their `onClose`) and drops the queued ones silently. |
|
|
1258
|
+
|
|
1259
|
+
It's a page region, not an open/close overlay: it fires no open/close events and `dismissAllOverlays()` leaves it alone. Like every overlay it moves itself to `<body>`; see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`.
|
|
1260
|
+
|
|
1261
|
+
`show()` / `showNotificationBanner()` options:
|
|
1262
|
+
|
|
1263
|
+
| Option | Default | Description |
|
|
1264
|
+
| --- | --- | --- |
|
|
1265
|
+
| `type` | `info` | `info`, `success` or `error` (`error` uses `role="alert"`). |
|
|
1266
|
+
| `position` | `top` | `top` or `bottom`. |
|
|
1267
|
+
| `actionText` / `onAction` | — | Adds an action button; clicking it runs `onAction` and dismisses the banner. |
|
|
1268
|
+
| `onClose` | — | Called when the banner is dismissed. |
|
|
1269
|
+
| `maxStack` | — | Sets `max-stack` on the region (sticky for later banners). |
|
|
1270
|
+
|
|
1271
|
+
Classes: `.a11y-notification-banner--info` / `--success` / `--error`, `__message`, `__action`, `__close`.
|
|
1272
|
+
|
|
1273
|
+
<details>
|
|
1274
|
+
<summary>CSS variables</summary>
|
|
1275
|
+
|
|
1276
|
+
Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared-tokens)).
|
|
1277
|
+
|
|
1278
|
+
| Variable | Default |
|
|
1279
|
+
| --- | --- |
|
|
1280
|
+
| `--a11y-notification-banner-actions-gap` | `0.75rem` |
|
|
1281
|
+
| `--a11y-notification-banner-animation-duration` | `0.3s` |
|
|
1282
|
+
| `--a11y-notification-banner-close-font-size` | `1.25rem` |
|
|
1283
|
+
| `--a11y-notification-banner-gap` | `1rem` |
|
|
1284
|
+
| `--a11y-notification-banner-padding` | `0.75rem 1.5rem` |
|
|
1285
|
+
|
|
1286
|
+
</details>
|
|
1287
|
+
|
|
1288
|
+
#### `a11y-popover`
|
|
1289
|
+
|
|
1290
|
+
Content attached to an anchor, opened from code. With `interactive` it's a `role="dialog"` that traps focus; without it, a `role="region"`. See [Anchored overlays](#anchored-overlays).
|
|
1291
|
+
|
|
1292
|
+
```html
|
|
1293
|
+
<button id="info-btn">Info</button>
|
|
1294
|
+
<a11y-popover id="info" anchor="info-btn" placement="right" interactive>
|
|
1295
|
+
<p>More details, with a <a href="/help">link</a>.</p>
|
|
1296
|
+
</a11y-popover>
|
|
1297
|
+
```
|
|
1298
|
+
|
|
1299
|
+
```js
|
|
1300
|
+
document.getElementById('info-btn').addEventListener('click', () => {
|
|
1301
|
+
document.getElementById('info').toggleAttribute('open');
|
|
1302
|
+
});
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
| Name | Kind | Default | Description |
|
|
1306
|
+
| --- | --- | --- | --- |
|
|
1307
|
+
| `interactive` | attribute | absent | `role="dialog"` and a focus trap. |
|
|
1308
|
+
| `trap-focus` | attribute | follows `interactive` | Force the focus trap on (`trap-focus`) or off (`trap-focus="false"`). |
|
|
1309
|
+
| `onClose` | callback | — | Called once it has closed. |
|
|
1310
|
+
|
|
1311
|
+
Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` / `anchorElement`, `placement`, `offset` and `updatePosition()`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1312
|
+
|
|
1313
|
+
<details>
|
|
1314
|
+
<summary>CSS variables</summary>
|
|
1315
|
+
|
|
1316
|
+
| Variable | Default |
|
|
1317
|
+
| --- | --- |
|
|
1318
|
+
| `--a11y-popover-border-radius` | `0.5rem` |
|
|
1319
|
+
| `--a11y-popover-color-background` | `#ffffff` |
|
|
1320
|
+
| `--a11y-popover-color-text` | `#111827` |
|
|
1321
|
+
| `--a11y-popover-content-padding` | `1rem` |
|
|
1322
|
+
| `--a11y-popover-max-width` | `320px` |
|
|
1323
|
+
| `--a11y-popover-shadow-blur` | `10px` |
|
|
1324
|
+
| `--a11y-popover-shadow-fade` | `85%` |
|
|
1325
|
+
| `--a11y-popover-shadow-offset-y` | `2px` |
|
|
1326
|
+
|
|
1327
|
+
</details>
|
|
1328
|
+
|
|
1329
|
+
#### `a11y-snackbar`
|
|
1330
|
+
|
|
1331
|
+
Toast notifications that dismiss themselves: after 3 s by default, or 10 s when the toast has an action button. The countdown pauses while the toast is hovered or focused. Place one region in the page, or skip it and use `notify()`, which finds or creates one.
|
|
1332
|
+
|
|
1333
|
+
```html
|
|
1334
|
+
<a11y-snackbar max-stack="5"></a11y-snackbar>
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
```js
|
|
1338
|
+
import { notify } from 'a11y-elements/overlays/snackbar';
|
|
1339
|
+
|
|
1340
|
+
notify('Saved');
|
|
1341
|
+
notify('Upload failed', { type: 'error', actionText: 'Retry', onAction: retryUpload });
|
|
1342
|
+
notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
1343
|
+
```
|
|
1344
|
+
|
|
1345
|
+
| Name | Kind | Default | Description |
|
|
1346
|
+
| --- | --- | --- | --- |
|
|
1347
|
+
| `max-stack` | attribute | `3` | How many toasts show at once; the rest wait in a queue and show as earlier ones are dismissed. |
|
|
1348
|
+
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1349
|
+
| `notify(message, options)` | method | — | Shows a toast (or queues it). |
|
|
1350
|
+
|
|
1351
|
+
It's a page region, not an open/close overlay: it fires no open/close events and `dismissAllOverlays()` leaves it alone. Like every overlay it moves itself to `<body>`; see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`.
|
|
1352
|
+
|
|
1353
|
+
`notify()` options (method and convenience export):
|
|
1354
|
+
|
|
1355
|
+
| Option | Default | Description |
|
|
1356
|
+
| --- | --- | --- |
|
|
1357
|
+
| `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
|
|
1358
|
+
| `position` | `bottom` | `bottom` or `top`. |
|
|
1359
|
+
| `duration` | `3000` (`10000` with an action) | Time on screen, in ms, not counting hover/focus. |
|
|
1360
|
+
| `actionText` / `onAction` | — | Adds an action button; clicking it dismisses the toast and runs `onAction`. |
|
|
1361
|
+
| `maxStack` | — | Sets `max-stack` on the region (sticky for later toasts). |
|
|
1362
|
+
|
|
1363
|
+
Classes: `.a11y-snackbar--info` / `--success` / `--warning` / `--error`.
|
|
1364
|
+
|
|
1365
|
+
<details>
|
|
1366
|
+
<summary>CSS variables</summary>
|
|
1367
|
+
|
|
1368
|
+
Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared-tokens)).
|
|
1369
|
+
|
|
1370
|
+
| Variable | Default |
|
|
1371
|
+
| --- | --- |
|
|
1372
|
+
| `--a11y-snackbar-animation-duration` | `0.3s` |
|
|
1373
|
+
| `--a11y-snackbar-border-radius` | `0.5rem` |
|
|
1374
|
+
| `--a11y-snackbar-container-width` | `350px` |
|
|
1375
|
+
| `--a11y-snackbar-gap` | `1rem` |
|
|
1376
|
+
| `--a11y-snackbar-offset` | `1rem` |
|
|
1377
|
+
| `--a11y-snackbar-padding` | `0.75rem 1.5rem` |
|
|
1378
|
+
| `--a11y-snackbar-shadow-blur` | `6px` |
|
|
1379
|
+
| `--a11y-snackbar-shadow-color` | `rgba(0, 0, 0, 0.3)` |
|
|
1380
|
+
| `--a11y-snackbar-shadow-offset-y` | `2px` |
|
|
1381
|
+
| `--a11y-snackbar-stack-gap` | `0.5rem` |
|
|
1382
|
+
|
|
1383
|
+
</details>
|
|
1384
|
+
|
|
1385
|
+
#### `a11y-tooltip`
|
|
1386
|
+
|
|
1387
|
+
A short description shown on hover or focus of its anchor, which gets `aria-describedby`. It stays open while the pointer is over it, and Escape hides it. Never traps focus. See [Anchored overlays](#anchored-overlays).
|
|
1388
|
+
|
|
1389
|
+
```html
|
|
1390
|
+
<button id="save-btn">Save</button>
|
|
1391
|
+
<a11y-tooltip anchor="save-btn" placement="top" show-delay="500">Saves your changes</a11y-tooltip>
|
|
1392
|
+
```
|
|
1393
|
+
|
|
1394
|
+
| Name | Kind | Default | Description |
|
|
1395
|
+
| --- | --- | --- | --- |
|
|
1396
|
+
| `show-delay` | attribute / property (read-only) | `300` | Delay before showing, in ms. |
|
|
1397
|
+
| `hide-delay` | attribute / property (read-only) | `100` | Delay before hiding once pointer/focus leaves, in ms. |
|
|
1398
|
+
| `dispose()` | method | — | Detaches from the anchor for good (`close()` only hides it). |
|
|
1399
|
+
|
|
1400
|
+
Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` / `anchorElement`, `placement`, `offset` and `updatePosition()`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1401
|
+
|
|
1402
|
+
<details>
|
|
1403
|
+
<summary>CSS variables</summary>
|
|
1404
|
+
|
|
1405
|
+
| Variable | Default |
|
|
1406
|
+
| --- | --- |
|
|
1407
|
+
| `--a11y-tooltip-border-radius` | `0.35rem` |
|
|
1408
|
+
| `--a11y-tooltip-color-background` | `#ffffff` |
|
|
1409
|
+
| `--a11y-tooltip-color-text` | `#111827` |
|
|
1410
|
+
| `--a11y-tooltip-content-padding` | `0.35rem 0.6rem` |
|
|
1411
|
+
| `--a11y-tooltip-font-size` | `0.85rem` |
|
|
1412
|
+
| `--a11y-tooltip-max-width` | `240px` |
|
|
1413
|
+
|
|
1414
|
+
</details>
|
|
1415
|
+
|
|
1416
|
+
### Shared tokens
|
|
1417
|
+
|
|
1418
|
+
Status colors and the z-index scale, defined on `:root` (in `overlays/core/overlay-variables.css`). Override them globally, or override a component's own token instead.
|
|
1419
|
+
|
|
1420
|
+
<details>
|
|
1421
|
+
<summary>CSS variables</summary>
|
|
1422
|
+
|
|
1423
|
+
| Variable | Default |
|
|
1424
|
+
| --- | --- |
|
|
1425
|
+
| `--a11y-color-success` | `rgb(76 175 80)` |
|
|
1426
|
+
| `--a11y-color-error` | `rgb(244 67 54)` |
|
|
1427
|
+
| `--a11y-color-info` | `rgb(33 150 243)` |
|
|
1428
|
+
| `--a11y-color-warning` | `rgb(244 67 54)` |
|
|
1429
|
+
| `--a11y-color-text` | `white` |
|
|
1430
|
+
| `--a11y-z-base` | `0` |
|
|
1431
|
+
| `--a11y-z-sticky-header` | `100` |
|
|
1432
|
+
| `--a11y-z-sticky-footer` | `110` |
|
|
1433
|
+
| `--a11y-z-floating-button` | `120` |
|
|
1434
|
+
| `--a11y-z-sidebar` | `200` |
|
|
1435
|
+
| `--a11y-z-mobile-nav` | `210` |
|
|
1436
|
+
| `--a11y-z-dropdown` | `300` |
|
|
1437
|
+
| `--a11y-z-popover` | `310` |
|
|
1438
|
+
| `--a11y-z-tooltip` | `320` |
|
|
1439
|
+
| `--a11y-z-context-menu` | `330` |
|
|
1440
|
+
| `--a11y-z-snackbar` | `400` |
|
|
1441
|
+
| `--a11y-z-toast` | `410` |
|
|
1442
|
+
| `--a11y-z-notification-banner` | `420` |
|
|
1443
|
+
| `--a11y-z-modal-backdrop` | `500` |
|
|
1444
|
+
| `--a11y-z-modal` | `510` |
|
|
1445
|
+
| `--a11y-z-drawer-backdrop` | `520` |
|
|
1446
|
+
| `--a11y-z-drawer` | `530` |
|
|
1447
|
+
| `--a11y-z-fullscreen-overlay` | `540` |
|
|
1448
|
+
| `--a11y-z-blocking-loader` | `600` |
|
|
1449
|
+
| `--a11y-z-emergency-dialog` | `610` |
|
|
1450
|
+
| `--a11y-z-debug-panel` | `700` |
|
|
1451
|
+
| `--a11y-z-inspector` | `710` |
|
|
1452
|
+
|
|
1453
|
+
</details>
|
|
84
1454
|
|
|
85
1455
|
## Customizing styles
|
|
86
1456
|
|
|
@@ -134,6 +1504,8 @@ The same custom properties follow ordinary CSS cascade/inheritance, so you can t
|
|
|
134
1504
|
|
|
135
1505
|
Either way, only that element changes — every other `<a11y-spinner>` on the page keeps its default (or globally-rethemed) look.
|
|
136
1506
|
|
|
1507
|
+
Attributes that map to a custom property (`<a11y-spinner color="…" size="…">`, `<a11y-avatar size="…">`, `<a11y-skeleton width="…" height="…">`) take precedence over your inline value only while they're set; removing the attribute brings your inline value back.
|
|
1508
|
+
|
|
137
1509
|
The full list of tokens, with their defaults, is in the shipped `dist/a11y.css` — search it for `--a11y-<component>-`.
|
|
138
1510
|
|
|
139
1511
|
## License
|