a11y-elements 0.1.0 → 0.2.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 +1139 -10
- package/dist/a11y.css +146 -12
- package/dist/browser/{accessibility-components → components}/anchor/define.js +136 -12
- package/dist/browser/components/anchor/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/avatar/define.js +103 -10
- package/dist/browser/components/avatar/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/checkbox/define.js +92 -7
- package/dist/browser/components/checkbox/define.js.map +1 -0
- package/dist/browser/components/focusable/define.js +199 -0
- package/dist/browser/components/focusable/define.js.map +1 -0
- package/dist/browser/components/input/define.js +669 -0
- package/dist/browser/components/input/define.js.map +1 -0
- package/dist/browser/components/label/define.js +262 -0
- package/dist/browser/components/label/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/picture/define.js +92 -5
- package/dist/browser/components/picture/define.js.map +1 -0
- package/dist/browser/components/progress/define.js +227 -0
- package/dist/browser/components/progress/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/radio-group/define.js +92 -6
- package/dist/browser/components/radio-group/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/select/define.js +92 -6
- package/dist/browser/components/select/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/skeleton/define.js +93 -7
- package/dist/browser/components/skeleton/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/spinner/define.js +100 -8
- package/dist/browser/components/spinner/define.js.map +1 -0
- package/dist/browser/{accessibility-components → components}/switch/define.js +92 -6
- package/dist/browser/components/switch/define.js.map +1 -0
- package/dist/browser/components/textarea/define.js +669 -0
- package/dist/browser/components/textarea/define.js.map +1 -0
- package/dist/browser/components/visually-hidden/define.js +183 -0
- package/dist/browser/components/visually-hidden/define.js.map +1 -0
- package/dist/browser/overlays/blocking-loader/define.js +170 -13
- package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
- package/dist/browser/overlays/context-menu/define.js +283 -121
- package/dist/browser/overlays/context-menu/define.js.map +1 -1
- package/dist/browser/overlays/drawer/define.js +190 -13
- package/dist/browser/overlays/drawer/define.js.map +1 -1
- package/dist/browser/overlays/dropdown/define.js +283 -121
- package/dist/browser/overlays/dropdown/define.js.map +1 -1
- package/dist/browser/overlays/emergency-dialog/define.js +190 -13
- package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/browser/overlays/modal/define.js +190 -14
- package/dist/browser/overlays/modal/define.js.map +1 -1
- package/dist/browser/overlays/notification-banner/define.js +171 -15
- package/dist/browser/overlays/notification-banner/define.js.map +1 -1
- package/dist/browser/overlays/popover/define.js +172 -11
- package/dist/browser/overlays/popover/define.js.map +1 -1
- package/dist/browser/overlays/snackbar/define.js +148 -15
- package/dist/browser/overlays/snackbar/define.js.map +1 -1
- package/dist/browser/overlays/tooltip/define.js +189 -14
- 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/{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 +1 -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.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 +0 -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 +76 -0
- package/dist/core/a11y-field-element.js +220 -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 +14 -0
- package/dist/core/focus-trap.js +85 -4
- 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 +39 -0
- package/dist/core/strings.js +47 -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 +2 -1
- 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 +9 -9
- 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.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.map +0 -1
- 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.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.map +0 -1
- 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}/picture/picture.element.d.ts +0 -0
- /package/dist/{accessibility-components → components}/picture/picture.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
|
@@ -12,7 +12,7 @@ Load a component's standalone browser bundle directly, no bundler required:
|
|
|
12
12
|
|
|
13
13
|
```html
|
|
14
14
|
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
|
|
15
|
-
<script type="module" src="node_modules/a11y-elements/dist/browser/
|
|
15
|
+
<script type="module" src="node_modules/a11y-elements/dist/browser/components/spinner/define.js"></script>
|
|
16
16
|
|
|
17
17
|
<a11y-spinner></a11y-spinner>
|
|
18
18
|
```
|
|
@@ -35,40 +35,921 @@ Import via the package's `exports` map, which exposes real per-component ESM out
|
|
|
35
35
|
|
|
36
36
|
```js
|
|
37
37
|
import 'a11y-elements/a11y.css';
|
|
38
|
-
import 'a11y-elements/
|
|
38
|
+
import 'a11y-elements/components/checkbox';
|
|
39
39
|
import 'a11y-elements/overlays/modal';
|
|
40
40
|
import { A11yElement } from 'a11y-elements/core';
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
* There's no default export: `import 'a11y-elements'` alone will fail.
|
|
44
44
|
* Import the component you want: `/element` gets you the class itself when you need it
|
|
45
|
-
* See
|
|
45
|
+
* See [Elements](#elements) for every component.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
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.
|
|
48
|
+
|
|
49
|
+
### Translating built-in strings
|
|
50
|
+
|
|
51
|
+
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`:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
import { setStrings } from 'a11y-elements/core';
|
|
55
|
+
// or: import { setStrings } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
56
|
+
|
|
57
|
+
setStrings({
|
|
58
|
+
closeDialog: 'Fermer la boîte de dialogue',
|
|
59
|
+
opensInNewTab: '(nouvel onglet)',
|
|
60
|
+
navigatedTo: 'Aller à {name}',
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
| Key | Default | Used by | Per-instance override |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
|
|
67
|
+
| `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
|
|
68
|
+
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>` | `close-label` |
|
|
69
|
+
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item | `dismiss-label` |
|
|
70
|
+
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
71
|
+
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
72
|
+
| `avatar` | `Avatar` | `<a11y-avatar>` with no `alt` or `initials` | `alt` / `initials` |
|
|
73
|
+
| `characterCount` | `{count} / {max}` | the visible text of an `<a11y-counter>` | — |
|
|
74
|
+
| `charactersRemaining` | `{count} characters remaining` | what an `<a11y-counter>` announces near the limit | — |
|
|
75
|
+
| `characterRemaining` | `{count} character remaining` | the same, with one character left | — |
|
|
76
|
+
|
|
77
|
+
* An instance attribute wins over `setStrings()`, which wins over the default. Keys you leave out keep their current value.
|
|
78
|
+
* Elements already on the page update right away, so calling it again on a language switch is enough.
|
|
79
|
+
* `resetStrings()` restores the English defaults.
|
|
80
|
+
|
|
81
|
+
## Elements
|
|
82
|
+
|
|
83
|
+
Each section shows an example, the element's own attributes/properties/methods, and its CSS variables (collapsed). Behavior shared by a family of elements is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
84
|
+
|
|
85
|
+
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<a11y-checkbox>`](#a11y-checkbox) · [`<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)
|
|
86
|
+
|
|
87
|
+
**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)
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
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).
|
|
92
|
+
|
|
93
|
+
### Accessibility components
|
|
94
|
+
|
|
95
|
+
#### `a11y-anchor`
|
|
96
|
+
|
|
97
|
+
Enhances a real `<a href>`:
|
|
98
|
+
|
|
99
|
+
* **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.
|
|
100
|
+
* **New-tab links** (`target="_blank"` or a named target) get `rel="noopener noreferrer"` and "(opens in new tab)" appended to their accessible name.
|
|
101
|
+
|
|
102
|
+
Both strings can be [translated](#translating-built-in-strings).
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<a11y-anchor><a href="#section-2">Jump to section 2</a></a11y-anchor>
|
|
106
|
+
<a11y-anchor><a href="https://example.com" target="_blank">External site</a></a11y-anchor>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
| Name | Kind | Default | Description |
|
|
110
|
+
| --- | --- | --- | --- |
|
|
111
|
+
| `new-tab-label` | attribute | `(opens in new tab)` | Suffix added to new-tab links' accessible name. |
|
|
112
|
+
| `navigated-label` | attribute | `Navigated to {name}` | Jump announcement; `{name}` is replaced by the target's name. |
|
|
113
|
+
|
|
114
|
+
No CSS variables of its own: style the `<a>` directly.
|
|
115
|
+
|
|
116
|
+
#### `a11y-avatar`
|
|
117
|
+
|
|
118
|
+
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`.
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<a11y-avatar alt="Jane Doe" src="jane.jpg" initials="JD" size="3rem"></a11y-avatar>
|
|
122
|
+
<a11y-avatar alt="John Roe" initials="JR" shape="square"></a11y-avatar>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
| Name | Kind | Default | Description |
|
|
126
|
+
| --- | --- | --- | --- |
|
|
127
|
+
| `src` | attribute | — | Image URL. |
|
|
128
|
+
| `alt` | attribute / property | `''` | Image alt text; also the accessible name of the initials fallback (then `initials`, then `Avatar`). |
|
|
129
|
+
| `initials` | attribute | — | Text shown when there's no image, or it fails to load. |
|
|
130
|
+
| `size` | attribute | — | Sets `--a11y-avatar-size`. |
|
|
131
|
+
| `shape` | attribute / property | `circle` | `circle` or `square`. |
|
|
132
|
+
|
|
133
|
+
<details>
|
|
134
|
+
<summary>CSS variables</summary>
|
|
135
|
+
|
|
136
|
+
| Variable | Default |
|
|
137
|
+
| --- | --- |
|
|
138
|
+
| `--a11y-avatar-border-radius-circle` | `9999px` |
|
|
139
|
+
| `--a11y-avatar-border-radius-square` | `4px` |
|
|
140
|
+
| `--a11y-avatar-color-surface` | `#f3f4f6` |
|
|
141
|
+
| `--a11y-avatar-color-text-muted` | `#6b7280` |
|
|
142
|
+
| `--a11y-avatar-font-family` | `Arial, sans-serif` |
|
|
143
|
+
| `--a11y-avatar-font-size-ratio` | `0.38` |
|
|
144
|
+
| `--a11y-avatar-font-weight` | `600` |
|
|
145
|
+
| `--a11y-avatar-initials-letter-spacing` | `0.05em` |
|
|
146
|
+
| `--a11y-avatar-size` | `2.5rem` |
|
|
147
|
+
|
|
148
|
+
</details>
|
|
149
|
+
|
|
150
|
+
#### `a11y-checkbox`
|
|
151
|
+
|
|
152
|
+
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
153
|
|
|
49
154
|
```html
|
|
50
155
|
<a11y-checkbox id="terms" label="Accept terms">
|
|
51
|
-
<input type="checkbox" name="terms">
|
|
156
|
+
<input type="checkbox" name="terms" required>
|
|
52
157
|
</a11y-checkbox>
|
|
53
158
|
```
|
|
54
159
|
|
|
55
160
|
```ts
|
|
56
|
-
import 'a11y-elements/
|
|
57
|
-
import type { CheckboxElement } from 'a11y-elements/
|
|
161
|
+
import 'a11y-elements/components/checkbox';
|
|
162
|
+
import type { CheckboxElement } from 'a11y-elements/components/checkbox/element';
|
|
58
163
|
|
|
59
164
|
const checkbox = document.getElementById('terms') as CheckboxElement;
|
|
60
165
|
checkbox.onChange = (checked) => console.log('accepted:', checked);
|
|
61
166
|
```
|
|
62
167
|
|
|
63
|
-
|
|
168
|
+
| Name | Kind | Default | Description |
|
|
169
|
+
| --- | --- | --- | --- |
|
|
170
|
+
| `label` | attribute | — | Visible label text. |
|
|
171
|
+
| `indeterminate` | attribute | absent | Sets the input's `indeterminate` state (it has no HTML attribute of its own). |
|
|
172
|
+
| `onChange` | callback | — | `(checked: boolean) => void`, called on every `change`. |
|
|
173
|
+
| `getValue()` / `setValue(checked)` | method | — | Reads / sets `checked`. |
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary>CSS variables</summary>
|
|
177
|
+
|
|
178
|
+
| Variable | Default |
|
|
179
|
+
| --- | --- |
|
|
180
|
+
| `--a11y-checkbox-border-radius` | `2px` |
|
|
181
|
+
| `--a11y-checkbox-checkmark-background-size` | `75%` |
|
|
182
|
+
| `--a11y-checkbox-color-background` | `#ffffff` |
|
|
183
|
+
| `--a11y-checkbox-color-border` | `#d1d5db` |
|
|
184
|
+
| `--a11y-checkbox-color-border-strong` | `#9ca3af` |
|
|
185
|
+
| `--a11y-checkbox-color-disabled-bg` | `#e5e7eb` |
|
|
186
|
+
| `--a11y-checkbox-color-primary` | `#2563eb` |
|
|
187
|
+
| `--a11y-checkbox-color-text` | `#111827` |
|
|
188
|
+
| `--a11y-checkbox-disabled-opacity` | `0.6` |
|
|
189
|
+
| `--a11y-checkbox-focus-outline-offset` | `2px` |
|
|
190
|
+
| `--a11y-checkbox-focus-outline-width` | `2px` |
|
|
191
|
+
| `--a11y-checkbox-gap` | `0.5rem` |
|
|
192
|
+
| `--a11y-checkbox-input-border-width` | `2px` |
|
|
193
|
+
| `--a11y-checkbox-input-size` | `1.125rem` |
|
|
194
|
+
| `--a11y-checkbox-label-font-size` | `1rem` |
|
|
195
|
+
| `--a11y-checkbox-label-line-height` | `1.4` |
|
|
196
|
+
| `--a11y-checkbox-transition-duration` | `0.2s` |
|
|
197
|
+
|
|
198
|
+
</details>
|
|
199
|
+
|
|
200
|
+
#### `a11y-focusable`
|
|
201
|
+
|
|
202
|
+
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.
|
|
203
|
+
|
|
204
|
+
```html
|
|
205
|
+
<a11y-focusable aria-label="Expand menu">
|
|
206
|
+
<svg aria-hidden="true">…</svg> Menu
|
|
207
|
+
</a11y-focusable>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
| Name | Kind | Default | Description |
|
|
211
|
+
| --- | --- | --- | --- |
|
|
212
|
+
| `aria-label` | attribute | — | Accessible name. Without it (or visible text), a console warning is logged. |
|
|
213
|
+
|
|
214
|
+
No CSS variables.
|
|
215
|
+
|
|
216
|
+
#### `a11y-input`
|
|
217
|
+
|
|
218
|
+
A text field built from a real `<input>` and optional parts, wired together for you:
|
|
219
|
+
|
|
220
|
+
* `<a11y-label>`: the visible label, linked with `for`. See [`a11y-label`](#a11y-label).
|
|
221
|
+
* `<a11y-hint>`: help text, any number of them, added to the input's `aria-describedby`.
|
|
222
|
+
* `<a11y-error>`: where the validation message is shown. It's hidden, and left out of `aria-describedby`, until there's an error to show.
|
|
223
|
+
* `<a11y-counter>`: a length counter, see [`a11y-textarea`](#a11y-textarea).
|
|
224
|
+
|
|
225
|
+
```html
|
|
226
|
+
<form>
|
|
227
|
+
<a11y-input type-mismatch-message="Enter an email like name@example.com">
|
|
228
|
+
<a11y-label>Email</a11y-label>
|
|
229
|
+
<input type="email" name="email" required>
|
|
230
|
+
<a11y-hint>We never share it.</a11y-hint>
|
|
231
|
+
<a11y-error></a11y-error>
|
|
232
|
+
</a11y-input>
|
|
233
|
+
</form>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The input stays yours and is never regenerated. 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. Ids you set are kept; missing ones are generated.
|
|
237
|
+
|
|
238
|
+
**When errors show.** Like `:user-invalid`, a field isn't flagged while it's first being filled in. Its error shows when it's left after an edit, or when a submit attempt finds it invalid. From then on it updates as the user types, and a form reset hides it again. While shown, the input has `aria-invalid="true"` and the message is in its `aria-describedby`.
|
|
239
|
+
|
|
240
|
+
**Submitting.** 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.
|
|
241
|
+
|
|
242
|
+
**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.
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
import 'a11y-elements/components/input';
|
|
246
|
+
import type { InputElement } from 'a11y-elements/components/input/element';
|
|
247
|
+
|
|
248
|
+
const username = document.getElementById('username') as InputElement;
|
|
249
|
+
username.validators = [(value) => (takenNames.has(value) ? 'That name is taken' : null)];
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**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:
|
|
253
|
+
|
|
254
|
+
```css
|
|
255
|
+
a11y-input:state(user-invalid) { background: #fef2f2; } /* the error is shown */
|
|
256
|
+
a11y-input:state(touched) { … } /* left at least once */
|
|
257
|
+
a11y-input:state(dirty) { … } /* edited at least once */
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Where `:state()` isn't supported, style `input[aria-invalid="true"]` instead.
|
|
261
|
+
|
|
262
|
+
Checkbox, radio, range, color, file, hidden and button inputs are left alone: use `<a11y-checkbox>`, `<a11y-radio-group>`, … for those.
|
|
263
|
+
|
|
264
|
+
| Name | Kind | Default | Description |
|
|
265
|
+
| --- | --- | --- | --- |
|
|
266
|
+
| `value-missing-message` | attribute | browser's | Message when `required` isn't met. |
|
|
267
|
+
| `type-mismatch-message` | attribute | browser's | Message when the value doesn't match `type` (`email`, `url`). |
|
|
268
|
+
| `pattern-mismatch-message` | attribute | browser's | Message when the value doesn't match `pattern`. |
|
|
269
|
+
| `too-short-message` / `too-long-message` | attribute | browser's | Messages for `minlength` / `maxlength`. |
|
|
270
|
+
| `range-underflow-message` / `range-overflow-message` | attribute | browser's | Messages for `min` / `max`. |
|
|
271
|
+
| `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). |
|
|
272
|
+
| `validators` | property | `[]` | `((value, control) => string \| null)[]`, run after the native constraints. |
|
|
273
|
+
| `onInput` / `onChange` | callback | — | `(value: string) => void`, called on every `input` / `change`. |
|
|
274
|
+
| `getValue()` / `setValue(value)` | method | — | Reads / sets the value. `setValue` re-validates without marking the field as edited. |
|
|
275
|
+
| `checkValidity()` | method | — | Returns whether the field is valid, without showing anything. |
|
|
276
|
+
| `reportValidity()` | method | — | Shows the error and focuses the input when it's invalid. |
|
|
277
|
+
| `validity` / `validationMessage` / `willValidate` / `form` | property | — | Same as on the input; `validationMessage` includes your overrides. |
|
|
278
|
+
|
|
279
|
+
Message attributes can use `{min}`, `{max}`, `{minlength}` and `{maxlength}`, filled from the input's attributes: `too-short-message="At least {minlength} characters"`.
|
|
280
|
+
|
|
281
|
+
<details>
|
|
282
|
+
<summary>CSS variables</summary>
|
|
283
|
+
|
|
284
|
+
| Variable | Default |
|
|
285
|
+
| --- | --- |
|
|
286
|
+
| `--a11y-input-color-background` | `#ffffff` |
|
|
287
|
+
| `--a11y-input-color-border` | `#d1d5db` |
|
|
288
|
+
| `--a11y-input-color-border-strong` | `#9ca3af` |
|
|
289
|
+
| `--a11y-input-color-disabled-bg` | `#e5e7eb` |
|
|
290
|
+
| `--a11y-input-color-disabled-text` | `#9ca3af` |
|
|
291
|
+
| `--a11y-input-color-error` | `#b91c1c` |
|
|
292
|
+
| `--a11y-input-color-primary` | `#2563eb` |
|
|
293
|
+
| `--a11y-input-color-text` | `#111827` |
|
|
294
|
+
| `--a11y-input-control-border-radius` | `4px` |
|
|
295
|
+
| `--a11y-input-control-border-width` | `1px` |
|
|
296
|
+
| `--a11y-input-control-font-family` | `inherit` |
|
|
297
|
+
| `--a11y-input-control-font-size` | `1rem` |
|
|
298
|
+
| `--a11y-input-control-line-height` | `1.4` |
|
|
299
|
+
| `--a11y-input-control-padding-x` | `0.75rem` |
|
|
300
|
+
| `--a11y-input-control-padding-y` | `0.5rem` |
|
|
301
|
+
| `--a11y-input-focus-outline-offset` | `2px` |
|
|
302
|
+
| `--a11y-input-focus-outline-width` | `2px` |
|
|
303
|
+
| `--a11y-input-gap` | `0.25rem` |
|
|
304
|
+
| `--a11y-input-transition-duration` | `0.2s` |
|
|
305
|
+
|
|
306
|
+
Shared by the parts of every field:
|
|
307
|
+
|
|
308
|
+
| Variable | Default |
|
|
309
|
+
| --- | --- |
|
|
310
|
+
| `--a11y-field-color-error` | `#b91c1c` |
|
|
311
|
+
| `--a11y-field-color-text-muted` | `#6b7280` |
|
|
312
|
+
| `--a11y-field-error-font-weight` | `600` |
|
|
313
|
+
| `--a11y-field-part-font-size` | `0.875rem` |
|
|
314
|
+
| `--a11y-field-part-line-height` | `1.4` |
|
|
315
|
+
|
|
316
|
+
</details>
|
|
317
|
+
|
|
318
|
+
##### Building your own field: `bindField()`
|
|
319
|
+
|
|
320
|
+
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.
|
|
321
|
+
|
|
322
|
+
```ts
|
|
323
|
+
import { bindField } from 'a11y-elements/core';
|
|
324
|
+
|
|
325
|
+
const field = bindField(
|
|
326
|
+
{ control: input, label: labelEl, hints: [hintEl], error: errorEl, counter: counterEl },
|
|
327
|
+
{
|
|
328
|
+
validators: [(value) => (value.includes(' ') ? 'No spaces' : null)],
|
|
329
|
+
messages: { valueMissing: 'Required', tooShort: 'At least {minlength} characters' },
|
|
330
|
+
onStateChange: ({ valid, message, touched, dirty, showError }) => { /* mirror it in your state */ },
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
field.sync({ control: input, label: labelEl, hints: [], error: errorEl }); // after parts change
|
|
335
|
+
field.show(); // show the error now, as a submit attempt would
|
|
336
|
+
field.reset(); // back to pristine (also happens on its own on form reset)
|
|
337
|
+
field.destroy(); // on unmount: removes its listeners and the ARIA it added
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
A real `<label>` is linked with `for`; any other element with `aria-labelledby`. Tokens you put in `aria-describedby` / `aria-labelledby` yourself are kept.
|
|
341
|
+
|
|
342
|
+
#### `a11y-label`
|
|
343
|
+
|
|
344
|
+
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:
|
|
345
|
+
|
|
346
|
+
```html
|
|
347
|
+
<a11y-label for="search">Search</a11y-label>
|
|
348
|
+
<input id="search" type="search">
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
A `*` marks a required field. It's CSS only and hidden from screen readers, which already announce the control's `required`.
|
|
352
|
+
|
|
353
|
+
| Name | Kind | Default | Description |
|
|
354
|
+
| --- | --- | --- | --- |
|
|
355
|
+
| `for` | attribute | — | Id of the control to label, when used outside a field. |
|
|
356
|
+
| `required` | attribute | absent | Shows the required marker outside a field (inside one, it follows the control's `required`). |
|
|
357
|
+
| `label` | property | — | The rendered `<label>` element. |
|
|
358
|
+
|
|
359
|
+
<details>
|
|
360
|
+
<summary>CSS variables</summary>
|
|
361
|
+
|
|
362
|
+
| Variable | Default |
|
|
363
|
+
| --- | --- |
|
|
364
|
+
| `--a11y-label-color-required` | `#b91c1c` |
|
|
365
|
+
| `--a11y-label-color-text` | `#111827` |
|
|
366
|
+
| `--a11y-label-font-size` | `0.875rem` |
|
|
367
|
+
| `--a11y-label-font-weight` | `600` |
|
|
368
|
+
| `--a11y-label-line-height` | `1.4` |
|
|
369
|
+
| `--a11y-label-required-gap` | `0.25em` |
|
|
370
|
+
| `--a11y-label-required-marker` | `"*"` |
|
|
371
|
+
|
|
372
|
+
</details>
|
|
373
|
+
|
|
374
|
+
#### `a11y-picture`
|
|
375
|
+
|
|
376
|
+
Wraps a real `<picture>`/`<img>` and optional `<figcaption>` as `role="figure"`. An image with `alt=""` and no caption is treated as decorative and hidden from assistive tech (`aria-hidden="true"`).
|
|
377
|
+
|
|
378
|
+
```html
|
|
379
|
+
<a11y-picture>
|
|
380
|
+
<picture>
|
|
381
|
+
<source srcset="hero.webp" type="image/webp">
|
|
382
|
+
<img src="hero.jpg" alt="Sunset over the Rockies" loading="lazy" decoding="async">
|
|
383
|
+
</picture>
|
|
384
|
+
<figcaption>Sunset over the Rockies</figcaption>
|
|
385
|
+
</a11y-picture>
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
No attributes of its own.
|
|
389
|
+
|
|
390
|
+
<details>
|
|
391
|
+
<summary>CSS variables</summary>
|
|
392
|
+
|
|
393
|
+
| Variable | Default |
|
|
394
|
+
| --- | --- |
|
|
395
|
+
| `--a11y-picture-caption-font-size` | `0.875rem` |
|
|
396
|
+
| `--a11y-picture-caption-line-height` | `1.4` |
|
|
397
|
+
| `--a11y-picture-caption-margin-top` | `0.25rem` |
|
|
398
|
+
| `--a11y-picture-color-text-muted` | `#6b7280` |
|
|
399
|
+
|
|
400
|
+
</details>
|
|
401
|
+
|
|
402
|
+
#### `a11y-progress`
|
|
403
|
+
|
|
404
|
+
A labelled progress bar around a native `<progress>`. Without `value`, it shows an indeterminate animation.
|
|
405
|
+
|
|
406
|
+
```html
|
|
407
|
+
<a11y-progress value="50" max="100" label="Uploading…"></a11y-progress>
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
| Name | Kind | Default | Description |
|
|
411
|
+
| --- | --- | --- | --- |
|
|
412
|
+
| `value` | attribute / property | — | Current value; absent means indeterminate. |
|
|
413
|
+
| `max` | attribute / property | `100` | Maximum value. |
|
|
414
|
+
| `label` | attribute | — | Visible label, used as the accessible name. |
|
|
415
|
+
| `aria-label` | attribute | `Progress` | Accessible name when there's no visible `label`. The default can be [translated](#translating-built-in-strings). |
|
|
416
|
+
|
|
417
|
+
<details>
|
|
418
|
+
<summary>CSS variables</summary>
|
|
419
|
+
|
|
420
|
+
| Variable | Default |
|
|
421
|
+
| --- | --- |
|
|
422
|
+
| `--a11y-progress-bar-border-radius` | `9999px` |
|
|
423
|
+
| `--a11y-progress-bar-height` | `0.5rem` |
|
|
424
|
+
| `--a11y-progress-bar-transition-duration` | `0.3s` |
|
|
425
|
+
| `--a11y-progress-color-primary` | `#2563eb` |
|
|
426
|
+
| `--a11y-progress-color-surface` | `#f3f4f6` |
|
|
427
|
+
| `--a11y-progress-color-text-muted` | `#6b7280` |
|
|
428
|
+
| `--a11y-progress-gap` | `0.25rem` |
|
|
429
|
+
| `--a11y-progress-indeterminate-duration` | `1.5s` |
|
|
430
|
+
| `--a11y-progress-label-font-size` | `0.875rem` |
|
|
431
|
+
| `--a11y-progress-label-font-weight` | `500` |
|
|
432
|
+
|
|
433
|
+
</details>
|
|
434
|
+
|
|
435
|
+
#### `a11y-radio-group`
|
|
436
|
+
|
|
437
|
+
Wraps your radios in a `<fieldset>` with a `<legend>`. Give every radio the same `name`; that's what makes them one native group.
|
|
438
|
+
|
|
439
|
+
```html
|
|
440
|
+
<a11y-radio-group legend="Choose a plan">
|
|
441
|
+
<label><input type="radio" name="plan" value="basic"> Basic</label>
|
|
442
|
+
<label><input type="radio" name="plan" value="pro"> Pro</label>
|
|
443
|
+
</a11y-radio-group>
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
| Name | Kind | Default | Description |
|
|
447
|
+
| --- | --- | --- | --- |
|
|
448
|
+
| `legend` | attribute | — | Visible group label. |
|
|
449
|
+
| `aria-label` | attribute | — | Group name when there's no `legend`. |
|
|
450
|
+
| `disabled` | attribute | absent | Disables every option (through the fieldset). |
|
|
451
|
+
| `onChange` | callback | — | `(value: string) => void`, called when an option is checked. |
|
|
452
|
+
| `getValue()` / `setValue(value)` | method | — | Reads the checked value / checks the option with that value. |
|
|
453
|
+
|
|
454
|
+
<details>
|
|
455
|
+
<summary>CSS variables</summary>
|
|
456
|
+
|
|
457
|
+
| Variable | Default |
|
|
458
|
+
| --- | --- |
|
|
459
|
+
| `--a11y-radio-group-checked-inner-ring` | `0.2rem` |
|
|
460
|
+
| `--a11y-radio-group-checked-outer-ring` | `0.5rem` |
|
|
461
|
+
| `--a11y-radio-group-color-background` | `#ffffff` |
|
|
462
|
+
| `--a11y-radio-group-color-border` | `#d1d5db` |
|
|
463
|
+
| `--a11y-radio-group-color-border-strong` | `#9ca3af` |
|
|
464
|
+
| `--a11y-radio-group-color-disabled-bg` | `#e5e7eb` |
|
|
465
|
+
| `--a11y-radio-group-color-primary` | `#2563eb` |
|
|
466
|
+
| `--a11y-radio-group-color-text` | `#111827` |
|
|
467
|
+
| `--a11y-radio-group-color-text-muted` | `#6b7280` |
|
|
468
|
+
| `--a11y-radio-group-disabled-opacity` | `0.6` |
|
|
469
|
+
| `--a11y-radio-group-focus-outline-offset` | `2px` |
|
|
470
|
+
| `--a11y-radio-group-focus-outline-width` | `2px` |
|
|
471
|
+
| `--a11y-radio-group-input-border-width` | `2px` |
|
|
472
|
+
| `--a11y-radio-group-input-size` | `1.125rem` |
|
|
473
|
+
| `--a11y-radio-group-input-transition-duration` | `0.2s` |
|
|
474
|
+
| `--a11y-radio-group-label-font-size` | `1rem` |
|
|
475
|
+
| `--a11y-radio-group-label-line-height` | `1.4` |
|
|
476
|
+
| `--a11y-radio-group-legend-font-size` | `0.875rem` |
|
|
477
|
+
| `--a11y-radio-group-legend-margin-bottom` | `0.5rem` |
|
|
478
|
+
| `--a11y-radio-group-option-gap` | `0.5rem` |
|
|
479
|
+
| `--a11y-radio-group-options-gap` | `0.5rem` |
|
|
480
|
+
|
|
481
|
+
</details>
|
|
482
|
+
|
|
483
|
+
#### `a11y-select`
|
|
484
|
+
|
|
485
|
+
Wraps a real `<select>` in a `<label>` with a visible label text. Options and keyboard handling stay native.
|
|
486
|
+
|
|
487
|
+
```html
|
|
488
|
+
<a11y-select label="Country">
|
|
489
|
+
<select name="country">
|
|
490
|
+
<option value="us">United States</option>
|
|
491
|
+
<option value="ca">Canada</option>
|
|
492
|
+
</select>
|
|
493
|
+
</a11y-select>
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
| Name | Kind | Default | Description |
|
|
497
|
+
| --- | --- | --- | --- |
|
|
498
|
+
| `label` | attribute | — | Visible label text. |
|
|
499
|
+
| `onChange` | callback | — | `(value: string) => void`, called on every `change`. |
|
|
500
|
+
| `getValue()` / `setValue(value)` | method | — | Reads / sets the selected value. |
|
|
501
|
+
|
|
502
|
+
<details>
|
|
503
|
+
<summary>CSS variables</summary>
|
|
504
|
+
|
|
505
|
+
| Variable | Default |
|
|
506
|
+
| --- | --- |
|
|
507
|
+
| `--a11y-select-color-border` | `#d1d5db` |
|
|
508
|
+
| `--a11y-select-color-border-strong` | `#9ca3af` |
|
|
509
|
+
| `--a11y-select-color-disabled-bg` | `#e5e7eb` |
|
|
510
|
+
| `--a11y-select-color-disabled-text` | `#9ca3af` |
|
|
511
|
+
| `--a11y-select-color-primary` | `#2563eb` |
|
|
512
|
+
| `--a11y-select-color-surface` | `#f3f4f6` |
|
|
513
|
+
| `--a11y-select-color-text` | `#111827` |
|
|
514
|
+
| `--a11y-select-color-text-muted` | `#6b7280` |
|
|
515
|
+
| `--a11y-select-control-border-radius` | `4px` |
|
|
516
|
+
| `--a11y-select-control-border-width` | `1px` |
|
|
517
|
+
| `--a11y-select-control-font-family` | `Arial, sans-serif` |
|
|
518
|
+
| `--a11y-select-control-font-size` | `1rem` |
|
|
519
|
+
| `--a11y-select-control-line-height` | `1.4` |
|
|
520
|
+
| `--a11y-select-control-padding-x` | `1rem` |
|
|
521
|
+
| `--a11y-select-control-padding-y` | `0.5rem` |
|
|
522
|
+
| `--a11y-select-control-transition-duration` | `0.2s` |
|
|
523
|
+
| `--a11y-select-focus-outline-offset` | `2px` |
|
|
524
|
+
| `--a11y-select-focus-outline-width` | `2px` |
|
|
525
|
+
| `--a11y-select-gap` | `0.25rem` |
|
|
526
|
+
| `--a11y-select-label-font-size` | `0.875rem` |
|
|
527
|
+
| `--a11y-select-label-font-weight` | `600` |
|
|
528
|
+
|
|
529
|
+
</details>
|
|
530
|
+
|
|
531
|
+
#### `a11y-skeleton`
|
|
532
|
+
|
|
533
|
+
A loading placeholder, hidden from assistive tech.
|
|
534
|
+
|
|
535
|
+
```html
|
|
536
|
+
<a11y-skeleton variant="text" lines="3"></a11y-skeleton>
|
|
537
|
+
<a11y-skeleton variant="circle" width="3rem"></a11y-skeleton>
|
|
538
|
+
<a11y-skeleton width="100%" height="10rem"></a11y-skeleton>
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
| Name | Kind | Default | Description |
|
|
542
|
+
| --- | --- | --- | --- |
|
|
543
|
+
| `variant` | attribute / property | `rect` | `rect`, `circle` or `text`. |
|
|
544
|
+
| `lines` | attribute / property | `1` | Number of lines, for `variant="text"`. |
|
|
545
|
+
| `width` | attribute | — | Sets `--a11y-skeleton-width`. |
|
|
546
|
+
| `height` | attribute | — | Sets `--a11y-skeleton-height`. |
|
|
547
|
+
|
|
548
|
+
<details>
|
|
549
|
+
<summary>CSS variables</summary>
|
|
550
|
+
|
|
551
|
+
| Variable | Default |
|
|
552
|
+
| --- | --- |
|
|
553
|
+
| `--a11y-skeleton-border-radius` | `4px` |
|
|
554
|
+
| `--a11y-skeleton-circle-default-size` | `2.5rem` |
|
|
555
|
+
| `--a11y-skeleton-color-surface` | `#f3f4f6` |
|
|
556
|
+
| `--a11y-skeleton-default-height` | `1em` |
|
|
557
|
+
| `--a11y-skeleton-height` | `1em` (`--a11y-skeleton-default-height`); circle: same as width |
|
|
558
|
+
| `--a11y-skeleton-last-line-width` | `70%` |
|
|
559
|
+
| `--a11y-skeleton-line-border-radius` | `2px` |
|
|
560
|
+
| `--a11y-skeleton-multiline-gap` | `0.5rem` |
|
|
561
|
+
| `--a11y-skeleton-pulse-duration` | `1.5s` |
|
|
562
|
+
| `--a11y-skeleton-pulse-min-opacity` | `0.45` |
|
|
563
|
+
| `--a11y-skeleton-stagger-delay` | `0.1s` |
|
|
564
|
+
| `--a11y-skeleton-text-border-radius` | `2px` |
|
|
565
|
+
| `--a11y-skeleton-width` | `100%`; circle: `2.5rem` (`--a11y-skeleton-circle-default-size`) |
|
|
566
|
+
|
|
567
|
+
</details>
|
|
568
|
+
|
|
569
|
+
#### `a11y-spinner`
|
|
570
|
+
|
|
571
|
+
A loading spinner with `role="status"`. No JS needed beyond the define.
|
|
572
|
+
|
|
573
|
+
```html
|
|
574
|
+
<a11y-spinner label="Saving…" size="3rem" color="#16a34a"></a11y-spinner>
|
|
575
|
+
<a11y-spinner class="a11y-spinner--lg"></a11y-spinner>
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
| Name | Kind | Default | Description |
|
|
579
|
+
| --- | --- | --- | --- |
|
|
580
|
+
| `label` | attribute / property | `Loading` | Accessible name. The default can be [translated](#translating-built-in-strings). |
|
|
581
|
+
| `size` | attribute / property | — | Sets `--a11y-spinner-size`. |
|
|
582
|
+
| `color` | attribute / property | — | Sets `--a11y-spinner-color`. |
|
|
583
|
+
| `duration` | attribute / property | — | Sets `--a11y-spinner-duration`. |
|
|
584
|
+
| `thickness` | attribute / property | — | Sets `--a11y-spinner-thickness`. |
|
|
585
|
+
|
|
586
|
+
Size presets: add `a11y-spinner--sm`, `a11y-spinner--lg` or `a11y-spinner--xl` to `class`.
|
|
587
|
+
|
|
588
|
+
<details>
|
|
589
|
+
<summary>CSS variables</summary>
|
|
590
|
+
|
|
591
|
+
| Variable | Default |
|
|
592
|
+
| --- | --- |
|
|
593
|
+
| `--a11y-spinner-border-radius` | `50%` |
|
|
594
|
+
| `--a11y-spinner-color` | `#2563eb` |
|
|
595
|
+
| `--a11y-spinner-duration` | `1s` |
|
|
596
|
+
| `--a11y-spinner-size` | `2rem` |
|
|
597
|
+
| `--a11y-spinner-size-lg` | `3rem` |
|
|
598
|
+
| `--a11y-spinner-size-sm` | `1rem` |
|
|
599
|
+
| `--a11y-spinner-size-xl` | `4rem` |
|
|
600
|
+
| `--a11y-spinner-thickness` | `3px` |
|
|
601
|
+
| `--a11y-spinner-thickness-lg` | `4px` |
|
|
602
|
+
| `--a11y-spinner-thickness-sm` | `2px` |
|
|
603
|
+
| `--a11y-spinner-thickness-xl` | `5px` |
|
|
604
|
+
|
|
605
|
+
</details>
|
|
606
|
+
|
|
607
|
+
#### `a11y-switch`
|
|
608
|
+
|
|
609
|
+
Like `<a11y-checkbox>`, but the input gets `role="switch"`.
|
|
610
|
+
|
|
611
|
+
```html
|
|
612
|
+
<a11y-switch label="Enable notifications">
|
|
613
|
+
<input type="checkbox" name="notifications">
|
|
614
|
+
</a11y-switch>
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
| Name | Kind | Default | Description |
|
|
618
|
+
| --- | --- | --- | --- |
|
|
619
|
+
| `label` | attribute | — | Visible label text. |
|
|
620
|
+
| `onChange` | callback | — | `(checked: boolean) => void`, called on every `change`. |
|
|
621
|
+
| `getValue()` / `setValue(checked)` | method | — | Reads / sets `checked`. |
|
|
622
|
+
|
|
623
|
+
<details>
|
|
624
|
+
<summary>CSS variables</summary>
|
|
625
|
+
|
|
626
|
+
| Variable | Default |
|
|
627
|
+
| --- | --- |
|
|
628
|
+
| `--a11y-switch-border-radius` | `9999px` |
|
|
629
|
+
| `--a11y-switch-color-background` | `#ffffff` |
|
|
630
|
+
| `--a11y-switch-color-border-strong` | `#9ca3af` |
|
|
631
|
+
| `--a11y-switch-color-disabled-bg` | `#e5e7eb` |
|
|
632
|
+
| `--a11y-switch-color-disabled-text` | `#9ca3af` |
|
|
633
|
+
| `--a11y-switch-color-primary` | `#2563eb` |
|
|
634
|
+
| `--a11y-switch-color-text` | `#111827` |
|
|
635
|
+
| `--a11y-switch-disabled-opacity` | `0.6` |
|
|
636
|
+
| `--a11y-switch-focus-outline-offset` | `2px` |
|
|
637
|
+
| `--a11y-switch-focus-outline-width` | `2px` |
|
|
638
|
+
| `--a11y-switch-gap` | `0.5rem` |
|
|
639
|
+
| `--a11y-switch-label-font-size` | `1rem` |
|
|
640
|
+
| `--a11y-switch-label-line-height` | `1.4` |
|
|
641
|
+
| `--a11y-switch-thumb-offset` | `calc((var(--a11y-switch-track-height, 1.5rem) - var(--a11y-switch-thumb-size, 1.125rem)) / 2)` |
|
|
642
|
+
| `--a11y-switch-thumb-shadow-blur` | `3px` |
|
|
643
|
+
| `--a11y-switch-thumb-shadow-color` | `rgba(0 0 0 / 25%)` |
|
|
644
|
+
| `--a11y-switch-thumb-shadow-offset-y` | `1px` |
|
|
645
|
+
| `--a11y-switch-thumb-size` | `1.125rem` |
|
|
646
|
+
| `--a11y-switch-track-height` | `1.5rem` |
|
|
647
|
+
| `--a11y-switch-track-width` | `2.75rem` |
|
|
648
|
+
| `--a11y-switch-transition-duration` | `0.2s` |
|
|
649
|
+
|
|
650
|
+
</details>
|
|
651
|
+
|
|
652
|
+
#### `a11y-textarea`
|
|
653
|
+
|
|
654
|
+
`<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
|
|
655
|
+
|
|
656
|
+
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.
|
|
657
|
+
|
|
658
|
+
```html
|
|
659
|
+
<a11y-textarea value-missing-message="Tell us a bit more">
|
|
660
|
+
<a11y-label>Bio</a11y-label>
|
|
661
|
+
<textarea name="bio" required maxlength="200"></textarea>
|
|
662
|
+
<a11y-counter></a11y-counter>
|
|
663
|
+
<a11y-error></a11y-error>
|
|
664
|
+
</a11y-textarea>
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
The counter's strings can be [translated](#translating-built-in-strings).
|
|
668
|
+
|
|
669
|
+
<details>
|
|
670
|
+
<summary>CSS variables</summary>
|
|
671
|
+
|
|
672
|
+
The same as [`a11y-input`](#a11y-input), prefixed `--a11y-textarea-` instead of `--a11y-input-`, plus:
|
|
673
|
+
|
|
674
|
+
| Variable | Default |
|
|
675
|
+
| --- | --- |
|
|
676
|
+
| `--a11y-textarea-min-height` | `6rem` |
|
|
677
|
+
| `--a11y-textarea-resize` | `vertical` |
|
|
678
|
+
|
|
679
|
+
</details>
|
|
680
|
+
|
|
681
|
+
#### `a11y-visually-hidden`
|
|
682
|
+
|
|
683
|
+
Content for screen readers only, hidden visually.
|
|
684
|
+
|
|
685
|
+
```html
|
|
686
|
+
<button>
|
|
687
|
+
<svg aria-hidden="true">…</svg>
|
|
688
|
+
<a11y-visually-hidden>Delete item</a11y-visually-hidden>
|
|
689
|
+
</button>
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
No attributes or CSS variables. The class `a11y-visually-hidden` is also usable on its own.
|
|
693
|
+
|
|
694
|
+
### Overlays
|
|
695
|
+
|
|
696
|
+
#### Common to all overlays
|
|
697
|
+
|
|
698
|
+
* **Open/close** with the `open` attribute or property, or `show()` / `close()`.
|
|
699
|
+
* **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.
|
|
700
|
+
* **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on `document`, with `event.detail.name` set to the tag name.
|
|
701
|
+
* **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
702
|
+
* **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.
|
|
703
|
+
|
|
704
|
+
##### Overlays in a framework
|
|
705
|
+
|
|
706
|
+
###### Removing them is up to you.
|
|
707
|
+
|
|
708
|
+
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`.
|
|
709
|
+
|
|
710
|
+
```js
|
|
711
|
+
import { removeOverlaysWithin } from 'a11y-elements/core';
|
|
712
|
+
// or: import { removeOverlaysWithin } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
|
|
713
|
+
|
|
714
|
+
onUnmount(() => removeOverlaysWithin(hostElement)); // your framework's unmount hook
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
Nothing is removed automatically, so subtrees your framework detaches and reattaches later (keep-alive caches, keyed moves) keep their overlays.
|
|
718
|
+
|
|
719
|
+
##### Don't reach overlay content through the host.
|
|
720
|
+
|
|
721
|
+
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.
|
|
722
|
+
|
|
723
|
+
If the bundle loads after rendering, the same query does find it, so the result depends on load order.
|
|
724
|
+
|
|
725
|
+
**Instead:**
|
|
726
|
+
|
|
727
|
+
* get the overlay by `id` (`document.getElementById`) and query inside it;
|
|
728
|
+
* bind events on the overlay element itself, or delegate from it;
|
|
729
|
+
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
730
|
+
|
|
731
|
+
##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
732
|
+
|
|
733
|
+
They also share:
|
|
734
|
+
|
|
735
|
+
* A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`).
|
|
736
|
+
* Escape, a click on the backdrop, or the × close button close it, unless it's `non-dismissible`.
|
|
737
|
+
* The dialog is named after its first heading (`aria-labelledby`), or `dialog-label`.
|
|
738
|
+
|
|
739
|
+
| Name | Kind | Default | Description |
|
|
740
|
+
| --- | --- | --- | --- |
|
|
741
|
+
| `non-dismissible` | attribute | absent | No close button, no Escape, no backdrop click: close it from code. |
|
|
742
|
+
| `dialog-label` | attribute | — | Accessible name (`aria-label`) when there's no heading. |
|
|
743
|
+
| `close-label` | attribute | `Close dialog` | Accessible name of the × close button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
744
|
+
| `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
|
|
745
|
+
| `onClose` | callback | — | Called once the close transition has finished. |
|
|
746
|
+
|
|
747
|
+
##### Anchored overlays (`<a11y-popover>`, `<a11y-tooltip>`, `<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
748
|
+
|
|
749
|
+
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.
|
|
750
|
+
|
|
751
|
+
| Name | Kind | Default | Description |
|
|
752
|
+
| --- | --- | --- | --- |
|
|
753
|
+
| `anchor` | attribute | — | `id` of the anchor element. |
|
|
754
|
+
| `anchorElement` | property | — | The anchor element itself (takes precedence over `anchor`). |
|
|
755
|
+
| `placement` | attribute | `bottom` | `top`, `bottom`, `left` or `right`, optionally with `-start` / `-end` (e.g. `bottom-start`). |
|
|
756
|
+
| `offset` | attribute | `8` | Gap to the anchor, in px. |
|
|
757
|
+
| `updatePosition()` | method | — | Recomputes the position (it already follows scroll, resize and size changes). |
|
|
758
|
+
|
|
759
|
+
##### Menus (`<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
760
|
+
|
|
761
|
+
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.
|
|
762
|
+
|
|
763
|
+
<details>
|
|
764
|
+
<summary>CSS variables shared by anchored overlays and menus</summary>
|
|
765
|
+
|
|
766
|
+
| Variable | Default |
|
|
767
|
+
| --- | --- |
|
|
768
|
+
| `--a11y-anchored-overlay-initial-scale` | `0.97` |
|
|
769
|
+
| `--a11y-anchored-overlay-transition-duration` | `0.15s` |
|
|
770
|
+
| `--a11y-menu-item-color-background` | `#ffffff` |
|
|
771
|
+
| `--a11y-menu-item-color-secondary-hover` | `#4b5563` |
|
|
772
|
+
| `--a11y-menu-item-color-text` | `#111827` |
|
|
773
|
+
| `--a11y-menu-item-disabled-opacity` | `0.5` |
|
|
774
|
+
| `--a11y-menu-item-padding` | `0.5rem 1rem` |
|
|
775
|
+
|
|
776
|
+
</details>
|
|
777
|
+
|
|
778
|
+
#### `a11y-blocking-loader`
|
|
779
|
+
|
|
780
|
+
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).
|
|
781
|
+
|
|
782
|
+
```html
|
|
783
|
+
<a11y-blocking-loader id="saving" message="Saving your changes…"></a11y-blocking-loader>
|
|
784
|
+
```
|
|
785
|
+
|
|
786
|
+
```js
|
|
787
|
+
const loader = document.getElementById('saving');
|
|
788
|
+
loader.show();
|
|
789
|
+
await save();
|
|
790
|
+
loader.close();
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
| Name | Kind | Default | Description |
|
|
794
|
+
| --- | --- | --- | --- |
|
|
795
|
+
| `message` | attribute | — | Visible message, also the spinner's label (`Loading` without it, [translatable](#translating-built-in-strings)). |
|
|
796
|
+
|
|
797
|
+
<details>
|
|
798
|
+
<summary>CSS variables</summary>
|
|
799
|
+
|
|
800
|
+
| Variable | Default |
|
|
801
|
+
| --- | --- |
|
|
802
|
+
| `--a11y-blocking-loader-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
803
|
+
| `--a11y-blocking-loader-color-text` | `#111827` |
|
|
804
|
+
| `--a11y-blocking-loader-gap` | `1rem` |
|
|
805
|
+
| `--a11y-blocking-loader-message-font-size` | `1rem` |
|
|
806
|
+
| `--a11y-blocking-loader-message-font-weight` | `600` |
|
|
807
|
+
|
|
808
|
+
</details>
|
|
809
|
+
|
|
810
|
+
#### `a11y-context-menu`
|
|
811
|
+
|
|
812
|
+
A menu that opens at the pointer on right-click of a trigger element, replacing the browser's own menu there. See [Menus](#common-to-all-overlays).
|
|
813
|
+
|
|
814
|
+
```html
|
|
815
|
+
<div id="canvas">Right-click me</div>
|
|
816
|
+
<a11y-context-menu trigger="canvas">
|
|
817
|
+
<div role="menuitem">Copy</div>
|
|
818
|
+
<div role="menuitem">Paste</div>
|
|
819
|
+
</a11y-context-menu>
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
| Name | Kind | Default | Description |
|
|
823
|
+
| --- | --- | --- | --- |
|
|
824
|
+
| `trigger` | attribute | — | `id` of the element to right-click. |
|
|
825
|
+
| `triggerElement` | property | — | The trigger element itself (takes precedence over `trigger`). |
|
|
826
|
+
| `dispose()` | method | — | Detaches from the trigger for good (`close()` only hides the current menu). |
|
|
827
|
+
|
|
828
|
+
<details>
|
|
829
|
+
<summary>CSS variables</summary>
|
|
830
|
+
|
|
831
|
+
| Variable | Default |
|
|
832
|
+
| --- | --- |
|
|
833
|
+
| `--a11y-context-menu-border-radius` | `0.5rem` |
|
|
834
|
+
| `--a11y-context-menu-color-background` | `#ffffff` |
|
|
835
|
+
| `--a11y-context-menu-color-text` | `#111827` |
|
|
836
|
+
| `--a11y-context-menu-content-padding` | `0.25rem 0` |
|
|
837
|
+
| `--a11y-context-menu-min-width` | `160px` |
|
|
838
|
+
| `--a11y-context-menu-shadow-blur` | `10px` |
|
|
839
|
+
| `--a11y-context-menu-shadow-fade` | `85%` |
|
|
840
|
+
| `--a11y-context-menu-shadow-offset-y` | `2px` |
|
|
841
|
+
|
|
842
|
+
</details>
|
|
843
|
+
|
|
844
|
+
#### `a11y-drawer`
|
|
845
|
+
|
|
846
|
+
A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dialogs](#common-to-all-overlays)).
|
|
847
|
+
|
|
848
|
+
```html
|
|
849
|
+
<a11y-drawer id="filters" edge="left">
|
|
850
|
+
<h2>Filters</h2>
|
|
851
|
+
…
|
|
852
|
+
</a11y-drawer>
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
| Name | Kind | Default | Description |
|
|
856
|
+
| --- | --- | --- | --- |
|
|
857
|
+
| `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
|
|
858
|
+
|
|
859
|
+
<details>
|
|
860
|
+
<summary>CSS variables</summary>
|
|
861
|
+
|
|
862
|
+
The close button uses the modal's `--a11y-modal-close-button-size` and `--a11y-modal-color-secondary(-hover)`.
|
|
863
|
+
|
|
864
|
+
| Variable | Default |
|
|
865
|
+
| --- | --- |
|
|
866
|
+
| `--a11y-drawer-color-background` | `#ffffff` |
|
|
867
|
+
| `--a11y-drawer-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
868
|
+
| `--a11y-drawer-color-text` | `#111827` |
|
|
869
|
+
| `--a11y-drawer-content-padding` | `1.5rem` |
|
|
870
|
+
| `--a11y-drawer-height` | `min(480px, 90vh)` |
|
|
871
|
+
| `--a11y-drawer-shadow-blur` | `10px` |
|
|
872
|
+
| `--a11y-drawer-shadow-fade` | `80%` |
|
|
873
|
+
| `--a11y-drawer-shadow-offset-y` | `2px` |
|
|
874
|
+
| `--a11y-drawer-transition-duration` | `0.3s` |
|
|
875
|
+
| `--a11y-drawer-width` | `min(400px, 90vw)` |
|
|
876
|
+
|
|
877
|
+
</details>
|
|
878
|
+
|
|
879
|
+
#### `a11y-dropdown`
|
|
880
|
+
|
|
881
|
+
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 and Menus](#common-to-all-overlays).
|
|
882
|
+
|
|
883
|
+
```html
|
|
884
|
+
<button id="actions-btn">Actions</button>
|
|
885
|
+
<a11y-dropdown anchor="actions-btn" placement="bottom-start">
|
|
886
|
+
<div role="menuitem">Edit</div>
|
|
887
|
+
<div role="menuitem" aria-disabled="true">Share</div>
|
|
888
|
+
<div role="menuitem">Delete</div>
|
|
889
|
+
</a11y-dropdown>
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
No attributes of its own beyond the anchored ones.
|
|
893
|
+
|
|
894
|
+
<details>
|
|
895
|
+
<summary>CSS variables</summary>
|
|
896
|
+
|
|
897
|
+
| Variable | Default |
|
|
898
|
+
| --- | --- |
|
|
899
|
+
| `--a11y-dropdown-border-radius` | `0.5rem` |
|
|
900
|
+
| `--a11y-dropdown-color-background` | `#ffffff` |
|
|
901
|
+
| `--a11y-dropdown-color-text` | `#111827` |
|
|
902
|
+
| `--a11y-dropdown-content-padding` | `0.25rem 0` |
|
|
903
|
+
| `--a11y-dropdown-min-width` | `160px` |
|
|
904
|
+
| `--a11y-dropdown-shadow-blur` | `10px` |
|
|
905
|
+
| `--a11y-dropdown-shadow-fade` | `85%` |
|
|
906
|
+
| `--a11y-dropdown-shadow-offset-y` | `2px` |
|
|
907
|
+
|
|
908
|
+
</details>
|
|
909
|
+
|
|
910
|
+
#### `a11y-emergency-dialog`
|
|
64
911
|
|
|
65
|
-
|
|
912
|
+
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.
|
|
913
|
+
|
|
914
|
+
```html
|
|
915
|
+
<a11y-emergency-dialog id="session">
|
|
916
|
+
<h2>Session expiring</h2>
|
|
917
|
+
<p>You'll be signed out in 2 minutes.</p>
|
|
918
|
+
<div class="a11y-modal-buttons">
|
|
919
|
+
<button id="stay">Stay signed in</button>
|
|
920
|
+
</div>
|
|
921
|
+
</a11y-emergency-dialog>
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
```js
|
|
925
|
+
document.getElementById('stay').addEventListener('click', () => {
|
|
926
|
+
document.getElementById('session').close();
|
|
927
|
+
});
|
|
928
|
+
```
|
|
929
|
+
|
|
930
|
+
Only `onClose` from the [Dialogs](#common-to-all-overlays) table applies. It uses the modal's CSS variables, plus:
|
|
931
|
+
|
|
932
|
+
<details>
|
|
933
|
+
<summary>CSS variables</summary>
|
|
934
|
+
|
|
935
|
+
| Variable | Default |
|
|
936
|
+
| --- | --- |
|
|
937
|
+
| `--a11y-emergency-dialog-accent-width` | `4px` |
|
|
938
|
+
|
|
939
|
+
</details>
|
|
940
|
+
|
|
941
|
+
#### `a11y-modal`
|
|
942
|
+
|
|
943
|
+
A centered dialog. Your content is its children. See [Dialogs](#common-to-all-overlays).
|
|
66
944
|
|
|
67
945
|
```html
|
|
68
946
|
<button id="open-settings">Open settings</button>
|
|
69
947
|
<a11y-modal id="settings">
|
|
70
948
|
<h2>Settings</h2>
|
|
71
949
|
<p>Press Escape, click the backdrop, or the close button to dismiss.</p>
|
|
950
|
+
<div class="a11y-modal-buttons">
|
|
951
|
+
<button type="button">Save</button>
|
|
952
|
+
</div>
|
|
72
953
|
</a11y-modal>
|
|
73
954
|
```
|
|
74
955
|
|
|
@@ -80,7 +961,253 @@ document.getElementById('open-settings').addEventListener('click', () => {
|
|
|
80
961
|
});
|
|
81
962
|
```
|
|
82
963
|
|
|
83
|
-
|
|
964
|
+
| Name | Kind | Default | Description |
|
|
965
|
+
| --- | --- | --- | --- |
|
|
966
|
+
| `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
|
|
967
|
+
|
|
968
|
+
`.a11y-modal-buttons` is an optional footer-row class for your own buttons.
|
|
969
|
+
|
|
970
|
+
<details>
|
|
971
|
+
<summary>CSS variables</summary>
|
|
972
|
+
|
|
973
|
+
| Variable | Default |
|
|
974
|
+
| --- | --- |
|
|
975
|
+
| `--a11y-modal-border-radius` | `1rem` |
|
|
976
|
+
| `--a11y-modal-close-button-size` | `1.5rem` |
|
|
977
|
+
| `--a11y-modal-color-background` | `#ffffff` |
|
|
978
|
+
| `--a11y-modal-color-overlay` | `rgba(0, 0, 0, 0.5)` |
|
|
979
|
+
| `--a11y-modal-color-secondary` | `#6b7280` |
|
|
980
|
+
| `--a11y-modal-color-secondary-hover` | `#4b5563` |
|
|
981
|
+
| `--a11y-modal-color-text` | `#111827` |
|
|
982
|
+
| `--a11y-modal-content-padding` | `1.5rem` |
|
|
983
|
+
| `--a11y-modal-footer-button-padding` | `0.5rem 1rem` |
|
|
984
|
+
| `--a11y-modal-footer-gap` | `1rem` |
|
|
985
|
+
| `--a11y-modal-footer-margin-top` | `1.5rem` |
|
|
986
|
+
| `--a11y-modal-initial-scale` | `0.95` |
|
|
987
|
+
| `--a11y-modal-overlay-padding` | `clamp(1rem, 10vmin, 6rem)` |
|
|
988
|
+
| `--a11y-modal-shadow-blur` | `2px` |
|
|
989
|
+
| `--a11y-modal-shadow-fade` | `80%` |
|
|
990
|
+
| `--a11y-modal-shadow-offset-y` | `2px` |
|
|
991
|
+
| `--a11y-modal-transition-duration` | `0.3s` |
|
|
992
|
+
|
|
993
|
+
</details>
|
|
994
|
+
|
|
995
|
+
#### `a11y-notification-banner`
|
|
996
|
+
|
|
997
|
+
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.
|
|
998
|
+
|
|
999
|
+
```html
|
|
1000
|
+
<a11y-notification-banner id="banners" max-stack="2"></a11y-notification-banner>
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
```js
|
|
1004
|
+
import { showNotificationBanner } from 'a11y-elements/overlays/notification-banner';
|
|
1005
|
+
|
|
1006
|
+
showNotificationBanner('Your trial ends in 3 days.', {
|
|
1007
|
+
type: 'info',
|
|
1008
|
+
actionText: 'Upgrade',
|
|
1009
|
+
onAction: () => location.assign('/billing'),
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
// e.g. clear them on navigation
|
|
1013
|
+
window.addEventListener('popstate', () => document.getElementById('banners').dismissAll());
|
|
1014
|
+
```
|
|
1015
|
+
|
|
1016
|
+
| Name | Kind | Default | Description |
|
|
1017
|
+
| --- | --- | --- | --- |
|
|
1018
|
+
| `max-stack` | attribute | `3` | How many banners show at once; the rest wait in a queue and show as earlier ones are dismissed. |
|
|
1019
|
+
| `dismiss-label` | attribute | `Dismiss` | Accessible name of each banner's × button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1020
|
+
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1021
|
+
| `show(message, options)` | method | — | Shows a banner (or queues it). |
|
|
1022
|
+
| `dismissAll()` | method | — | Closes every banner (calling their `onClose`) and drops the queued ones silently. |
|
|
1023
|
+
|
|
1024
|
+
`show()` / `showNotificationBanner()` options:
|
|
1025
|
+
|
|
1026
|
+
| Option | Default | Description |
|
|
1027
|
+
| --- | --- | --- |
|
|
1028
|
+
| `type` | `info` | `info`, `success` or `error` (`error` uses `role="alert"`). |
|
|
1029
|
+
| `position` | `top` | `top` or `bottom`. |
|
|
1030
|
+
| `actionText` / `onAction` | — | Adds an action button; clicking it runs `onAction` and dismisses the banner. |
|
|
1031
|
+
| `onClose` | — | Called when the banner is dismissed. |
|
|
1032
|
+
| `maxStack` | — | Sets `max-stack` on the region (sticky for later banners). |
|
|
1033
|
+
|
|
1034
|
+
Classes: `.a11y-notification-banner--info` / `--success` / `--error`, `__message`, `__action`, `__close`.
|
|
1035
|
+
|
|
1036
|
+
<details>
|
|
1037
|
+
<summary>CSS variables</summary>
|
|
1038
|
+
|
|
1039
|
+
Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared-tokens)).
|
|
1040
|
+
|
|
1041
|
+
| Variable | Default |
|
|
1042
|
+
| --- | --- |
|
|
1043
|
+
| `--a11y-notification-banner-actions-gap` | `0.75rem` |
|
|
1044
|
+
| `--a11y-notification-banner-animation-duration` | `0.3s` |
|
|
1045
|
+
| `--a11y-notification-banner-close-font-size` | `1.25rem` |
|
|
1046
|
+
| `--a11y-notification-banner-gap` | `1rem` |
|
|
1047
|
+
| `--a11y-notification-banner-padding` | `0.75rem 1.5rem` |
|
|
1048
|
+
|
|
1049
|
+
</details>
|
|
1050
|
+
|
|
1051
|
+
#### `a11y-popover`
|
|
1052
|
+
|
|
1053
|
+
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](#common-to-all-overlays).
|
|
1054
|
+
|
|
1055
|
+
```html
|
|
1056
|
+
<button id="info-btn">Info</button>
|
|
1057
|
+
<a11y-popover id="info" anchor="info-btn" placement="right" interactive>
|
|
1058
|
+
<p>More details, with a <a href="/help">link</a>.</p>
|
|
1059
|
+
</a11y-popover>
|
|
1060
|
+
```
|
|
1061
|
+
|
|
1062
|
+
```js
|
|
1063
|
+
document.getElementById('info-btn').addEventListener('click', () => {
|
|
1064
|
+
document.getElementById('info').toggleAttribute('open');
|
|
1065
|
+
});
|
|
1066
|
+
```
|
|
1067
|
+
|
|
1068
|
+
| Name | Kind | Default | Description |
|
|
1069
|
+
| --- | --- | --- | --- |
|
|
1070
|
+
| `interactive` | attribute | absent | `role="dialog"` and a focus trap. |
|
|
1071
|
+
| `trap-focus` | attribute | follows `interactive` | Force the focus trap on (`trap-focus`) or off (`trap-focus="false"`). |
|
|
1072
|
+
| `onClose` | callback | — | Called once it has closed. |
|
|
1073
|
+
|
|
1074
|
+
<details>
|
|
1075
|
+
<summary>CSS variables</summary>
|
|
1076
|
+
|
|
1077
|
+
| Variable | Default |
|
|
1078
|
+
| --- | --- |
|
|
1079
|
+
| `--a11y-popover-border-radius` | `0.5rem` |
|
|
1080
|
+
| `--a11y-popover-color-background` | `#ffffff` |
|
|
1081
|
+
| `--a11y-popover-color-text` | `#111827` |
|
|
1082
|
+
| `--a11y-popover-content-padding` | `1rem` |
|
|
1083
|
+
| `--a11y-popover-max-width` | `320px` |
|
|
1084
|
+
| `--a11y-popover-shadow-blur` | `10px` |
|
|
1085
|
+
| `--a11y-popover-shadow-fade` | `85%` |
|
|
1086
|
+
| `--a11y-popover-shadow-offset-y` | `2px` |
|
|
1087
|
+
|
|
1088
|
+
</details>
|
|
1089
|
+
|
|
1090
|
+
#### `a11y-snackbar`
|
|
1091
|
+
|
|
1092
|
+
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.
|
|
1093
|
+
|
|
1094
|
+
```html
|
|
1095
|
+
<a11y-snackbar max-stack="5"></a11y-snackbar>
|
|
1096
|
+
```
|
|
1097
|
+
|
|
1098
|
+
```js
|
|
1099
|
+
import { notify } from 'a11y-elements/overlays/snackbar';
|
|
1100
|
+
|
|
1101
|
+
notify('Saved');
|
|
1102
|
+
notify('Upload failed', { type: 'error', actionText: 'Retry', onAction: retryUpload });
|
|
1103
|
+
notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
| Name | Kind | Default | Description |
|
|
1107
|
+
| --- | --- | --- | --- |
|
|
1108
|
+
| `max-stack` | attribute | `3` | How many toasts show at once; the rest wait in a queue and show as earlier ones are dismissed. |
|
|
1109
|
+
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1110
|
+
| `notify(message, options)` | method | — | Shows a toast (or queues it). |
|
|
1111
|
+
|
|
1112
|
+
`notify()` options (method and convenience export):
|
|
1113
|
+
|
|
1114
|
+
| Option | Default | Description |
|
|
1115
|
+
| --- | --- | --- |
|
|
1116
|
+
| `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
|
|
1117
|
+
| `position` | `bottom` | `bottom` or `top`. |
|
|
1118
|
+
| `duration` | `3000` (`10000` with an action) | Time on screen, in ms, not counting hover/focus. |
|
|
1119
|
+
| `actionText` / `onAction` | — | Adds an action button; clicking it dismisses the toast and runs `onAction`. |
|
|
1120
|
+
| `maxStack` | — | Sets `max-stack` on the region (sticky for later toasts). |
|
|
1121
|
+
|
|
1122
|
+
Classes: `.a11y-snackbar--info` / `--success` / `--warning` / `--error`.
|
|
1123
|
+
|
|
1124
|
+
<details>
|
|
1125
|
+
<summary>CSS variables</summary>
|
|
1126
|
+
|
|
1127
|
+
Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared-tokens)).
|
|
1128
|
+
|
|
1129
|
+
| Variable | Default |
|
|
1130
|
+
| --- | --- |
|
|
1131
|
+
| `--a11y-snackbar-animation-duration` | `0.3s` |
|
|
1132
|
+
| `--a11y-snackbar-border-radius` | `0.5rem` |
|
|
1133
|
+
| `--a11y-snackbar-container-width` | `350px` |
|
|
1134
|
+
| `--a11y-snackbar-gap` | `1rem` |
|
|
1135
|
+
| `--a11y-snackbar-offset` | `1rem` |
|
|
1136
|
+
| `--a11y-snackbar-padding` | `0.75rem 1.5rem` |
|
|
1137
|
+
| `--a11y-snackbar-shadow-blur` | `6px` |
|
|
1138
|
+
| `--a11y-snackbar-shadow-color` | `rgba(0, 0, 0, 0.3)` |
|
|
1139
|
+
| `--a11y-snackbar-shadow-offset-y` | `2px` |
|
|
1140
|
+
| `--a11y-snackbar-stack-gap` | `0.5rem` |
|
|
1141
|
+
|
|
1142
|
+
</details>
|
|
1143
|
+
|
|
1144
|
+
#### `a11y-tooltip`
|
|
1145
|
+
|
|
1146
|
+
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](#common-to-all-overlays).
|
|
1147
|
+
|
|
1148
|
+
```html
|
|
1149
|
+
<button id="save-btn">Save</button>
|
|
1150
|
+
<a11y-tooltip anchor="save-btn" placement="top" show-delay="500">Saves your changes</a11y-tooltip>
|
|
1151
|
+
```
|
|
1152
|
+
|
|
1153
|
+
| Name | Kind | Default | Description |
|
|
1154
|
+
| --- | --- | --- | --- |
|
|
1155
|
+
| `show-delay` | attribute / property (read-only) | `300` | Delay before showing, in ms. |
|
|
1156
|
+
| `hide-delay` | attribute / property (read-only) | `100` | Delay before hiding once pointer/focus leaves, in ms. |
|
|
1157
|
+
| `dispose()` | method | — | Detaches from the anchor for good (`close()` only hides it). |
|
|
1158
|
+
|
|
1159
|
+
<details>
|
|
1160
|
+
<summary>CSS variables</summary>
|
|
1161
|
+
|
|
1162
|
+
| Variable | Default |
|
|
1163
|
+
| --- | --- |
|
|
1164
|
+
| `--a11y-tooltip-border-radius` | `0.35rem` |
|
|
1165
|
+
| `--a11y-tooltip-color-background` | `#ffffff` |
|
|
1166
|
+
| `--a11y-tooltip-color-text` | `#111827` |
|
|
1167
|
+
| `--a11y-tooltip-content-padding` | `0.35rem 0.6rem` |
|
|
1168
|
+
| `--a11y-tooltip-font-size` | `0.85rem` |
|
|
1169
|
+
| `--a11y-tooltip-max-width` | `240px` |
|
|
1170
|
+
|
|
1171
|
+
</details>
|
|
1172
|
+
|
|
1173
|
+
### Shared tokens
|
|
1174
|
+
|
|
1175
|
+
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.
|
|
1176
|
+
|
|
1177
|
+
<details>
|
|
1178
|
+
<summary>CSS variables</summary>
|
|
1179
|
+
|
|
1180
|
+
| Variable | Default |
|
|
1181
|
+
| --- | --- |
|
|
1182
|
+
| `--a11y-color-success` | `rgb(76 175 80)` |
|
|
1183
|
+
| `--a11y-color-error` | `rgb(244 67 54)` |
|
|
1184
|
+
| `--a11y-color-info` | `rgb(33 150 243)` |
|
|
1185
|
+
| `--a11y-color-warning` | `rgb(244 67 54)` |
|
|
1186
|
+
| `--a11y-color-text` | `white` |
|
|
1187
|
+
| `--a11y-z-base` | `0` |
|
|
1188
|
+
| `--a11y-z-sticky-header` | `100` |
|
|
1189
|
+
| `--a11y-z-sticky-footer` | `110` |
|
|
1190
|
+
| `--a11y-z-floating-button` | `120` |
|
|
1191
|
+
| `--a11y-z-sidebar` | `200` |
|
|
1192
|
+
| `--a11y-z-mobile-nav` | `210` |
|
|
1193
|
+
| `--a11y-z-dropdown` | `300` |
|
|
1194
|
+
| `--a11y-z-popover` | `310` |
|
|
1195
|
+
| `--a11y-z-tooltip` | `320` |
|
|
1196
|
+
| `--a11y-z-context-menu` | `330` |
|
|
1197
|
+
| `--a11y-z-snackbar` | `400` |
|
|
1198
|
+
| `--a11y-z-toast` | `410` |
|
|
1199
|
+
| `--a11y-z-notification-banner` | `420` |
|
|
1200
|
+
| `--a11y-z-modal-backdrop` | `500` |
|
|
1201
|
+
| `--a11y-z-modal` | `510` |
|
|
1202
|
+
| `--a11y-z-drawer-backdrop` | `520` |
|
|
1203
|
+
| `--a11y-z-drawer` | `530` |
|
|
1204
|
+
| `--a11y-z-fullscreen-overlay` | `540` |
|
|
1205
|
+
| `--a11y-z-blocking-loader` | `600` |
|
|
1206
|
+
| `--a11y-z-emergency-dialog` | `610` |
|
|
1207
|
+
| `--a11y-z-debug-panel` | `700` |
|
|
1208
|
+
| `--a11y-z-inspector` | `710` |
|
|
1209
|
+
|
|
1210
|
+
</details>
|
|
84
1211
|
|
|
85
1212
|
## Customizing styles
|
|
86
1213
|
|
|
@@ -134,6 +1261,8 @@ The same custom properties follow ordinary CSS cascade/inheritance, so you can t
|
|
|
134
1261
|
|
|
135
1262
|
Either way, only that element changes — every other `<a11y-spinner>` on the page keeps its default (or globally-rethemed) look.
|
|
136
1263
|
|
|
1264
|
+
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.
|
|
1265
|
+
|
|
137
1266
|
The full list of tokens, with their defaults, is in the shipped `dist/a11y.css` — search it for `--a11y-<component>-`.
|
|
138
1267
|
|
|
139
1268
|
## License
|