a11y-elements 0.2.0 → 0.4.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 +395 -22
- package/dist/a11y.css +364 -0
- package/dist/all.d.ts +38 -0
- package/dist/all.js +38 -0
- package/dist/all.js.map +1 -0
- package/dist/browser/all.js +149 -0
- package/dist/browser/all.js.map +1 -0
- package/dist/browser/chunk-2YF57VSU.js +122 -0
- package/dist/browser/chunk-2YF57VSU.js.map +1 -0
- package/dist/browser/chunk-3RRJOPEF.js +24 -0
- package/dist/browser/chunk-3RRJOPEF.js.map +1 -0
- package/dist/browser/chunk-3UC2S6JJ.js +42 -0
- package/dist/browser/chunk-3UC2S6JJ.js.map +1 -0
- package/dist/browser/chunk-46SIA3RI.js +410 -0
- package/dist/browser/chunk-46SIA3RI.js.map +1 -0
- package/dist/browser/chunk-4FHDXZ3L.js +547 -0
- package/dist/browser/chunk-4FHDXZ3L.js.map +1 -0
- package/dist/browser/chunk-4IURHUQU.js +78 -0
- package/dist/browser/chunk-4IURHUQU.js.map +1 -0
- package/dist/browser/chunk-4KU26VOY.js +16 -0
- package/dist/browser/chunk-4KU26VOY.js.map +1 -0
- package/dist/browser/chunk-6BOK3R6K.js +400 -0
- package/dist/browser/chunk-6BOK3R6K.js.map +1 -0
- package/dist/browser/chunk-6Q6VW435.js +125 -0
- package/dist/browser/chunk-6Q6VW435.js.map +1 -0
- package/dist/browser/chunk-A32U5MX7.js +76 -0
- package/dist/browser/chunk-A32U5MX7.js.map +1 -0
- package/dist/browser/chunk-A5CV54CT.js +38 -0
- package/dist/browser/chunk-A5CV54CT.js.map +1 -0
- package/dist/browser/chunk-ABTLBDUK.js +56 -0
- package/dist/browser/chunk-ABTLBDUK.js.map +1 -0
- package/dist/browser/chunk-ACOSO5NE.js +64 -0
- package/dist/browser/chunk-ACOSO5NE.js.map +1 -0
- package/dist/browser/chunk-CXUZEGZY.js +52 -0
- package/dist/browser/chunk-CXUZEGZY.js.map +1 -0
- package/dist/browser/chunk-EAASMTBS.js +123 -0
- package/dist/browser/chunk-EAASMTBS.js.map +1 -0
- package/dist/browser/chunk-F47DDMFE.js +39 -0
- package/dist/browser/chunk-F47DDMFE.js.map +1 -0
- package/dist/browser/chunk-FAEA66RR.js +29 -0
- package/dist/browser/chunk-FAEA66RR.js.map +1 -0
- package/dist/browser/chunk-FXHJKL3U.js +81 -0
- package/dist/browser/chunk-FXHJKL3U.js.map +1 -0
- package/dist/browser/chunk-GDJTILU4.js +100 -0
- package/dist/browser/chunk-GDJTILU4.js.map +1 -0
- package/dist/browser/chunk-GH53G7MU.js +35 -0
- package/dist/browser/chunk-GH53G7MU.js.map +1 -0
- package/dist/browser/chunk-GKNBHWGY.js +67 -0
- package/dist/browser/chunk-GKNBHWGY.js.map +1 -0
- package/dist/browser/chunk-GUKQIHPM.js +72 -0
- package/dist/browser/chunk-GUKQIHPM.js.map +1 -0
- package/dist/browser/chunk-HGPHWR3R.js +106 -0
- package/dist/browser/chunk-HGPHWR3R.js.map +1 -0
- package/dist/browser/chunk-HLID3PP5.js +19 -0
- package/dist/browser/chunk-HLID3PP5.js.map +1 -0
- package/dist/browser/chunk-HPTH4SJ2.js +68 -0
- package/dist/browser/chunk-HPTH4SJ2.js.map +1 -0
- package/dist/browser/chunk-I4KOJO4B.js +66 -0
- package/dist/browser/chunk-I4KOJO4B.js.map +1 -0
- package/dist/browser/chunk-ISWQOJT7.js +19 -0
- package/dist/browser/chunk-ISWQOJT7.js.map +1 -0
- package/dist/browser/chunk-KUTHJLZ5.js +72 -0
- package/dist/browser/chunk-KUTHJLZ5.js.map +1 -0
- package/dist/browser/chunk-LQ34M47I.js +41 -0
- package/dist/browser/chunk-LQ34M47I.js.map +1 -0
- package/dist/browser/chunk-NI7PACR4.js +449 -0
- package/dist/browser/chunk-NI7PACR4.js.map +1 -0
- package/dist/browser/chunk-NTNPE4TH.js +162 -0
- package/dist/browser/chunk-NTNPE4TH.js.map +1 -0
- package/dist/browser/chunk-O4AJULBZ.js +249 -0
- package/dist/browser/chunk-O4AJULBZ.js.map +1 -0
- package/dist/browser/chunk-P42KF3NM.js +138 -0
- package/dist/browser/chunk-P42KF3NM.js.map +1 -0
- package/dist/browser/chunk-QT7Z23GS.js +189 -0
- package/dist/browser/chunk-QT7Z23GS.js.map +1 -0
- package/dist/browser/chunk-R4OVZULJ.js +48 -0
- package/dist/browser/chunk-R4OVZULJ.js.map +1 -0
- package/dist/browser/chunk-S7GPESLQ.js +51 -0
- package/dist/browser/chunk-S7GPESLQ.js.map +1 -0
- package/dist/browser/chunk-SIQUYA37.js +76 -0
- package/dist/browser/chunk-SIQUYA37.js.map +1 -0
- package/dist/browser/chunk-SYKTM7WJ.js +82 -0
- package/dist/browser/chunk-SYKTM7WJ.js.map +1 -0
- package/dist/browser/chunk-TTP33GXU.js +177 -0
- package/dist/browser/chunk-TTP33GXU.js.map +1 -0
- package/dist/browser/chunk-UCAUEEED.js +125 -0
- package/dist/browser/chunk-UCAUEEED.js.map +1 -0
- package/dist/browser/chunk-VY6BZLCJ.js +170 -0
- package/dist/browser/chunk-VY6BZLCJ.js.map +1 -0
- package/dist/browser/chunk-ZMCETLOQ.js +39 -0
- package/dist/browser/chunk-ZMCETLOQ.js.map +1 -0
- package/dist/browser/components/anchor/define.js +9 -310
- package/dist/browser/components/anchor/define.js.map +1 -1
- package/dist/browser/components/avatar/define.js +7 -246
- package/dist/browser/components/avatar/define.js.map +1 -1
- package/dist/browser/components/card-link/define.js +16 -0
- package/dist/browser/components/card-link/define.js.map +1 -0
- package/dist/browser/components/checkbox/define.js +9 -265
- package/dist/browser/components/checkbox/define.js.map +1 -1
- package/dist/browser/components/checkbox-group/define.js +15 -0
- package/dist/browser/components/checkbox-group/define.js.map +1 -0
- package/dist/browser/components/file-input/define.js +20 -0
- package/dist/browser/components/file-input/define.js.map +1 -0
- package/dist/browser/components/focusable/define.js +7 -193
- package/dist/browser/components/focusable/define.js.map +1 -1
- package/dist/browser/components/input/define.js +13 -662
- package/dist/browser/components/input/define.js.map +1 -1
- package/dist/browser/components/label/define.js +9 -256
- package/dist/browser/components/label/define.js.map +1 -1
- package/dist/browser/components/picture/define.js +9 -237
- package/dist/browser/components/picture/define.js.map +1 -1
- package/dist/browser/components/progress/define.js +7 -221
- package/dist/browser/components/progress/define.js.map +1 -1
- package/dist/browser/components/radio-group/define.js +9 -284
- package/dist/browser/components/radio-group/define.js.map +1 -1
- package/dist/browser/components/select/define.js +9 -264
- package/dist/browser/components/select/define.js.map +1 -1
- package/dist/browser/components/skeleton/define.js +7 -216
- package/dist/browser/components/skeleton/define.js.map +1 -1
- package/dist/browser/components/spinner/define.js +7 -242
- package/dist/browser/components/spinner/define.js.map +1 -1
- package/dist/browser/components/switch/define.js +9 -272
- package/dist/browser/components/switch/define.js.map +1 -1
- package/dist/browser/components/textarea/define.js +13 -662
- package/dist/browser/components/textarea/define.js.map +1 -1
- package/dist/browser/components/visually-hidden/define.js +7 -177
- package/dist/browser/components/visually-hidden/define.js.map +1 -1
- package/dist/browser/overlays/blocking-loader/define.js +14 -500
- package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
- package/dist/browser/overlays/context-menu/define.js +16 -928
- package/dist/browser/overlays/context-menu/define.js.map +1 -1
- package/dist/browser/overlays/drawer/define.js +15 -698
- package/dist/browser/overlays/drawer/define.js.map +1 -1
- package/dist/browser/overlays/dropdown/define.js +16 -924
- package/dist/browser/overlays/dropdown/define.js.map +1 -1
- package/dist/browser/overlays/emergency-dialog/define.js +15 -694
- package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/browser/overlays/floating/define.js +21 -0
- package/dist/browser/overlays/floating/define.js.map +1 -0
- package/dist/browser/overlays/modal/define.js +15 -691
- package/dist/browser/overlays/modal/define.js.map +1 -1
- package/dist/browser/overlays/notification-banner/define.js +14 -437
- package/dist/browser/overlays/notification-banner/define.js.map +1 -1
- package/dist/browser/overlays/popover/define.js +15 -778
- package/dist/browser/overlays/popover/define.js.map +1 -1
- package/dist/browser/overlays/snackbar/define.js +14 -393
- package/dist/browser/overlays/snackbar/define.js.map +1 -1
- package/dist/browser/overlays/tooltip/define.js +16 -874
- package/dist/browser/overlays/tooltip/define.js.map +1 -1
- package/dist/components/anchor/define.d.ts +1 -1
- package/dist/components/anchor/define.js +3 -5
- package/dist/components/anchor/define.js.map +1 -1
- package/dist/components/avatar/define.d.ts +1 -1
- package/dist/components/avatar/define.js +3 -5
- package/dist/components/avatar/define.js.map +1 -1
- package/dist/components/card-link/card-link.element.d.ts +47 -0
- package/dist/components/card-link/card-link.element.js +129 -0
- package/dist/components/card-link/card-link.element.js.map +1 -0
- package/dist/components/card-link/define.d.ts +8 -0
- package/dist/components/card-link/define.js +6 -0
- package/dist/components/card-link/define.js.map +1 -0
- package/dist/components/checkbox/define.d.ts +1 -1
- package/dist/components/checkbox/define.js +3 -5
- package/dist/components/checkbox/define.js.map +1 -1
- 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 +6 -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 +7 -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/components/focusable/define.d.ts +1 -1
- package/dist/components/focusable/define.js +3 -5
- package/dist/components/focusable/define.js.map +1 -1
- package/dist/components/focusable/focusable.element.d.ts +1 -1
- package/dist/components/focusable/focusable.element.js +3 -3
- package/dist/components/focusable/focusable.element.js.map +1 -1
- package/dist/components/input/define.d.ts +1 -1
- package/dist/components/input/define.js +3 -5
- package/dist/components/input/define.js.map +1 -1
- package/dist/components/label/define.d.ts +1 -1
- package/dist/components/label/define.js +3 -5
- package/dist/components/label/define.js.map +1 -1
- package/dist/components/label/label.element.d.ts +1 -1
- package/dist/components/label/label.element.js +1 -1
- package/dist/components/picture/define.d.ts +2 -1
- package/dist/components/picture/define.js +3 -5
- package/dist/components/picture/define.js.map +1 -1
- package/dist/components/picture/picture.element.d.ts +72 -6
- package/dist/components/picture/picture.element.js +201 -9
- package/dist/components/picture/picture.element.js.map +1 -1
- package/dist/components/progress/define.d.ts +1 -1
- package/dist/components/progress/define.js +3 -5
- package/dist/components/progress/define.js.map +1 -1
- package/dist/components/radio-group/define.d.ts +1 -1
- package/dist/components/radio-group/define.js +3 -5
- package/dist/components/radio-group/define.js.map +1 -1
- package/dist/components/radio-group/radio-group.element.js +4 -0
- package/dist/components/radio-group/radio-group.element.js.map +1 -1
- package/dist/components/select/define.d.ts +1 -1
- package/dist/components/select/define.js +3 -5
- package/dist/components/select/define.js.map +1 -1
- package/dist/components/skeleton/define.d.ts +1 -1
- package/dist/components/skeleton/define.js +3 -5
- package/dist/components/skeleton/define.js.map +1 -1
- package/dist/components/skeleton/skeleton.element.js +2 -2
- package/dist/components/skeleton/skeleton.element.js.map +1 -1
- package/dist/components/spinner/define.d.ts +1 -1
- package/dist/components/spinner/define.js +3 -5
- package/dist/components/spinner/define.js.map +1 -1
- package/dist/components/switch/define.d.ts +1 -1
- package/dist/components/switch/define.js +3 -5
- package/dist/components/switch/define.js.map +1 -1
- package/dist/components/textarea/define.d.ts +1 -1
- package/dist/components/textarea/define.js +3 -5
- package/dist/components/textarea/define.js.map +1 -1
- package/dist/components/visually-hidden/define.d.ts +1 -1
- package/dist/components/visually-hidden/define.js +3 -5
- package/dist/components/visually-hidden/define.js.map +1 -1
- package/dist/components/visually-hidden/visually-hidden.element.d.ts +1 -1
- package/dist/components/visually-hidden/visually-hidden.element.js +3 -4
- package/dist/components/visually-hidden/visually-hidden.element.js.map +1 -1
- package/dist/core/a11y-element.d.ts +14 -6
- package/dist/core/a11y-element.js +7 -3
- package/dist/core/a11y-element.js.map +1 -1
- package/dist/core/a11y-field-element.d.ts +17 -7
- package/dist/core/a11y-field-element.js +25 -5
- package/dist/core/a11y-field-element.js.map +1 -1
- package/dist/core/define-element.d.ts +6 -0
- package/dist/core/define-element.js +10 -0
- package/dist/core/define-element.js.map +1 -0
- package/dist/core/focus-trap.d.ts +8 -0
- package/dist/core/focus-trap.js +13 -1
- package/dist/core/focus-trap.js.map +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/sanitize.d.ts +21 -0
- package/dist/core/sanitize.js +107 -0
- package/dist/core/sanitize.js.map +1 -0
- package/dist/core/strings.d.ts +25 -1
- package/dist/core/strings.js +15 -3
- package/dist/core/strings.js.map +1 -1
- package/dist/core/template.d.ts +37 -7
- package/dist/core/template.js +211 -17
- package/dist/core/template.js.map +1 -1
- package/dist/core/zero-build-exports.d.ts +1 -0
- package/dist/core/zero-build-exports.js +3 -0
- package/dist/core/zero-build-exports.js.map +1 -0
- package/dist/overlays/blocking-loader/blocking-loader.element.js +2 -2
- package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -1
- package/dist/overlays/blocking-loader/define.d.ts +1 -2
- package/dist/overlays/blocking-loader/define.js +3 -6
- package/dist/overlays/blocking-loader/define.js.map +1 -1
- package/dist/overlays/context-menu/define.d.ts +1 -2
- package/dist/overlays/context-menu/define.js +3 -6
- package/dist/overlays/context-menu/define.js.map +1 -1
- package/dist/overlays/core/a11y-menu-overlay-element.js +2 -2
- package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-modal-overlay-element.js +1 -1
- package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +3 -1
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/core/zero-build-exports.d.ts +2 -0
- package/dist/overlays/core/zero-build-exports.js +4 -0
- package/dist/overlays/core/zero-build-exports.js.map +1 -0
- package/dist/overlays/drawer/define.d.ts +1 -2
- package/dist/overlays/drawer/define.js +3 -6
- package/dist/overlays/drawer/define.js.map +1 -1
- package/dist/overlays/dropdown/define.d.ts +1 -2
- package/dist/overlays/dropdown/define.js +3 -6
- package/dist/overlays/dropdown/define.js.map +1 -1
- package/dist/overlays/emergency-dialog/define.d.ts +1 -2
- package/dist/overlays/emergency-dialog/define.js +3 -6
- package/dist/overlays/emergency-dialog/define.js.map +1 -1
- package/dist/overlays/floating/define.d.ts +8 -0
- package/dist/overlays/floating/define.js +6 -0
- package/dist/overlays/floating/define.js.map +1 -0
- package/dist/overlays/floating/floating.element.d.ts +125 -0
- package/dist/overlays/floating/floating.element.js +621 -0
- package/dist/overlays/floating/floating.element.js.map +1 -0
- package/dist/overlays/modal/define.d.ts +1 -2
- package/dist/overlays/modal/define.js +3 -6
- package/dist/overlays/modal/define.js.map +1 -1
- package/dist/overlays/notification-banner/define.d.ts +3 -3
- package/dist/overlays/notification-banner/define.js +3 -6
- package/dist/overlays/notification-banner/define.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +2 -1
- package/dist/overlays/notification-banner/notification-banner.element.js +2 -2
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/popover/define.d.ts +1 -2
- package/dist/overlays/popover/define.js +3 -6
- package/dist/overlays/popover/define.js.map +1 -1
- package/dist/overlays/snackbar/define.d.ts +3 -3
- package/dist/overlays/snackbar/define.js +3 -6
- package/dist/overlays/snackbar/define.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +2 -1
- package/dist/overlays/snackbar/snackbar.element.js +2 -2
- package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
- package/dist/overlays/tooltip/define.d.ts +1 -2
- package/dist/overlays/tooltip/define.js +3 -6
- package/dist/overlays/tooltip/define.js.map +1 -1
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -4,11 +4,13 @@ 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
|
|
10
12
|
|
|
11
|
-
Load a component's
|
|
13
|
+
Load a component's browser bundle directly, no bundler required:
|
|
12
14
|
|
|
13
15
|
```html
|
|
14
16
|
<link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
|
|
@@ -17,8 +19,9 @@ Load a component's standalone browser bundle directly, no bundler required:
|
|
|
17
19
|
<a11y-spinner></a11y-spinner>
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
* Each component has its own `define.js` under `dist/browser/**`.
|
|
21
|
-
*
|
|
22
|
+
* Each component has its own `define.js` under `dist/browser/**`. Load only the ones you use.
|
|
23
|
+
* They share their common code through `chunk-*.js` files in `dist/browser/`, so the browser fetches it once however many you load. Serve them from the package's `dist/browser/` folder as is: a `define.js` copied on its own won't load.
|
|
24
|
+
* `dist/browser/all.js` registers every element at once and exports everything the individual bundles do.
|
|
22
25
|
* Page-wide state is shared between bundles, so mixing several on one page is safe.
|
|
23
26
|
* Overlay bundles also export `dismissAllOverlays()`:
|
|
24
27
|
|
|
@@ -42,6 +45,7 @@ import { A11yElement } from 'a11y-elements/core';
|
|
|
42
45
|
|
|
43
46
|
* There's no default export: `import 'a11y-elements'` alone will fail.
|
|
44
47
|
* Import the component you want: `/element` gets you the class itself when you need it
|
|
48
|
+
* `import 'a11y-elements/all'` registers every element at once, and exports every element class plus `setStrings()`, `dismissAllOverlays()`, `notify()` and the other helpers the individual entries export.
|
|
45
49
|
* See [Elements](#elements) for every component.
|
|
46
50
|
|
|
47
51
|
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.
|
|
@@ -65,14 +69,24 @@ setStrings({
|
|
|
65
69
|
| --- | --- | --- | --- |
|
|
66
70
|
| `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
|
|
67
71
|
| `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` |
|
|
72
|
+
| `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`, an expandable `<a11y-floating>`'s panel | `close-label` |
|
|
73
|
+
| `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
|
|
70
74
|
| `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
|
|
71
75
|
| `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
|
|
72
76
|
| `avatar` | `Avatar` | `<a11y-avatar>` with no `alt` or `initials` | `alt` / `initials` |
|
|
73
77
|
| `characterCount` | `{count} / {max}` | the visible text of an `<a11y-counter>` | — |
|
|
74
78
|
| `charactersRemaining` | `{count} characters remaining` | what an `<a11y-counter>` announces near the limit | — |
|
|
75
79
|
| `characterRemaining` | `{count} character remaining` | the same, with one character left | — |
|
|
80
|
+
| `selectAll` | `Select all` | the generated checkbox of `<a11y-checkbox-group select-all>` | `select-all-label` |
|
|
81
|
+
| `browseFiles` | `Browse files` | the browse button of `<a11y-file-input>` | `browse-label` |
|
|
82
|
+
| `dropFiles` | `or drop files here` | the drag & drop prompt of `<a11y-file-input>` | `drop-label` |
|
|
83
|
+
| `selectedFiles` | `Selected files` | the name of `<a11y-file-input>`'s file list | — |
|
|
84
|
+
| `remove` / `removeFile` | `Remove` / `Remove {name}` | the visible text / accessible name of each remove button of `<a11y-file-input>` | — |
|
|
85
|
+
| `fileAdded` / `filesAdded` | `{name} added` / `{count} files added` | what `<a11y-file-input>` announces after a pick or a drop | — |
|
|
86
|
+
| `fileRemoved` | `{name} removed` | what `<a11y-file-input>` announces after a removal | — |
|
|
87
|
+
| `fileTypeRejected` | `{name} wasn’t added: this type of file isn’t allowed` | a file `accept` rules out | `type-rejected-message` |
|
|
88
|
+
| `fileSizeRejected` | `{name} wasn’t added: it’s larger than {maxSize}` | a file over `max-size` | `size-rejected-message` |
|
|
89
|
+
| `fileCountRejected` | `{name} wasn’t added: too many files (maximum {max})` | a file past `max-files` | `count-rejected-message` |
|
|
76
90
|
|
|
77
91
|
* An instance attribute wins over `setStrings()`, which wins over the default. Keys you leave out keep their current value.
|
|
78
92
|
* Elements already on the page update right away, so calling it again on a language switch is enough.
|
|
@@ -80,11 +94,13 @@ setStrings({
|
|
|
80
94
|
|
|
81
95
|
## Elements
|
|
82
96
|
|
|
83
|
-
Each section shows an example, the element's own attributes/properties/methods, and its CSS variables (collapsed).
|
|
97
|
+
Each section shows an example, the element's own attributes/properties/methods, and its CSS variables (collapsed).
|
|
98
|
+
|
|
99
|
+
Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
|
|
84
100
|
|
|
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)
|
|
101
|
+
**Accessibility components:** [`<a11y-anchor>`](#a11y-anchor) · [`<a11y-avatar>`](#a11y-avatar) · [`<a11y-card-link>`](#a11y-card-link) · [`<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)
|
|
86
102
|
|
|
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)
|
|
103
|
+
**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-floating>`](#a11y-floating) · [`<a11y-modal>`](#a11y-modal) · [`<a11y-notification-banner>`](#a11y-notification-banner) · [`<a11y-popover>`](#a11y-popover) · [`<a11y-snackbar>`](#a11y-snackbar) · [`<a11y-tooltip>`](#a11y-tooltip)
|
|
88
104
|
|
|
89
105
|
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
106
|
|
|
@@ -147,6 +163,44 @@ An avatar image with an initials fallback. When the image is missing or fails to
|
|
|
147
163
|
|
|
148
164
|
</details>
|
|
149
165
|
|
|
166
|
+
#### `a11y-card-link`
|
|
167
|
+
|
|
168
|
+
Makes a whole card go to one page through a real `<a href>` inside it (usually around the title). The link stays the card's only tab stop and its accessible name, so screen readers announce a link named by the title, Enter follows it, Space scrolls the page, and middle-click, "Open in new tab" and "Copy link address" work on it.
|
|
169
|
+
|
|
170
|
+
A click anywhere else on the card is forwarded to the link with a real `click()`, so your own click handlers on the link (an SPA router's) run for it too. Clicks aren't forwarded when they land on another control in the card (a button, a second link, an input…), when the user was selecting text, or when something already called `preventDefault()`. Cmd/Ctrl/Shift-click and middle-click on the card open the link in a new tab.
|
|
171
|
+
|
|
172
|
+
The card gets no `role` or `tabindex`. Use it for cards that navigate; for cards that perform an action, use a `<button>` or [`<a11y-focusable>`](#a11y-focusable).
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<a11y-card-link describe>
|
|
176
|
+
<div class="card">
|
|
177
|
+
<svg aria-hidden="true">…</svg>
|
|
178
|
+
<h3><a href="/articles/why-nutin">Why Nutin?</a></h3>
|
|
179
|
+
<p data-card-description>The idea behind the framework…</p>
|
|
180
|
+
</div>
|
|
181
|
+
</a11y-card-link>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
| Name | Kind | Default | Description |
|
|
185
|
+
| --- | --- | --- | --- |
|
|
186
|
+
| `describe` | attribute (boolean) | — | Adds the `data-card-description` element to the link's `aria-describedby` (giving it an id if it has none), so it's read after the title. |
|
|
187
|
+
| `data-card-link` | attribute, on an `<a href>` inside | — | The link to use when the card has several. Otherwise the first `<a href>` is used. Without one, a console warning is logged. |
|
|
188
|
+
| `data-card-description` | attribute, on an element inside | — | The description `describe` points to. |
|
|
189
|
+
| `link` | property (read-only) | — | The link the card navigates through. |
|
|
190
|
+
|
|
191
|
+
The whole card is outlined while its link has keyboard focus (`:has(:focus-visible)`). In browsers without `:has()`, the link keeps its own focus ring.
|
|
192
|
+
|
|
193
|
+
<details>
|
|
194
|
+
<summary>CSS variables</summary>
|
|
195
|
+
|
|
196
|
+
| Variable | Default |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| `--a11y-card-link-focus-outline-color` | `#2563eb` |
|
|
199
|
+
| `--a11y-card-link-focus-outline-offset` | `2px` |
|
|
200
|
+
| `--a11y-card-link-focus-outline-width` | `2px` |
|
|
201
|
+
|
|
202
|
+
</details>
|
|
203
|
+
|
|
150
204
|
#### `a11y-checkbox`
|
|
151
205
|
|
|
152
206
|
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.
|
|
@@ -197,10 +251,147 @@ checkbox.onChange = (checked) => console.log('accepted:', checked);
|
|
|
197
251
|
|
|
198
252
|
</details>
|
|
199
253
|
|
|
254
|
+
#### `a11y-checkbox-group`
|
|
255
|
+
|
|
256
|
+
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.
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<a11y-checkbox-group id="toppings" legend="Toppings" select-all>
|
|
260
|
+
<label><input type="checkbox" name="toppings" value="cheese"> Cheese</label>
|
|
261
|
+
<label><input type="checkbox" name="toppings" value="ham"> Ham</label>
|
|
262
|
+
</a11y-checkbox-group>
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
import 'a11y-elements/components/checkbox-group';
|
|
267
|
+
import type { CheckboxGroupElement } from 'a11y-elements/components/checkbox-group/element';
|
|
268
|
+
|
|
269
|
+
const group = document.getElementById('toppings') as CheckboxGroupElement;
|
|
270
|
+
group.onChange = (values) => console.log('toppings:', values);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
| Name | Kind | Default | Description |
|
|
274
|
+
| --- | --- | --- | --- |
|
|
275
|
+
| `legend` | attribute | — | Visible group label. |
|
|
276
|
+
| `aria-label` | attribute | — | Group name when there's no `legend`. |
|
|
277
|
+
| `disabled` | attribute | absent | Disables every option (through the fieldset). |
|
|
278
|
+
| `select-all` | attribute | absent | Adds the "Select all" checkbox after the legend. |
|
|
279
|
+
| `select-all-label` | attribute | `Select all` | Its text; also `setStrings({ selectAll })`. |
|
|
280
|
+
| `onChange` | callback | — | `(values: string[]) => void`, called once per user action, a "Select all" click included. |
|
|
281
|
+
| `getValue()` / `setValue(values)` | method | — | Reads the checked values / checks exactly those values. |
|
|
282
|
+
| `selectAll()` / `unselectAll()` | method | — | Checks / unchecks every enabled option. Like `setValue()`, fires no events. |
|
|
283
|
+
|
|
284
|
+
A "Select all" click fires `input` and `change` on every option it changes.
|
|
285
|
+
|
|
286
|
+
Options use the `--a11y-checkbox-*` variables above.
|
|
287
|
+
|
|
288
|
+
<details>
|
|
289
|
+
<summary>CSS variables</summary>
|
|
290
|
+
|
|
291
|
+
| Variable | Default |
|
|
292
|
+
| --- | --- |
|
|
293
|
+
| `--a11y-checkbox-group-color-text-muted` | `#6b7280` |
|
|
294
|
+
| `--a11y-checkbox-group-disabled-opacity` | `0.6` |
|
|
295
|
+
| `--a11y-checkbox-group-legend-font-size` | `0.875rem` |
|
|
296
|
+
| `--a11y-checkbox-group-legend-margin-bottom` | `0.5rem` |
|
|
297
|
+
| `--a11y-checkbox-group-options-gap` | `0.5rem` |
|
|
298
|
+
| `--a11y-checkbox-group-select-all-border` | `1px solid #e5e7eb` |
|
|
299
|
+
| `--a11y-checkbox-group-select-all-padding-bottom` | `0.5rem` |
|
|
300
|
+
|
|
301
|
+
</details>
|
|
302
|
+
|
|
303
|
+
#### `a11y-file-input`
|
|
304
|
+
|
|
305
|
+
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.
|
|
306
|
+
|
|
307
|
+
```html
|
|
308
|
+
<a11y-file-input max-size="5MB" max-files="3" previews value-missing-message="Add at least one file">
|
|
309
|
+
<a11y-label>Attachments</a11y-label>
|
|
310
|
+
<input type="file" name="attachments" multiple accept=".pdf,image/*" required>
|
|
311
|
+
<a11y-hint>PDF or images, up to 5 MB each.</a11y-hint>
|
|
312
|
+
<a11y-error></a11y-error>
|
|
313
|
+
</a11y-file-input>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
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.
|
|
317
|
+
|
|
318
|
+
**Accessibility.**
|
|
319
|
+
|
|
320
|
+
* 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".
|
|
321
|
+
* "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").
|
|
322
|
+
* Dragging is a shortcut, never the only way: everything works from the keyboard. The drop prompt is hidden from assistive tech.
|
|
323
|
+
* 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.
|
|
324
|
+
* 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.
|
|
325
|
+
* 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.
|
|
326
|
+
|
|
327
|
+
**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`.
|
|
328
|
+
|
|
329
|
+
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.
|
|
330
|
+
|
|
331
|
+
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>`.
|
|
332
|
+
|
|
333
|
+
| Name | Kind | Default | Description |
|
|
334
|
+
| --- | --- | --- | --- |
|
|
335
|
+
| `max-size` | attribute | — | Largest file accepted: `500KB`, `5MB`, `1GB` or bytes (1 KB = 1024 bytes). |
|
|
336
|
+
| `max-files` | attribute | — | Most files the selection can hold, with `multiple`. |
|
|
337
|
+
| `previews` | attribute | `false` | Shows a thumbnail next to image files. |
|
|
338
|
+
| `browse-label` / `drop-label` | attribute | see [strings](#translating-built-in-strings) | Text of the browse button / of the drop prompt. |
|
|
339
|
+
| `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. |
|
|
340
|
+
| `value-missing-message`, … | attribute | browser's | As on [`a11y-input`](#a11y-input). |
|
|
341
|
+
| `validators` | property | `[]` | As on `a11y-input`; the second argument is the input. |
|
|
342
|
+
| `onChange` / `onInput` | callback | — | `(files: File[]) => void`, called once per pick, drop or removal. |
|
|
343
|
+
| `getValue()` | method | — | The selected files. |
|
|
344
|
+
| `setValue(files)` | method | — | Replaces the selection, silently: no events, no announcement. The rules still apply. |
|
|
345
|
+
| `addFiles(files)` | method | — | Adds files as a drop would: checked, announced, then `input` and `change` fire. Handy for a paste handler. |
|
|
346
|
+
| `removeFile(fileOrIndex)` / `clear()` | method | — | Removes one file / all of them, silently. |
|
|
347
|
+
| `checkValidity()` / `reportValidity()` | method | — | As on `a11y-input`. |
|
|
348
|
+
|
|
349
|
+
Sizes are formatted with `Intl` in the language of the closest `lang` attribute (`1.5 MB`, `1,5 Mo`, …).
|
|
350
|
+
|
|
351
|
+
<details>
|
|
352
|
+
<summary>CSS variables</summary>
|
|
353
|
+
|
|
354
|
+
| Variable | Default |
|
|
355
|
+
| --- | --- |
|
|
356
|
+
| `--a11y-file-input-button-border-radius` | `4px` |
|
|
357
|
+
| `--a11y-file-input-button-font-weight` | `600` |
|
|
358
|
+
| `--a11y-file-input-button-padding-x` | `1rem` |
|
|
359
|
+
| `--a11y-file-input-button-padding-y` | `0.5rem` |
|
|
360
|
+
| `--a11y-file-input-color-background` | `#ffffff` |
|
|
361
|
+
| `--a11y-file-input-color-border` | `#d1d5db` |
|
|
362
|
+
| `--a11y-file-input-color-disabled-bg` | `#e5e7eb` |
|
|
363
|
+
| `--a11y-file-input-color-disabled-text` | `#9ca3af` |
|
|
364
|
+
| `--a11y-file-input-color-dragover-bg` | `#eff6ff` |
|
|
365
|
+
| `--a11y-file-input-color-error` | `#b91c1c` |
|
|
366
|
+
| `--a11y-file-input-color-primary` | `#2563eb` |
|
|
367
|
+
| `--a11y-file-input-color-text` | `#111827` |
|
|
368
|
+
| `--a11y-file-input-color-text-muted` | `#6b7280` |
|
|
369
|
+
| `--a11y-file-input-dropzone-border-radius` | `8px` |
|
|
370
|
+
| `--a11y-file-input-dropzone-border-width` | `2px` |
|
|
371
|
+
| `--a11y-file-input-dropzone-gap` | `0.5rem` |
|
|
372
|
+
| `--a11y-file-input-dropzone-padding` | `1.5rem 1rem` |
|
|
373
|
+
| `--a11y-file-input-focus-outline-offset` | `2px` |
|
|
374
|
+
| `--a11y-file-input-focus-outline-width` | `2px` |
|
|
375
|
+
| `--a11y-file-input-gap` | `0.25rem` |
|
|
376
|
+
| `--a11y-file-input-item-border-radius` | `4px` |
|
|
377
|
+
| `--a11y-file-input-item-gap` | `0.75rem` |
|
|
378
|
+
| `--a11y-file-input-item-padding` | `0.5rem 0.75rem` |
|
|
379
|
+
| `--a11y-file-input-list-gap` | `0.5rem` |
|
|
380
|
+
| `--a11y-file-input-list-margin-top` | `0.25rem` |
|
|
381
|
+
| `--a11y-file-input-preview-border-radius` | `4px` |
|
|
382
|
+
| `--a11y-file-input-preview-size` | `2.5rem` |
|
|
383
|
+
| `--a11y-file-input-transition-duration` | `0.2s` |
|
|
384
|
+
|
|
385
|
+
The hint and error use the [shared field variables](#a11y-input).
|
|
386
|
+
|
|
387
|
+
</details>
|
|
388
|
+
|
|
200
389
|
#### `a11y-focusable`
|
|
201
390
|
|
|
202
391
|
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
392
|
|
|
393
|
+
It's for **actions**. Cards that go to another page should use [`<a11y-card-link>`](#a11y-card-link) or a plain `<a href>`: a button role, Space activation and no `href` mislead screen-reader users and break "Open in new tab".
|
|
394
|
+
|
|
204
395
|
```html
|
|
205
396
|
<a11y-focusable aria-label="Expand menu">
|
|
206
397
|
<svg aria-hidden="true">…</svg> Menu
|
|
@@ -233,11 +424,42 @@ A text field built from a real `<input>` and optional parts, wired together for
|
|
|
233
424
|
</form>
|
|
234
425
|
```
|
|
235
426
|
|
|
236
|
-
The input stays yours and is never regenerated.
|
|
427
|
+
The input stays yours and is never regenerated.
|
|
428
|
+
|
|
429
|
+
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.
|
|
430
|
+
|
|
431
|
+
Ids you set are kept; missing ones are generated.
|
|
432
|
+
|
|
433
|
+
- **When errors show.**
|
|
434
|
+
|
|
435
|
+
Like `:user-invalid`, a field isn't flagged while it's first being filled in.
|
|
436
|
+
|
|
437
|
+
Its error shows when it's left after an edit, or when a submit attempt finds it invalid.
|
|
438
|
+
|
|
439
|
+
From then on it updates as the user types, and a form reset hides it again.
|
|
440
|
+
|
|
441
|
+
While shown, the input has `aria-invalid="true"` and the message is in its `aria-describedby`.
|
|
442
|
+
|
|
443
|
+
- **Submitting.**
|
|
444
|
+
|
|
445
|
+
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.
|
|
446
|
+
|
|
447
|
+
- **Why the submit button stays enabled.**
|
|
237
448
|
|
|
238
|
-
|
|
449
|
+
Nothing here disables your submit button while fields are invalid, and doing it yourself is best avoided.
|
|
239
450
|
|
|
240
|
-
|
|
451
|
+
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.
|
|
452
|
+
|
|
453
|
+
Instead, let the submit happen: it's blocked, each error shows next to its field, and focus moves to the first invalid one.
|
|
454
|
+
|
|
455
|
+
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.
|
|
456
|
+
|
|
457
|
+
**Empty fields.** Validation follows the browser's rules, which have two consequences:
|
|
458
|
+
|
|
459
|
+
* 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.
|
|
460
|
+
* `minlength` / `maxlength` only flag a value the user typed. A value set from code (`control.value`, `setValue()`) passes them until it's edited.
|
|
461
|
+
|
|
462
|
+
`validators` do run on an empty value. To keep an optional field optional, return `null` for `""`.
|
|
241
463
|
|
|
242
464
|
**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
465
|
|
|
@@ -259,7 +481,7 @@ a11y-input:state(dirty) { … } /* edited at least once
|
|
|
259
481
|
|
|
260
482
|
Where `:state()` isn't supported, style `input[aria-invalid="true"]` instead.
|
|
261
483
|
|
|
262
|
-
Checkbox, radio, range, color, file, hidden and button inputs are left alone: use `<a11y-checkbox>`, `<a11y-radio-group>`, … for those.
|
|
484
|
+
Checkbox, radio, range, color, file, hidden and button inputs are left alone: use `<a11y-checkbox>`, `<a11y-checkbox-group>`, `<a11y-radio-group>`, … for those.
|
|
263
485
|
|
|
264
486
|
| Name | Kind | Default | Description |
|
|
265
487
|
| --- | --- | --- | --- |
|
|
@@ -373,7 +595,7 @@ A `*` marks a required field. It's CSS only and hidden from screen readers, whic
|
|
|
373
595
|
|
|
374
596
|
#### `a11y-picture`
|
|
375
597
|
|
|
376
|
-
Wraps a
|
|
598
|
+
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"`).
|
|
377
599
|
|
|
378
600
|
```html
|
|
379
601
|
<a11y-picture>
|
|
@@ -385,7 +607,48 @@ Wraps a real `<picture>`/`<img>` and optional `<figcaption>` as `role="figure"`.
|
|
|
385
607
|
</a11y-picture>
|
|
386
608
|
```
|
|
387
609
|
|
|
388
|
-
|
|
610
|
+
**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.
|
|
611
|
+
|
|
612
|
+
```html
|
|
613
|
+
<a11y-picture
|
|
614
|
+
src="s.jpg"
|
|
615
|
+
alt="S illustration"
|
|
616
|
+
sources="s.avif image/avif, s.webp image/webp"
|
|
617
|
+
caption="An illustration of S">
|
|
618
|
+
</a11y-picture>
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
The same from JavaScript, in one object:
|
|
622
|
+
|
|
623
|
+
```js
|
|
624
|
+
const base = './assets/images/s';
|
|
625
|
+
document.querySelector('a11y-picture').image = {
|
|
626
|
+
sources: [
|
|
627
|
+
{ src: `${base}.avif`, type: 'image/avif' },
|
|
628
|
+
{ src: `${base}.webp`, type: 'image/webp' },
|
|
629
|
+
],
|
|
630
|
+
fallback: `${base}.jpg`,
|
|
631
|
+
alt: 'S illustration',
|
|
632
|
+
};
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
* 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.
|
|
636
|
+
* Use one way or the other: with a `src`, children you wrote are ignored.
|
|
637
|
+
* 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.
|
|
638
|
+
|
|
639
|
+
| Name | Kind | Default | Description |
|
|
640
|
+
| --- | --- | --- | --- |
|
|
641
|
+
| `src` | attribute / property | — | The fallback image. Setting it switches to a generated picture. |
|
|
642
|
+
| `alt` | attribute / property | — | The image's text alternative; `""` for a decorative image. |
|
|
643
|
+
| `sources` | attribute | — | `url type` pairs, comma-separated: `"s.avif image/avif, s.webp image/webp"`. |
|
|
644
|
+
| `sources` | property | — | `{ src, type?, media?, sizes? }[]`; `src` can be a full srcset. Wins over the attribute until the attribute changes. |
|
|
645
|
+
| `caption` | attribute / property | — | Text of a generated `<figcaption>`. |
|
|
646
|
+
| `width` / `height` | attribute / property | — | The image's intrinsic size, to avoid layout shift. |
|
|
647
|
+
| `loading` | attribute / property | `lazy` | `lazy` or `eager`. The image is always `decoding="async"`. |
|
|
648
|
+
| `sizes` | attribute | — | `sizes` of the `<img>`. |
|
|
649
|
+
| `image` | property | — | Sets it all at once: `{ sources?, fallback, alt, caption?, width?, height?, loading? }`. |
|
|
650
|
+
|
|
651
|
+
The `PictureSource` and `PictureImage` types are exported with the element.
|
|
389
652
|
|
|
390
653
|
<details>
|
|
391
654
|
<summary>CSS variables</summary>
|
|
@@ -699,6 +962,7 @@ No attributes or CSS variables. The class `a11y-visually-hidden` is also usable
|
|
|
699
962
|
* **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
963
|
* **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on `document`, with `event.detail.name` set to the tag name.
|
|
701
964
|
* **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
|
|
965
|
+
* **Except `<a11y-floating>`**, which is visible by default and has no `open`: `dismissAllOverlays()` only collapses its expanded panel. See [`a11y-floating`](#a11y-floating).
|
|
702
966
|
* **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
967
|
|
|
704
968
|
##### Overlays in a framework
|
|
@@ -728,6 +992,8 @@ If the bundle loads after rendering, the same query does find it, so the result
|
|
|
728
992
|
* bind events on the overlay element itself, or delegate from it;
|
|
729
993
|
* put final text into the markup before injecting it, rather than in a pass after rendering.
|
|
730
994
|
|
|
995
|
+
<a id="dialogs"></a>
|
|
996
|
+
|
|
731
997
|
##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
|
|
732
998
|
|
|
733
999
|
They also share:
|
|
@@ -744,6 +1010,8 @@ They also share:
|
|
|
744
1010
|
| `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
|
|
745
1011
|
| `onClose` | callback | — | Called once the close transition has finished. |
|
|
746
1012
|
|
|
1013
|
+
<a id="anchored-overlays"></a>
|
|
1014
|
+
|
|
747
1015
|
##### Anchored overlays (`<a11y-popover>`, `<a11y-tooltip>`, `<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
748
1016
|
|
|
749
1017
|
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.
|
|
@@ -756,6 +1024,8 @@ They are positioned next to an anchor. They flip to the opposite side when there
|
|
|
756
1024
|
| `offset` | attribute | `8` | Gap to the anchor, in px. |
|
|
757
1025
|
| `updatePosition()` | method | — | Recomputes the position (it already follows scroll, resize and size changes). |
|
|
758
1026
|
|
|
1027
|
+
<a id="menus"></a>
|
|
1028
|
+
|
|
759
1029
|
##### Menus (`<a11y-dropdown>`, `<a11y-context-menu>`)
|
|
760
1030
|
|
|
761
1031
|
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.
|
|
@@ -794,6 +1064,8 @@ loader.close();
|
|
|
794
1064
|
| --- | --- | --- | --- |
|
|
795
1065
|
| `message` | attribute | — | Visible message, also the spinner's label (`Loading` without it, [translatable](#translating-built-in-strings)). |
|
|
796
1066
|
|
|
1067
|
+
See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
|
|
1068
|
+
|
|
797
1069
|
<details>
|
|
798
1070
|
<summary>CSS variables</summary>
|
|
799
1071
|
|
|
@@ -809,7 +1081,7 @@ loader.close();
|
|
|
809
1081
|
|
|
810
1082
|
#### `a11y-context-menu`
|
|
811
1083
|
|
|
812
|
-
A menu that opens at the pointer on right-click of a trigger element, replacing the browser's own menu there. See [Menus](#
|
|
1084
|
+
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).
|
|
813
1085
|
|
|
814
1086
|
```html
|
|
815
1087
|
<div id="canvas">Right-click me</div>
|
|
@@ -825,6 +1097,8 @@ A menu that opens at the pointer on right-click of a trigger element, replacing
|
|
|
825
1097
|
| `triggerElement` | property | — | The trigger element itself (takes precedence over `trigger`). |
|
|
826
1098
|
| `dispose()` | method | — | Detaches from the trigger for good (`close()` only hides the current menu). |
|
|
827
1099
|
|
|
1100
|
+
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()`.
|
|
1101
|
+
|
|
828
1102
|
<details>
|
|
829
1103
|
<summary>CSS variables</summary>
|
|
830
1104
|
|
|
@@ -843,7 +1117,7 @@ A menu that opens at the pointer on right-click of a trigger element, replacing
|
|
|
843
1117
|
|
|
844
1118
|
#### `a11y-drawer`
|
|
845
1119
|
|
|
846
|
-
A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dialogs](#
|
|
1120
|
+
A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dialogs](#dialogs)).
|
|
847
1121
|
|
|
848
1122
|
```html
|
|
849
1123
|
<a11y-drawer id="filters" edge="left">
|
|
@@ -856,6 +1130,8 @@ A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dia
|
|
|
856
1130
|
| --- | --- | --- | --- |
|
|
857
1131
|
| `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
|
|
858
1132
|
|
|
1133
|
+
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()`.
|
|
1134
|
+
|
|
859
1135
|
<details>
|
|
860
1136
|
<summary>CSS variables</summary>
|
|
861
1137
|
|
|
@@ -878,7 +1154,7 @@ The close button uses the modal's `--a11y-modal-close-button-size` and `--a11y-m
|
|
|
878
1154
|
|
|
879
1155
|
#### `a11y-dropdown`
|
|
880
1156
|
|
|
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](#
|
|
1157
|
+
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).
|
|
882
1158
|
|
|
883
1159
|
```html
|
|
884
1160
|
<button id="actions-btn">Actions</button>
|
|
@@ -889,7 +1165,7 @@ A menu attached to a trigger button. The anchor is the trigger: clicking it togg
|
|
|
889
1165
|
</a11y-dropdown>
|
|
890
1166
|
```
|
|
891
1167
|
|
|
892
|
-
No attributes of its own
|
|
1168
|
+
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()`.
|
|
893
1169
|
|
|
894
1170
|
<details>
|
|
895
1171
|
<summary>CSS variables</summary>
|
|
@@ -927,7 +1203,7 @@ document.getElementById('stay').addEventListener('click', () => {
|
|
|
927
1203
|
});
|
|
928
1204
|
```
|
|
929
1205
|
|
|
930
|
-
|
|
1206
|
+
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:
|
|
931
1207
|
|
|
932
1208
|
<details>
|
|
933
1209
|
<summary>CSS variables</summary>
|
|
@@ -938,9 +1214,92 @@ Only `onClose` from the [Dialogs](#common-to-all-overlays) table applies. It use
|
|
|
938
1214
|
|
|
939
1215
|
</details>
|
|
940
1216
|
|
|
1217
|
+
#### `a11y-floating`
|
|
1218
|
+
|
|
1219
|
+
Content pinned to a corner or edge of the viewport: a floating button that opens a drawer, an info bubble, a help launcher. It's visible by default: there's no `open` attribute. Hide it with `hidden` or `dismiss()`. Several in the same position stack instead of overlapping.
|
|
1220
|
+
|
|
1221
|
+
It works in one of two modes:
|
|
1222
|
+
|
|
1223
|
+
* **Controls mode:** with `controls="<id>"`, its trigger opens and closes that overlay. The trigger is a `[data-floating-trigger]` child, else the first button. It gets `aria-controls`, an `aria-expanded` kept in sync with the overlay however it closes, and `aria-haspopup` (`dialog` for a modal, drawer, emergency dialog or `interactive` popover; `menu` for a dropdown or context menu). A popover or dropdown with no anchor is anchored to the trigger.
|
|
1224
|
+
* **Expandable mode:** with `expandable`, its content goes into a panel (`role="dialog"`, not modal) that a launcher button expands. The launcher is a `[data-floating-trigger]` child, else a generated button showing `label`. Expanding moves focus to the panel's first control. Escape, a click outside, the panel's × or the launcher collapse it, and focus returns to the launcher. The panel is named by `panel-label`, else its first heading, else `label`.
|
|
1225
|
+
|
|
1226
|
+
```html
|
|
1227
|
+
<!-- Opens a drawer -->
|
|
1228
|
+
<a11y-floating controls="nav-drawer"><button>Menu</button></a11y-floating>
|
|
1229
|
+
<a11y-drawer id="nav-drawer"><h2>Navigation</h2>…</a11y-drawer>
|
|
1230
|
+
|
|
1231
|
+
<!-- Info bubble -->
|
|
1232
|
+
<a11y-floating position="bottom-left" label="What's new" dismissible hide-on-scroll>
|
|
1233
|
+
<p>Dark mode is here.</p>
|
|
1234
|
+
</a11y-floating>
|
|
1235
|
+
|
|
1236
|
+
<!-- Help panel -->
|
|
1237
|
+
<a11y-floating expandable label="Help">
|
|
1238
|
+
<h2>Need help?</h2>
|
|
1239
|
+
<a href="/faq">Read the FAQ</a>
|
|
1240
|
+
</a11y-floating>
|
|
1241
|
+
```
|
|
1242
|
+
|
|
1243
|
+
| Name | Kind | Default | Description |
|
|
1244
|
+
| --- | --- | --- | --- |
|
|
1245
|
+
| `position` | attribute / property | `bottom-right` | `top`, `bottom`, `top-left`, `top-right`, `bottom-left` or `bottom-right`. |
|
|
1246
|
+
| `controls` | attribute | — | Id of the overlay its trigger toggles. |
|
|
1247
|
+
| `controlsElement` | property | — | The same, as an element. |
|
|
1248
|
+
| `expandable` | attribute | absent | Expandable mode. Ignored with `controls`. |
|
|
1249
|
+
| `expanded` | attribute / property | absent | Whether the panel is expanded. `expand()`, `collapse()` and `toggle()` set it. |
|
|
1250
|
+
| `label` | attribute | — | Text of the generated launcher. Outside expandable mode, makes the element a `role="region"` landmark with this name. |
|
|
1251
|
+
| `panel-label` | attribute | first heading | Accessible name of the panel. |
|
|
1252
|
+
| `close-label` | attribute | `Close dialog` | Accessible name of the panel's × button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1253
|
+
| `trap-focus` | attribute | absent | Traps focus in the expanded panel. |
|
|
1254
|
+
| `dismissible` | attribute | absent | Adds a × button that calls `dismiss()`. |
|
|
1255
|
+
| `dismiss-label` | attribute | `Dismiss` | Accessible name of that button. See [Translating built-in strings](#translating-built-in-strings). |
|
|
1256
|
+
| `announce` | attribute | absent | Makes the element a polite `role="status"` live region, so content shown with `show()` is announced. |
|
|
1257
|
+
| `hide-on-scroll` | attribute | absent | Slides it out of view while the page scrolls down and back on scroll up. It stays in the Tab order and comes back when focused. |
|
|
1258
|
+
| `scroll-threshold` | attribute | `16` | Pixels of scrolling before `hide-on-scroll` reacts. |
|
|
1259
|
+
| `dismiss()` | method | — | Fires a cancelable `a11y-floating-dismiss` event, then animates out and sets `hidden`. Focus goes back to where it was before it entered. |
|
|
1260
|
+
| `show()` | method | — | Shows it again (`hidden = false`). |
|
|
1261
|
+
| `onClose` | callback | — | Called when the panel collapses or the element is dismissed. |
|
|
1262
|
+
|
|
1263
|
+
Events on the element: `a11y-floating-expand`, `a11y-floating-collapse`, `a11y-floating-dismiss` (cancelable). The panel also fires `a11y-overlay-open` / `a11y-overlay-close` on `document`, and `dismissAllOverlays()` collapses it but leaves the element showing. Like every overlay it moves itself out of where it was authored (into `.a11y-floating-stack[data-position]` on `<body>`); see [Overlays in a framework](#overlays-in-a-framework) for `removeOverlaysWithin()`. Being last in `<body>`, it comes last in the Tab order.
|
|
1264
|
+
|
|
1265
|
+
Classes: `.a11y-floating-launcher`, `.a11y-floating-panel`, `.a11y-floating-panel-close`, `.a11y-floating-dismiss`. The element itself has no background, so style your bubble's content directly.
|
|
1266
|
+
|
|
1267
|
+
<details>
|
|
1268
|
+
<summary>CSS variables</summary>
|
|
1269
|
+
|
|
1270
|
+
Offsets add the device's safe-area inset (`env(safe-area-inset-*)`). The stacking order comes from `--a11y-z-floating-button` (see [Shared tokens](#shared-tokens)).
|
|
1271
|
+
|
|
1272
|
+
| Variable | Default |
|
|
1273
|
+
| --- | --- |
|
|
1274
|
+
| `--a11y-floating-close-font-size` | `1.25rem` |
|
|
1275
|
+
| `--a11y-floating-content-gap` | `0.5rem` |
|
|
1276
|
+
| `--a11y-floating-gap` | `0.75rem` |
|
|
1277
|
+
| `--a11y-floating-launcher-border-radius` | `999px` |
|
|
1278
|
+
| `--a11y-floating-launcher-color-background` | `#111827` |
|
|
1279
|
+
| `--a11y-floating-launcher-color-text` | `#ffffff` |
|
|
1280
|
+
| `--a11y-floating-launcher-padding` | `0 1rem` |
|
|
1281
|
+
| `--a11y-floating-launcher-size` | `3rem` |
|
|
1282
|
+
| `--a11y-floating-max-width` | `calc(100vw - 2rem)` |
|
|
1283
|
+
| `--a11y-floating-offset` | `1rem` |
|
|
1284
|
+
| `--a11y-floating-offset-x` / `--a11y-floating-offset-y` | `--a11y-floating-offset` |
|
|
1285
|
+
| `--a11y-floating-panel-border-radius` | `0.5rem` |
|
|
1286
|
+
| `--a11y-floating-panel-color-background` | `#ffffff` |
|
|
1287
|
+
| `--a11y-floating-panel-color-text` | `#111827` |
|
|
1288
|
+
| `--a11y-floating-panel-initial-scale` | `0.97` |
|
|
1289
|
+
| `--a11y-floating-panel-max-height` | `min(480px, 70vh)` |
|
|
1290
|
+
| `--a11y-floating-panel-offset` | `0.5rem` |
|
|
1291
|
+
| `--a11y-floating-panel-padding` | `1rem` |
|
|
1292
|
+
| `--a11y-floating-panel-shadow-blur` | `10px` |
|
|
1293
|
+
| `--a11y-floating-panel-shadow-fade` | `80%` |
|
|
1294
|
+
| `--a11y-floating-panel-shadow-offset-y` | `2px` |
|
|
1295
|
+
| `--a11y-floating-panel-width` | `min(320px, calc(100vw - 2rem))` |
|
|
1296
|
+
| `--a11y-floating-transition-duration` | `0.2s` |
|
|
1297
|
+
|
|
1298
|
+
</details>
|
|
1299
|
+
|
|
941
1300
|
#### `a11y-modal`
|
|
942
1301
|
|
|
943
|
-
A centered dialog. Your content is its children. See [Dialogs](#
|
|
1302
|
+
A centered dialog. Your content is its children. See [Dialogs](#dialogs).
|
|
944
1303
|
|
|
945
1304
|
```html
|
|
946
1305
|
<button id="open-settings">Open settings</button>
|
|
@@ -965,6 +1324,8 @@ document.getElementById('open-settings').addEventListener('click', () => {
|
|
|
965
1324
|
| --- | --- | --- | --- |
|
|
966
1325
|
| `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
|
|
967
1326
|
|
|
1327
|
+
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()`.
|
|
1328
|
+
|
|
968
1329
|
`.a11y-modal-buttons` is an optional footer-row class for your own buttons.
|
|
969
1330
|
|
|
970
1331
|
<details>
|
|
@@ -1021,6 +1382,8 @@ window.addEventListener('popstate', () => document.getElementById('banners').dis
|
|
|
1021
1382
|
| `show(message, options)` | method | — | Shows a banner (or queues it). |
|
|
1022
1383
|
| `dismissAll()` | method | — | Closes every banner (calling their `onClose`) and drops the queued ones silently. |
|
|
1023
1384
|
|
|
1385
|
+
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()`.
|
|
1386
|
+
|
|
1024
1387
|
`show()` / `showNotificationBanner()` options:
|
|
1025
1388
|
|
|
1026
1389
|
| Option | Default | Description |
|
|
@@ -1050,7 +1413,7 @@ Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared
|
|
|
1050
1413
|
|
|
1051
1414
|
#### `a11y-popover`
|
|
1052
1415
|
|
|
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](#
|
|
1416
|
+
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).
|
|
1054
1417
|
|
|
1055
1418
|
```html
|
|
1056
1419
|
<button id="info-btn">Info</button>
|
|
@@ -1071,6 +1434,8 @@ document.getElementById('info-btn').addEventListener('click', () => {
|
|
|
1071
1434
|
| `trap-focus` | attribute | follows `interactive` | Force the focus trap on (`trap-focus`) or off (`trap-focus="false"`). |
|
|
1072
1435
|
| `onClose` | callback | — | Called once it has closed. |
|
|
1073
1436
|
|
|
1437
|
+
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()`.
|
|
1438
|
+
|
|
1074
1439
|
<details>
|
|
1075
1440
|
<summary>CSS variables</summary>
|
|
1076
1441
|
|
|
@@ -1097,10 +1462,12 @@ Toast notifications that dismiss themselves: after 3 s by default, or 10 s when
|
|
|
1097
1462
|
|
|
1098
1463
|
```js
|
|
1099
1464
|
import { notify } from 'a11y-elements/overlays/snackbar';
|
|
1465
|
+
import { raw } from 'a11y-elements/core';
|
|
1100
1466
|
|
|
1101
1467
|
notify('Saved');
|
|
1102
1468
|
notify('Upload failed', { type: 'error', actionText: 'Retry', onAction: retryUpload });
|
|
1103
1469
|
notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
1470
|
+
notify(raw('Saved. <a href="/files">View files</a>')); // markup: sanitized, see below
|
|
1104
1471
|
```
|
|
1105
1472
|
|
|
1106
1473
|
| Name | Kind | Default | Description |
|
|
@@ -1109,6 +1476,10 @@ notify('Copied to clipboard', { position: 'top', duration: 1500 });
|
|
|
1109
1476
|
| `maxStack` | property | `3` | Same as `max-stack`. `setMaxStack(n)` is an alias. |
|
|
1110
1477
|
| `notify(message, options)` | method | — | Shows a toast (or queues it). |
|
|
1111
1478
|
|
|
1479
|
+
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()`.
|
|
1480
|
+
|
|
1481
|
+
A `message` is text: a string is escaped. For markup, pass `raw(markup)` from `a11y-elements/core`. It's sanitized (no scripts, styles, event handlers or `javascript:` URLs), so it's safe with user data in it. `trustedRaw(markup)` skips that, for markup you wrote yourself. The same goes for `<a11y-notification-banner>`.
|
|
1482
|
+
|
|
1112
1483
|
`notify()` options (method and convenience export):
|
|
1113
1484
|
|
|
1114
1485
|
| Option | Default | Description |
|
|
@@ -1143,7 +1514,7 @@ Colors come from the shared `--a11y-color-*` tokens (see [Shared tokens](#shared
|
|
|
1143
1514
|
|
|
1144
1515
|
#### `a11y-tooltip`
|
|
1145
1516
|
|
|
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](#
|
|
1517
|
+
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).
|
|
1147
1518
|
|
|
1148
1519
|
```html
|
|
1149
1520
|
<button id="save-btn">Save</button>
|
|
@@ -1156,6 +1527,8 @@ A short description shown on hover or focus of its anchor, which gets `aria-desc
|
|
|
1156
1527
|
| `hide-delay` | attribute / property (read-only) | `100` | Delay before hiding once pointer/focus leaves, in ms. |
|
|
1157
1528
|
| `dispose()` | method | — | Detaches from the anchor for good (`close()` only hides it). |
|
|
1158
1529
|
|
|
1530
|
+
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()`.
|
|
1531
|
+
|
|
1159
1532
|
<details>
|
|
1160
1533
|
<summary>CSS variables</summary>
|
|
1161
1534
|
|