a11y-elements 0.4.0 → 0.6.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.
Files changed (233) hide show
  1. package/README.md +210 -18
  2. package/dist/a11y-dark.css +31 -0
  3. package/dist/a11y.css +253 -166
  4. package/dist/all.d.ts +2 -1
  5. package/dist/all.js +2 -1
  6. package/dist/all.js.map +1 -1
  7. package/dist/browser/all.js +49 -42
  8. package/dist/browser/{chunk-UCAUEEED.js → chunk-2NVBEX7S.js} +5 -5
  9. package/dist/browser/{chunk-UCAUEEED.js.map → chunk-2NVBEX7S.js.map} +1 -1
  10. package/dist/browser/{chunk-A32U5MX7.js → chunk-2ZZTJUCP.js} +3 -3
  11. package/dist/browser/{chunk-HLID3PP5.js → chunk-34XMXDXI.js} +3 -3
  12. package/dist/browser/{chunk-O4AJULBZ.js → chunk-4SU2MZLZ.js} +8 -8
  13. package/dist/browser/chunk-4SU2MZLZ.js.map +1 -0
  14. package/dist/browser/{chunk-VY6BZLCJ.js → chunk-5AG6BS4G.js} +3 -3
  15. package/dist/browser/{chunk-6BOK3R6K.js → chunk-5MZZUC7J.js} +3 -3
  16. package/dist/browser/{chunk-3UC2S6JJ.js → chunk-5VP2UQ2M.js} +5 -4
  17. package/dist/browser/chunk-5VP2UQ2M.js.map +1 -0
  18. package/dist/browser/{chunk-SYKTM7WJ.js → chunk-67ZOQAXV.js} +3 -3
  19. package/dist/browser/{chunk-R4OVZULJ.js → chunk-6G3UL7FH.js} +8 -6
  20. package/dist/browser/chunk-6G3UL7FH.js.map +1 -0
  21. package/dist/browser/{chunk-QT7Z23GS.js → chunk-73Y3YTSE.js} +3 -3
  22. package/dist/browser/{chunk-2YF57VSU.js → chunk-7H2JJLCH.js} +3 -3
  23. package/dist/browser/{chunk-3RRJOPEF.js → chunk-7NNZKO4M.js} +2 -2
  24. package/dist/browser/{chunk-ABTLBDUK.js → chunk-ACNPSWNA.js} +3 -3
  25. package/dist/browser/{chunk-4IURHUQU.js → chunk-BIPMRVAZ.js} +12 -10
  26. package/dist/browser/chunk-BIPMRVAZ.js.map +1 -0
  27. package/dist/browser/{chunk-P42KF3NM.js → chunk-BRTWVAIT.js} +4 -4
  28. package/dist/browser/chunk-BRTWVAIT.js.map +1 -0
  29. package/dist/browser/{chunk-ACOSO5NE.js → chunk-C3FJNOYD.js} +21 -12
  30. package/dist/browser/chunk-C3FJNOYD.js.map +1 -0
  31. package/dist/browser/{chunk-EAASMTBS.js → chunk-CKKI36NF.js} +16 -13
  32. package/dist/browser/chunk-CKKI36NF.js.map +1 -0
  33. package/dist/browser/{chunk-NI7PACR4.js → chunk-EOB4TM57.js} +3 -3
  34. package/dist/browser/{chunk-CXUZEGZY.js → chunk-F4AVN6JZ.js} +3 -3
  35. package/dist/browser/chunk-F4AVN6JZ.js.map +1 -0
  36. package/dist/browser/{chunk-I4KOJO4B.js → chunk-FFPWED5A.js} +3 -3
  37. package/dist/browser/{chunk-KUTHJLZ5.js → chunk-IAXHGJ62.js} +8 -5
  38. package/dist/browser/chunk-IAXHGJ62.js.map +1 -0
  39. package/dist/browser/{chunk-NTNPE4TH.js → chunk-IL347KK3.js} +28 -11
  40. package/dist/browser/chunk-IL347KK3.js.map +1 -0
  41. package/dist/browser/{chunk-S7GPESLQ.js → chunk-LCRRFDV5.js} +19 -7
  42. package/dist/browser/chunk-LCRRFDV5.js.map +1 -0
  43. package/dist/browser/{chunk-FXHJKL3U.js → chunk-MENBNSBN.js} +9 -10
  44. package/dist/browser/chunk-MENBNSBN.js.map +1 -0
  45. package/dist/browser/chunk-MENQDLBL.js +81 -0
  46. package/dist/browser/chunk-MENQDLBL.js.map +1 -0
  47. package/dist/browser/{chunk-GUKQIHPM.js → chunk-MG2YZ7AD.js} +3 -3
  48. package/dist/browser/{chunk-4FHDXZ3L.js → chunk-N7AMX7RC.js} +7 -7
  49. package/dist/browser/{chunk-4FHDXZ3L.js.map → chunk-N7AMX7RC.js.map} +1 -1
  50. package/dist/browser/{chunk-LQ34M47I.js → chunk-NEQKRAIP.js} +2 -2
  51. package/dist/browser/chunk-PTU2DM52.js +169 -0
  52. package/dist/browser/chunk-PTU2DM52.js.map +1 -0
  53. package/dist/browser/chunk-PWR4UC47.js +122 -0
  54. package/dist/browser/chunk-PWR4UC47.js.map +1 -0
  55. package/dist/browser/{chunk-GDJTILU4.js → chunk-QT3RDF3H.js} +3 -3
  56. package/dist/browser/{chunk-6Q6VW435.js → chunk-SGSOENNQ.js} +23 -11
  57. package/dist/browser/chunk-SGSOENNQ.js.map +1 -0
  58. package/dist/browser/{chunk-A5CV54CT.js → chunk-SQ7OFQMX.js} +5 -4
  59. package/dist/browser/chunk-SQ7OFQMX.js.map +1 -0
  60. package/dist/browser/{chunk-ISWQOJT7.js → chunk-SREYEWDY.js} +3 -3
  61. package/dist/browser/{chunk-HPTH4SJ2.js → chunk-UOOA4WYM.js} +3 -3
  62. package/dist/browser/{chunk-SIQUYA37.js → chunk-VZZ6PGGW.js} +17 -11
  63. package/dist/browser/chunk-VZZ6PGGW.js.map +1 -0
  64. package/dist/browser/{chunk-ZMCETLOQ.js → chunk-WQJUSHAX.js} +5 -4
  65. package/dist/browser/chunk-WQJUSHAX.js.map +1 -0
  66. package/dist/browser/{chunk-HGPHWR3R.js → chunk-WRM4HPFX.js} +3 -3
  67. package/dist/browser/chunk-XNWCI66X.js +202 -0
  68. package/dist/browser/chunk-XNWCI66X.js.map +1 -0
  69. package/dist/browser/{chunk-TTP33GXU.js → chunk-ZCMKKXSE.js} +32 -5
  70. package/dist/browser/chunk-ZCMKKXSE.js.map +1 -0
  71. package/dist/browser/{chunk-GKNBHWGY.js → chunk-ZLIFEZUJ.js} +3 -3
  72. package/dist/browser/components/anchor/define.js +3 -3
  73. package/dist/browser/components/avatar/define.js +3 -2
  74. package/dist/browser/components/card-link/define.js +3 -3
  75. package/dist/browser/components/checkbox/define.js +3 -3
  76. package/dist/browser/components/checkbox-group/define.js +3 -3
  77. package/dist/browser/components/file-input/define.js +4 -4
  78. package/dist/browser/components/focusable/define.js +2 -2
  79. package/dist/browser/components/input/define.js +4 -4
  80. package/dist/browser/components/label/define.js +3 -3
  81. package/dist/browser/components/picture/define.js +3 -3
  82. package/dist/browser/components/progress/define.js +3 -2
  83. package/dist/browser/components/radio-group/define.js +3 -3
  84. package/dist/browser/components/select/define.js +3 -3
  85. package/dist/browser/components/skeleton/define.js +3 -2
  86. package/dist/browser/components/spinner/define.js +3 -2
  87. package/dist/browser/components/switch/define.js +3 -3
  88. package/dist/browser/components/tabs/define.js +16 -0
  89. package/dist/browser/components/tabs/define.js.map +1 -0
  90. package/dist/browser/components/textarea/define.js +4 -4
  91. package/dist/browser/components/visually-hidden/define.js +2 -2
  92. package/dist/browser/overlays/blocking-loader/define.js +7 -6
  93. package/dist/browser/overlays/context-menu/define.js +7 -7
  94. package/dist/browser/overlays/drawer/define.js +6 -6
  95. package/dist/browser/overlays/dropdown/define.js +7 -7
  96. package/dist/browser/overlays/emergency-dialog/define.js +6 -6
  97. package/dist/browser/overlays/floating/define.js +4 -4
  98. package/dist/browser/overlays/modal/define.js +10 -7
  99. package/dist/browser/overlays/notification-banner/define.js +5 -4
  100. package/dist/browser/overlays/popover/define.js +6 -6
  101. package/dist/browser/overlays/snackbar/define.js +5 -4
  102. package/dist/browser/overlays/tooltip/define.js +6 -6
  103. package/dist/components/avatar/avatar.element.d.ts +5 -3
  104. package/dist/components/avatar/avatar.element.js +12 -9
  105. package/dist/components/avatar/avatar.element.js.map +1 -1
  106. package/dist/components/progress/progress.element.d.ts +4 -1
  107. package/dist/components/progress/progress.element.js +14 -4
  108. package/dist/components/progress/progress.element.js.map +1 -1
  109. package/dist/components/skeleton/skeleton.element.d.ts +1 -2
  110. package/dist/components/skeleton/skeleton.element.js +3 -3
  111. package/dist/components/skeleton/skeleton.element.js.map +1 -1
  112. package/dist/components/spinner/spinner.element.d.ts +2 -2
  113. package/dist/components/spinner/spinner.element.js +3 -2
  114. package/dist/components/spinner/spinner.element.js.map +1 -1
  115. package/dist/components/tabs/define.d.ts +8 -0
  116. package/dist/components/tabs/define.js +6 -0
  117. package/dist/components/tabs/define.js.map +1 -0
  118. package/dist/components/tabs/tabs.element.d.ts +60 -0
  119. package/dist/components/tabs/tabs.element.js +207 -0
  120. package/dist/components/tabs/tabs.element.js.map +1 -0
  121. package/dist/core/a11y-element.d.ts +6 -9
  122. package/dist/core/a11y-element.js +12 -5
  123. package/dist/core/a11y-element.js.map +1 -1
  124. package/dist/core/a11y-overlay-element.d.ts +17 -9
  125. package/dist/core/a11y-overlay-element.js +24 -11
  126. package/dist/core/a11y-overlay-element.js.map +1 -1
  127. package/dist/core/a11y-wrapper-element.d.ts +3 -3
  128. package/dist/core/a11y-wrapper-element.js +3 -3
  129. package/dist/core/a11y-wrapper-element.js.map +1 -1
  130. package/dist/core/dom.d.ts +23 -0
  131. package/dist/core/dom.js +35 -0
  132. package/dist/core/dom.js.map +1 -0
  133. package/dist/core/focus-trap.d.ts +7 -0
  134. package/dist/core/focus-trap.js +39 -3
  135. package/dist/core/focus-trap.js.map +1 -1
  136. package/dist/core/index.d.ts +1 -0
  137. package/dist/core/index.js +1 -0
  138. package/dist/core/index.js.map +1 -1
  139. package/dist/core/overlay-registry.d.ts +27 -8
  140. package/dist/core/overlay-registry.js +34 -9
  141. package/dist/core/overlay-registry.js.map +1 -1
  142. package/dist/core/sanitize.d.ts +2 -6
  143. package/dist/core/sanitize.js +9 -28
  144. package/dist/core/sanitize.js.map +1 -1
  145. package/dist/core/strings.d.ts +4 -0
  146. package/dist/core/strings.js +2 -0
  147. package/dist/core/strings.js.map +1 -1
  148. package/dist/core/template.d.ts +18 -48
  149. package/dist/core/template.js +27 -213
  150. package/dist/core/template.js.map +1 -1
  151. package/dist/overlays/blocking-loader/blocking-loader.element.js +5 -3
  152. package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -1
  153. package/dist/overlays/core/a11y-anchored-overlay-element.js +3 -3
  154. package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
  155. package/dist/overlays/core/a11y-menu-overlay-element.js +2 -2
  156. package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
  157. package/dist/overlays/core/a11y-modal-overlay-element.d.ts +7 -0
  158. package/dist/overlays/core/a11y-modal-overlay-element.js +29 -4
  159. package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
  160. package/dist/overlays/core/a11y-passive-overlay-element.d.ts +4 -4
  161. package/dist/overlays/core/a11y-passive-overlay-element.js +1 -1
  162. package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
  163. package/dist/overlays/drawer/drawer.element.d.ts +2 -1
  164. package/dist/overlays/drawer/drawer.element.js +2 -1
  165. package/dist/overlays/drawer/drawer.element.js.map +1 -1
  166. package/dist/overlays/emergency-dialog/emergency-dialog.element.d.ts +2 -1
  167. package/dist/overlays/emergency-dialog/emergency-dialog.element.js +2 -1
  168. package/dist/overlays/emergency-dialog/emergency-dialog.element.js.map +1 -1
  169. package/dist/overlays/floating/floating.element.d.ts +1 -1
  170. package/dist/overlays/floating/floating.element.js +3 -3
  171. package/dist/overlays/floating/floating.element.js.map +1 -1
  172. package/dist/overlays/modal/confirm-dialog.d.ts +24 -0
  173. package/dist/overlays/modal/confirm-dialog.js +41 -0
  174. package/dist/overlays/modal/confirm-dialog.js.map +1 -0
  175. package/dist/overlays/modal/define.d.ts +1 -0
  176. package/dist/overlays/modal/define.js +1 -0
  177. package/dist/overlays/modal/define.js.map +1 -1
  178. package/dist/overlays/modal/modal.element.d.ts +3 -2
  179. package/dist/overlays/modal/modal.element.js +2 -1
  180. package/dist/overlays/modal/modal.element.js.map +1 -1
  181. package/dist/overlays/notification-banner/define.d.ts +2 -2
  182. package/dist/overlays/notification-banner/define.js.map +1 -1
  183. package/dist/overlays/notification-banner/notification-banner.element.d.ts +3 -3
  184. package/dist/overlays/notification-banner/notification-banner.element.js +2 -8
  185. package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
  186. package/dist/overlays/popover/popover.element.d.ts +2 -1
  187. package/dist/overlays/popover/popover.element.js +2 -1
  188. package/dist/overlays/popover/popover.element.js.map +1 -1
  189. package/dist/overlays/snackbar/define.d.ts +2 -2
  190. package/dist/overlays/snackbar/define.js.map +1 -1
  191. package/dist/overlays/snackbar/snackbar.element.d.ts +2 -2
  192. package/dist/overlays/snackbar/snackbar.element.js +4 -5
  193. package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
  194. package/package.json +3 -2
  195. package/dist/browser/chunk-3UC2S6JJ.js.map +0 -1
  196. package/dist/browser/chunk-46SIA3RI.js +0 -410
  197. package/dist/browser/chunk-46SIA3RI.js.map +0 -1
  198. package/dist/browser/chunk-4IURHUQU.js.map +0 -1
  199. package/dist/browser/chunk-6Q6VW435.js.map +0 -1
  200. package/dist/browser/chunk-A5CV54CT.js.map +0 -1
  201. package/dist/browser/chunk-ACOSO5NE.js.map +0 -1
  202. package/dist/browser/chunk-CXUZEGZY.js.map +0 -1
  203. package/dist/browser/chunk-EAASMTBS.js.map +0 -1
  204. package/dist/browser/chunk-FXHJKL3U.js.map +0 -1
  205. package/dist/browser/chunk-GH53G7MU.js +0 -35
  206. package/dist/browser/chunk-GH53G7MU.js.map +0 -1
  207. package/dist/browser/chunk-KUTHJLZ5.js.map +0 -1
  208. package/dist/browser/chunk-NTNPE4TH.js.map +0 -1
  209. package/dist/browser/chunk-O4AJULBZ.js.map +0 -1
  210. package/dist/browser/chunk-P42KF3NM.js.map +0 -1
  211. package/dist/browser/chunk-R4OVZULJ.js.map +0 -1
  212. package/dist/browser/chunk-S7GPESLQ.js.map +0 -1
  213. package/dist/browser/chunk-SIQUYA37.js.map +0 -1
  214. package/dist/browser/chunk-TTP33GXU.js.map +0 -1
  215. package/dist/browser/chunk-ZMCETLOQ.js.map +0 -1
  216. /package/dist/browser/{chunk-A32U5MX7.js.map → chunk-2ZZTJUCP.js.map} +0 -0
  217. /package/dist/browser/{chunk-HLID3PP5.js.map → chunk-34XMXDXI.js.map} +0 -0
  218. /package/dist/browser/{chunk-VY6BZLCJ.js.map → chunk-5AG6BS4G.js.map} +0 -0
  219. /package/dist/browser/{chunk-6BOK3R6K.js.map → chunk-5MZZUC7J.js.map} +0 -0
  220. /package/dist/browser/{chunk-SYKTM7WJ.js.map → chunk-67ZOQAXV.js.map} +0 -0
  221. /package/dist/browser/{chunk-QT7Z23GS.js.map → chunk-73Y3YTSE.js.map} +0 -0
  222. /package/dist/browser/{chunk-2YF57VSU.js.map → chunk-7H2JJLCH.js.map} +0 -0
  223. /package/dist/browser/{chunk-3RRJOPEF.js.map → chunk-7NNZKO4M.js.map} +0 -0
  224. /package/dist/browser/{chunk-ABTLBDUK.js.map → chunk-ACNPSWNA.js.map} +0 -0
  225. /package/dist/browser/{chunk-NI7PACR4.js.map → chunk-EOB4TM57.js.map} +0 -0
  226. /package/dist/browser/{chunk-I4KOJO4B.js.map → chunk-FFPWED5A.js.map} +0 -0
  227. /package/dist/browser/{chunk-GUKQIHPM.js.map → chunk-MG2YZ7AD.js.map} +0 -0
  228. /package/dist/browser/{chunk-LQ34M47I.js.map → chunk-NEQKRAIP.js.map} +0 -0
  229. /package/dist/browser/{chunk-GDJTILU4.js.map → chunk-QT3RDF3H.js.map} +0 -0
  230. /package/dist/browser/{chunk-ISWQOJT7.js.map → chunk-SREYEWDY.js.map} +0 -0
  231. /package/dist/browser/{chunk-HPTH4SJ2.js.map → chunk-UOOA4WYM.js.map} +0 -0
  232. /package/dist/browser/{chunk-HGPHWR3R.js.map → chunk-WRM4HPFX.js.map} +0 -0
  233. /package/dist/browser/{chunk-GKNBHWGY.js.map → chunk-ZLIFEZUJ.js.map} +0 -0
package/README.md CHANGED
@@ -4,7 +4,7 @@ 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)
7
+ See a [demo of the elements](https://nutin.dev/a11y-elements/elements) - See a [demo of the overlays](https://nutin.org/a11y-elements/overlays)
8
8
 
9
9
  ## Usage
10
10
 
@@ -56,7 +56,6 @@ A few English strings end up in accessible names and announcements. Replace them
56
56
 
57
57
  ```js
58
58
  import { setStrings } from 'a11y-elements/core';
59
- // or: import { setStrings } from './node_modules/a11y-elements/dist/browser/overlays/modal/define.js';
60
59
 
61
60
  setStrings({
62
61
  closeDialog: 'Fermer la boîte de dialogue',
@@ -70,6 +69,7 @@ setStrings({
70
69
  | `opensInNewTab` | `(opens in new tab)` | `<a11y-anchor>` new-tab links | `new-tab-label` |
71
70
  | `navigatedTo` | `Navigated to {name}` | `<a11y-anchor>` jump announcement (`{name}` is the target's name) | `navigated-label` |
72
71
  | `closeDialog` | `Close dialog` | the × button of `<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`, an expandable `<a11y-floating>`'s panel | `close-label` |
72
+ | `confirm` / `cancel` | `OK` / `Cancel` | the buttons of `confirmDialog()` | `confirmLabel` / `cancelLabel` |
73
73
  | `dismiss` | `Dismiss` | the × button of each `<a11y-notification-banner>` item and of a `dismissible` `<a11y-floating>` | `dismiss-label` |
74
74
  | `loading` | `Loading` | `<a11y-spinner>`, `<a11y-blocking-loader>` | `label` / `message` |
75
75
  | `progress` | `Progress` | `<a11y-progress>` without a label | `label` / `aria-label` |
@@ -98,7 +98,7 @@ Each section shows an example, the element's own attributes/properties/methods,
98
98
 
99
99
  Behavior shared by overlays is described once, in [Common to all overlays](#common-to-all-overlays).
100
100
 
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)
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-tabs>`](#a11y-tabs) · [`<a11y-textarea>`](#a11y-textarea) · [`<a11y-visually-hidden>`](#a11y-visually-hidden)
102
102
 
103
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)
104
104
 
@@ -146,6 +146,8 @@ An avatar image with an initials fallback. When the image is missing or fails to
146
146
  | `size` | attribute | — | Sets `--a11y-avatar-size`. |
147
147
  | `shape` | attribute / property | `circle` | `circle` or `square`. |
148
148
 
149
+ The initials are set in Arial rather than the page font, so they fit the circle the same way everywhere. Set `--a11y-avatar-font-family` to use your own font.
150
+
149
151
  <details>
150
152
  <summary>CSS variables</summary>
151
153
 
@@ -762,6 +764,8 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
762
764
  | `onChange` | callback | — | `(value: string) => void`, called on every `change`. |
763
765
  | `getValue()` / `setValue(value)` | method | — | Reads / sets the selected value. |
764
766
 
767
+ The native `<select>` inside stays the source of truth: its `change` events and `.value` work as usual. A framework that binds events on the native element can use those and skip `onChange` / `getValue()`.
768
+
765
769
  <details>
766
770
  <summary>CSS variables</summary>
767
771
 
@@ -777,7 +781,7 @@ Wraps a real `<select>` in a `<label>` with a visible label text. Options and ke
777
781
  | `--a11y-select-color-text-muted` | `#6b7280` |
778
782
  | `--a11y-select-control-border-radius` | `4px` |
779
783
  | `--a11y-select-control-border-width` | `1px` |
780
- | `--a11y-select-control-font-family` | `Arial, sans-serif` |
784
+ | `--a11y-select-control-font-family` | `inherit` |
781
785
  | `--a11y-select-control-font-size` | `1rem` |
782
786
  | `--a11y-select-control-line-height` | `1.4` |
783
787
  | `--a11y-select-control-padding-x` | `1rem` |
@@ -912,6 +916,61 @@ Like `<a11y-checkbox>`, but the input gets `role="switch"`.
912
916
 
913
917
  </details>
914
918
 
919
+ #### `a11y-tabs`
920
+
921
+ Turns your own tab buttons and panels into the WAI-ARIA Tabs pattern (automatic activation). Tabs are the `[data-tab]` elements inside the `[data-tablist]` child, each one showing the `[data-panel]` with the same name.
922
+
923
+ ```html
924
+ <a11y-tabs label="Projects" selected="apps">
925
+ <div data-tablist>
926
+ <button data-tab="tools">Tools</button>
927
+ <button data-tab="apps">Apps</button>
928
+ </div>
929
+ <section data-panel="tools">…</section>
930
+ <section data-panel="apps">…</section>
931
+ </a11y-tabs>
932
+ ```
933
+
934
+ * Sets the roles, `aria-selected`, `aria-controls`/`aria-labelledby` (ids generated when missing) and a roving `tabindex`. Hidden panels get `hidden`. A panel gets `tabindex="0"` unless it already has a `tabindex`.
935
+ * Arrow keys move the selection and focus (Left/Right, or Up/Down with `orientation="vertical"`, mirrored in right-to-left text). Home/End go to the first/last tab. Disabled tabs (`disabled` or `aria-disabled="true"`) are skipped.
936
+ * A same-page link (`<a href="#id">`, with or without `<a11y-anchor>`) whose target is in a hidden panel selects that panel first. So do `hashchange` and the page's initial hash, even when its target is added after the element connects (it's then scrolled into view).
937
+ * Tabs and panels inside a nested `<a11y-tabs>` belong to it.
938
+
939
+ | Name | Kind | Default | Description |
940
+ | --- | --- | --- | --- |
941
+ | `label` | attribute | — | The tablist's accessible name (`aria-label`), unless the tablist has `aria-labelledby`. |
942
+ | `selected` | attribute / property | first enabled tab | The selected tab's `data-tab`. Unknown or disabled names fall back to the first enabled tab. |
943
+ | `orientation` | attribute | `horizontal` | `vertical` stacks the tabs and uses Up/Down. |
944
+ | `onChange` | callback | — | `(name: string) => void`, called when the user changes the tab (click, keyboard, link or hash). Not called by `select()` or `selected`. |
945
+ | `select(name)` | method | — | Selects a tab. |
946
+ | `reveal(element)` | method | — | Selects the panel containing `element`. Returns `false` if it isn't in one of this element's panels. |
947
+
948
+ <details>
949
+ <summary>CSS variables</summary>
950
+
951
+ | Variable | Default |
952
+ | --- | --- |
953
+ | `--a11y-tabs-border-width` | `1px` |
954
+ | `--a11y-tabs-color-border` | `#d1d5db` |
955
+ | `--a11y-tabs-color-disabled` | `#9ca3af` |
956
+ | `--a11y-tabs-color-focus` | `#2563eb` |
957
+ | `--a11y-tabs-color-selected` | `#2563eb` |
958
+ | `--a11y-tabs-color-text` | `#4b5563` |
959
+ | `--a11y-tabs-color-text-hover` | `#111827` |
960
+ | `--a11y-tabs-focus-outline-offset` | `2px` |
961
+ | `--a11y-tabs-focus-outline-width` | `2px` |
962
+ | `--a11y-tabs-gap` | `0.25rem` |
963
+ | `--a11y-tabs-indicator-width` | `2px` |
964
+ | `--a11y-tabs-tab-background` | `transparent` |
965
+ | `--a11y-tabs-tab-border-radius` | `0` |
966
+ | `--a11y-tabs-tab-font-size` | `1rem` |
967
+ | `--a11y-tabs-tab-font-weight` | `500` |
968
+ | `--a11y-tabs-tab-line-height` | `1.4` |
969
+ | `--a11y-tabs-tab-padding` | `0.5rem 1rem` |
970
+ | `--a11y-tabs-transition-duration` | `0.2s` |
971
+
972
+ </details>
973
+
915
974
  #### `a11y-textarea`
916
975
 
917
976
  `<a11y-input>` for a real `<textarea>`: same parts, attributes, properties, validation and states.
@@ -960,7 +1019,21 @@ No attributes or CSS variables. The class `a11y-visually-hidden` is also usable
960
1019
 
961
1020
  * **Open/close** with the `open` attribute or property, or `show()` / `close()`.
962
1021
  * **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.
963
- * **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on `document`, with `event.detail.name` set to the tag name.
1022
+ * **Events:** `a11y-overlay-open` and `a11y-overlay-close` fire on the overlay element and bubble to `document`, so you can listen on either. `event.detail` has `name` (the tag name) and `element` (the overlay). On `a11y-overlay-close`, `detail.reason` says why it closed:
1023
+
1024
+ | `reason` | Closed by |
1025
+ | --- | --- |
1026
+ | `escape` | the Escape key |
1027
+ | `backdrop` | a click on a dialog's backdrop |
1028
+ | `close-button` | a dialog's × button |
1029
+ | `outside-click` | a click outside an anchored overlay |
1030
+ | `focus-out` | focus leaving a menu |
1031
+ | `item` | activating a menu item |
1032
+ | `dismiss-all` | `dismissAllOverlays()` |
1033
+ | `removed` | removing the element while open (the event then fires on `document`) |
1034
+ | `api` | `close()`, `open = false` or removing `open` |
1035
+
1036
+ `close(reason)` also takes a reason, for your own close buttons. `<a11y-floating>` passes `element` but no `reason`.
964
1037
  * **`dismissAllOverlays()`** closes every open overlay (e.g. on navigation). It's exported from `a11y-elements/core` and from every overlay's `define.js`.
965
1038
  * **Except `<a11y-floating>`**, which is visible by default and has no `open`: `dismissAllOverlays()` only collapses its expanded panel. See [`a11y-floating`](#a11y-floating).
966
1039
  * **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.
@@ -992,14 +1065,19 @@ If the bundle loads after rendering, the same query does find it, so the result
992
1065
  * bind events on the overlay element itself, or delegate from it;
993
1066
  * put final text into the markup before injecting it, rather than in a pass after rendering.
994
1067
 
1068
+ ##### Bind overlay events yourself.
1069
+
1070
+ Framework template bindings (event directives, declarative listeners) usually run over the component's subtree after it's inserted. By then the overlay has already moved to `<body>`, so its bindings never attach. Get the overlay with `getElementById`, call `addEventListener` on it (or delegate from it) after each render, and remove the listener on unmount.
1071
+
995
1072
  <a id="dialogs"></a>
996
1073
 
997
1074
  ##### Dialogs (`<a11y-modal>`, `<a11y-drawer>`, `<a11y-emergency-dialog>`)
998
1075
 
999
1076
  They also share:
1000
1077
 
1001
- * A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`).
1078
+ * A focus trap (Tab stays inside, focus returns to the trigger on close) and a page scroll lock (`html.a11y-no-scroll`, `overflow: hidden`). If the page had a classic scrollbar, the lock also adds `html.a11y-no-scroll--gutter` (`scrollbar-gutter: stable`), so the page keeps its width while the scrollbar is gone.
1002
1079
  * Escape, a click on the backdrop, or the × close button close it, unless it's `non-dismissible`.
1080
+ * On open, focus moves to `initial-focus` if set, else to a descendant with `autofocus`, else to the first focusable element. That's the × close button when it's dismissible.
1003
1081
  * The dialog is named after its first heading (`aria-labelledby`), or `dialog-label`.
1004
1082
 
1005
1083
  | Name | Kind | Default | Description |
@@ -1007,8 +1085,9 @@ They also share:
1007
1085
  | `non-dismissible` | attribute | absent | No close button, no Escape, no backdrop click: close it from code. |
1008
1086
  | `dialog-label` | attribute | — | Accessible name (`aria-label`) when there's no heading. |
1009
1087
  | `close-label` | attribute | `Close dialog` | Accessible name of the × close button. See [Translating built-in strings](#translating-built-in-strings). |
1088
+ | `initial-focus` | attribute | — | The element to focus on open: an `id`, else a selector, looked up inside the dialog. Ignored if it's missing or can't take focus. |
1010
1089
  | `dismissible` | property (read-only) | `true` | Inverse of `non-dismissible`. |
1011
- | `onClose` | callback | — | Called once the close transition has finished. |
1090
+ | `onClose` | callback | — | Called once the close transition has finished, with the close [`reason`](#common-to-all-overlays). |
1012
1091
 
1013
1092
  <a id="anchored-overlays"></a>
1014
1093
 
@@ -1130,7 +1209,7 @@ A panel that slides in from a screen edge. Behaves like `<a11y-modal>` (see [Dia
1130
1209
  | --- | --- | --- | --- |
1131
1210
  | `edge` | attribute / property (read-only) | `right` | `left`, `right`, `top` or `bottom`. Read when the drawer opens. |
1132
1211
 
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()`.
1212
+ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `initial-focus`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
1134
1213
 
1135
1214
  <details>
1136
1215
  <summary>CSS variables</summary>
@@ -1324,9 +1403,43 @@ document.getElementById('open-settings').addEventListener('click', () => {
1324
1403
  | --- | --- | --- | --- |
1325
1404
  | `fullscreen` | attribute | absent | Fills the viewport, without the backdrop gutter. Read when the modal opens. |
1326
1405
 
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()`.
1406
+ **Size:** the dialog is as tall as its content and up to `32rem` wide, inside the backdrop's padding (`--a11y-modal-overlay-padding`). Longer content scrolls inside it. Change the size with `--a11y-modal-width`, `--a11y-modal-height`, `--a11y-modal-max-width` and `--a11y-modal-max-height`. Set `--a11y-modal-width` and `--a11y-modal-height` to `100%` to fill the padded area, as before 0.5.0. `<a11y-emergency-dialog>` is sized the same way.
1407
+
1408
+ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-label`, `close-label`, `initial-focus`, `dismissible` and `onClose`. See [Common to all overlays](#common-to-all-overlays) for `open`, `show()` / `close()`, the open/close events and `dismissAllOverlays()`.
1409
+
1410
+ `.a11y-modal-buttons` is an optional footer-row class for your own buttons. It lays them out in a row, and gives plain `<button>`s a default look (padding, font size, hover colors). Those styles have zero specificity (`:where()`), so any class on your buttons overrides them. They also sit in the `a11y-elements` cascade layer, so any CSS of yours that isn't in a layer wins. If your own styles are layered (Tailwind's `@layer utilities`, for example), declare the order first so yours win: `@layer a11y-elements, base, components, utilities;`. With `danger: true`, `confirmDialog()`'s confirm button uses `--a11y-color-danger` for its text and hover background.
1411
+
1412
+ ##### Confirmation dialogs: `confirmDialog()`
1413
+
1414
+ `confirmDialog()` asks a yes/no question in a temporary modal, and resolves `true` only when the confirm button is pressed. Every other close (Cancel, Escape, the backdrop, ×, `dismissAllOverlays()`) resolves `false`. Focus starts on Cancel, so a stray Enter doesn't confirm. The modal is removed once closed.
1415
+
1416
+ ```js
1417
+ import { confirmDialog } from 'a11y-elements/overlays/modal';
1418
+
1419
+ if (await confirmDialog({ title: 'Delete all notes?', message: 'This can’t be undone.', confirmLabel: 'Delete', danger: true })) {
1420
+ deleteAll();
1421
+ }
1422
+ ```
1423
+
1424
+ | Option | Default | Description |
1425
+ | --- | --- | --- |
1426
+ | `title` | — | The heading, which also names the dialog. |
1427
+ | `message` | — | Text under the heading. A string is text; pass a node, or `raw()` for markup. |
1428
+ | `confirmLabel` | `OK` | Confirm button text, else `setStrings({ confirm })`. |
1429
+ | `cancelLabel` | `Cancel` | Cancel button text, else `setStrings({ cancel })`. |
1430
+ | `danger` | `false` | Adds `a11y-confirm__confirm--danger` to the confirm button. |
1328
1431
 
1329
- `.a11y-modal-buttons` is an optional footer-row class for your own buttons.
1432
+ The modal has the class `a11y-confirm`. Its parts are `.a11y-confirm__title`, `.a11y-confirm__message`, and `.a11y-confirm__cancel` and `.a11y-confirm__confirm` in a `.a11y-modal-buttons` footer. Style them with your own CSS.
1433
+
1434
+ To build your own instead, set `initial-focus` on Cancel, let your buttons record the answer before calling `modal.close()`, and treat every other close as Cancel:
1435
+
1436
+ ```js
1437
+ let answer = false;
1438
+ confirmButton.addEventListener('click', () => { answer = true; modal.close(); });
1439
+ cancelButton.addEventListener('click', () => modal.close());
1440
+ modal.onClose = () => resolve(answer); // Escape, backdrop, × … leave it false
1441
+ modal.open = true;
1442
+ ```
1330
1443
 
1331
1444
  <details>
1332
1445
  <summary>CSS variables</summary>
@@ -1344,12 +1457,16 @@ Also takes the shared [dialog](#dialogs) options: `non-dismissible`, `dialog-lab
1344
1457
  | `--a11y-modal-footer-button-padding` | `0.5rem 1rem` |
1345
1458
  | `--a11y-modal-footer-gap` | `1rem` |
1346
1459
  | `--a11y-modal-footer-margin-top` | `1.5rem` |
1460
+ | `--a11y-modal-height` | `auto` |
1347
1461
  | `--a11y-modal-initial-scale` | `0.95` |
1462
+ | `--a11y-modal-max-height` | `100%` |
1463
+ | `--a11y-modal-max-width` | `100%` |
1348
1464
  | `--a11y-modal-overlay-padding` | `clamp(1rem, 10vmin, 6rem)` |
1349
1465
  | `--a11y-modal-shadow-blur` | `2px` |
1350
1466
  | `--a11y-modal-shadow-fade` | `80%` |
1351
1467
  | `--a11y-modal-shadow-offset-y` | `2px` |
1352
1468
  | `--a11y-modal-transition-duration` | `0.3s` |
1469
+ | `--a11y-modal-width` | `min(32rem, 100%)` |
1353
1470
 
1354
1471
  </details>
1355
1472
 
@@ -1388,13 +1505,13 @@ It's a page region, not an open/close overlay: it fires no open/close events and
1388
1505
 
1389
1506
  | Option | Default | Description |
1390
1507
  | --- | --- | --- |
1391
- | `type` | `info` | `info`, `success` or `error` (`error` uses `role="alert"`). |
1508
+ | `type` | `info` | `info`, `success`, `warning` or `error` (`error` uses `role="alert"`). |
1392
1509
  | `position` | `top` | `top` or `bottom`. |
1393
1510
  | `actionText` / `onAction` | — | Adds an action button; clicking it runs `onAction` and dismisses the banner. |
1394
1511
  | `onClose` | — | Called when the banner is dismissed. |
1395
1512
  | `maxStack` | — | Sets `max-stack` on the region (sticky for later banners). |
1396
1513
 
1397
- Classes: `.a11y-notification-banner--info` / `--success` / `--error`, `__message`, `__action`, `__close`.
1514
+ Classes: `.a11y-notification-banner--info` / `--success` / `--warning` / `--error`, `__message`, `__action`, `__close`.
1398
1515
 
1399
1516
  <details>
1400
1517
  <summary>CSS variables</summary>
@@ -1462,12 +1579,13 @@ Toast notifications that dismiss themselves: after 3 s by default, or 10 s when
1462
1579
 
1463
1580
  ```js
1464
1581
  import { notify } from 'a11y-elements/overlays/snackbar';
1465
- import { raw } from 'a11y-elements/core';
1582
+ import { h, raw } from 'a11y-elements/core';
1466
1583
 
1467
1584
  notify('Saved');
1468
1585
  notify('Upload failed', { type: 'error', actionText: 'Retry', onAction: retryUpload });
1469
1586
  notify('Copied to clipboard', { position: 'top', duration: 1500 });
1470
1587
  notify(raw('Saved. <a href="/files">View files</a>')); // markup: sanitized, see below
1588
+ notify(h('span', null, 'Saved. ', h('a', { href: '/files' }, 'View files'))); // nodes, no parsing at all
1471
1589
  ```
1472
1590
 
1473
1591
  | Name | Kind | Default | Description |
@@ -1478,7 +1596,7 @@ notify(raw('Saved. <a href="/files">View files</a>')); // markup: sanitized, see
1478
1596
 
1479
1597
  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
1598
 
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>`.
1599
+ A `message` is text: a string is inserted as text, never parsed. A DOM node (e.g. built with `h()` from `a11y-elements/core`) is inserted as is. 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
1600
 
1483
1601
  `notify()` options (method and convenience export):
1484
1602
 
@@ -1547,16 +1665,22 @@ Also takes the shared [anchored-overlay](#anchored-overlays) options: `anchor` /
1547
1665
 
1548
1666
  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.
1549
1667
 
1668
+ Each status color has a text color drawn on it (`--a11y-color-text-on-<type>`). Every default pair passes WCAG AA (4.5:1): success 5.13:1, info 5.75:1, error 5.62:1, warning 9.00:1. Warning is amber with dark text, since white on it is only 1.97:1. If you change a status color, check its contrast with its text color.
1669
+
1550
1670
  <details>
1551
1671
  <summary>CSS variables</summary>
1552
1672
 
1553
1673
  | Variable | Default |
1554
1674
  | --- | --- |
1555
- | `--a11y-color-success` | `rgb(76 175 80)` |
1556
- | `--a11y-color-error` | `rgb(244 67 54)` |
1557
- | `--a11y-color-info` | `rgb(33 150 243)` |
1558
- | `--a11y-color-warning` | `rgb(244 67 54)` |
1675
+ | `--a11y-color-success` | `#2e7d32` |
1676
+ | `--a11y-color-error` | `#c62828` |
1677
+ | `--a11y-color-info` | `#1565c0` |
1678
+ | `--a11y-color-warning` | `#f9a825` |
1559
1679
  | `--a11y-color-text` | `white` |
1680
+ | `--a11y-color-text-on-success` | `var(--a11y-color-text)` |
1681
+ | `--a11y-color-text-on-error` | `var(--a11y-color-text)` |
1682
+ | `--a11y-color-text-on-info` | `var(--a11y-color-text)` |
1683
+ | `--a11y-color-text-on-warning` | `#111827` |
1560
1684
  | `--a11y-z-base` | `0` |
1561
1685
  | `--a11y-z-sticky-header` | `100` |
1562
1686
  | `--a11y-z-sticky-footer` | `110` |
@@ -1614,6 +1738,65 @@ Override at `:root` (or `body`) and every instance of that component on the page
1614
1738
  }
1615
1739
  ```
1616
1740
 
1741
+ ### Theme with semantic variables
1742
+
1743
+ Every component color, and the form controls' radius and font, falls back to a global semantic variable before its shipped default:
1744
+
1745
+ ```css
1746
+ /* from input.css */
1747
+ color: var(--a11y-input-color-text, var(--a11y-color-text-default, #111827));
1748
+ ```
1749
+
1750
+ So a dozen variables theme every element, and the per-component ones still win where you set them:
1751
+
1752
+ | Variable | Default | Used for |
1753
+ | --- | --- | --- |
1754
+ | `--a11y-color-surface` | `#ffffff` | control and overlay backgrounds, text on primary or inverted surfaces |
1755
+ | `--a11y-color-surface-muted` | `#f3f4f6` | tracks, skeletons, avatar and select fills, the drop zone highlight |
1756
+ | `--a11y-color-surface-disabled` | `#e5e7eb` | disabled control backgrounds |
1757
+ | `--a11y-color-text-default` | `#111827` | text, the tooltip and floating launcher backgrounds |
1758
+ | `--a11y-color-text-muted` | `#6b7280` (`#4b5563` for hovers) | hints, secondary text, menu item and modal button hover backgrounds |
1759
+ | `--a11y-color-text-disabled` | `#9ca3af` | disabled text |
1760
+ | `--a11y-color-border` | `#d1d5db` | control borders |
1761
+ | `--a11y-color-border-strong` | `#9ca3af` | hovered borders, unchecked checkboxes and radios |
1762
+ | `--a11y-color-primary` | `#2563eb` | checked, active and focused states, links |
1763
+ | `--a11y-color-focus` | `--a11y-color-primary` | focus outlines |
1764
+ | `--a11y-color-danger` | `#b91c1c` | errors and required markers |
1765
+ | `--a11y-radius` | `4px` | input, textarea, select and file-input button radius |
1766
+ | `--a11y-font-family` | `inherit` | input, textarea and select text |
1767
+
1768
+ They aren't set anywhere by default. The defaults pass WCAG AA for text (4.5:1) in the pairs the elements use. If you change them, keep text on its surface at 4.5:1. Status colors are separate (see [Shared tokens](#shared-tokens)).
1769
+
1770
+ ### Dark mode
1771
+
1772
+ Load the opt-in dark theme after `a11y.css`:
1773
+
1774
+ ```html
1775
+ <link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y.css" />
1776
+ <link rel="stylesheet" href="node_modules/a11y-elements/dist/a11y-dark.css" />
1777
+ ```
1778
+
1779
+ ```js
1780
+ import 'a11y-elements/a11y.css';
1781
+ import 'a11y-elements/a11y-dark.css';
1782
+ ```
1783
+
1784
+ It redefines only the semantic variables above and sets `color-scheme: dark`, so native parts (scrollbars, `<select>` popups) follow. It applies under `prefers-color-scheme: dark`. `data-theme="dark"` or `data-theme="light"` on `<html>` forces a theme. Status colors keep their values: they pass AA with their text in both themes.
1785
+
1786
+ To use your own palette instead, set the semantic variables yourself under your dark selector:
1787
+
1788
+ ```css
1789
+ @media (prefers-color-scheme: dark) {
1790
+ :root {
1791
+ --a11y-color-surface: var(--my-surface);
1792
+ --a11y-color-text-default: var(--my-text);
1793
+ /* … */
1794
+ }
1795
+ }
1796
+ ```
1797
+
1798
+ Set them on `:root`, not on a dark-themed wrapper: overlays move to `<body>`, out of the wrapper (see below).
1799
+
1617
1800
  ### Scope to one instance
1618
1801
 
1619
1802
  The same custom properties follow ordinary CSS cascade/inheritance, so you can target just one element instead. Two equivalent ways to do it:
@@ -1634,10 +1817,19 @@ The same custom properties follow ordinary CSS cascade/inheritance, so you can t
1634
1817
 
1635
1818
  Either way, only that element changes — every other `<a11y-spinner>` on the page keeps its default (or globally-rethemed) look.
1636
1819
 
1820
+ **Overlays are the exception for ancestors:** they move to `<body>` when connected, so variables set on a wrapper around one (`.dark-section { --a11y-modal-color-background: … }`) no longer reach it. Set overlay variables on `:root` / `body`, or on the overlay element itself (an inline style or a class on `<a11y-modal>`).
1821
+
1637
1822
  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.
1638
1823
 
1639
1824
  The full list of tokens, with their defaults, is in the shipped `dist/a11y.css` — search it for `--a11y-<component>-`.
1640
1825
 
1826
+ ## Testing
1827
+
1828
+ * **Elements exist only once their `define` entry is imported.** In a test that doesn't import it, an `<a11y-checkbox>` stays a plain unknown element. Read its attributes (`label`, …), and don't expect overlays to move to `<body>`, build their chrome or fire their events.
1829
+ * **The elements run under jsdom** once defined. This library's own suite does, with a small polyfill for `ElementInternals` validity (`setValidity()`, `validity`), which jsdom lacks and the form fields use. Expect no layout: positioning and transitions resolve immediately.
1830
+ * **Stub `notify()`** through your own wrapper (a service that calls it), and replace the wrapper in tests.
1831
+ * **Simulate a user closing an overlay:** with the element defined, call `close('escape')` (or `'backdrop'`, …): it fires `a11y-overlay-close` and `onClose` with that reason. Without it, set `open = false` and dispatch the event yourself: `document.dispatchEvent(new CustomEvent('a11y-overlay-close', { detail: { name: 'a11y-modal', element: modal, reason: 'escape' } }))`.
1832
+
1641
1833
  ## License
1642
1834
 
1643
1835
  MIT — see [`LICENSE.txt`](./LICENSE.txt).
@@ -0,0 +1,31 @@
1
+ /* src/a11y-dark.css */
2
+ @media (prefers-color-scheme: dark) {
3
+ :root:not([data-theme=light]) {
4
+ color-scheme: dark;
5
+ --a11y-color-surface: #1f2937;
6
+ --a11y-color-surface-muted: #374151;
7
+ --a11y-color-surface-disabled: #374151;
8
+ --a11y-color-text-default: #f9fafb;
9
+ --a11y-color-text-muted: #9ca3af;
10
+ --a11y-color-text-disabled: #6b7280;
11
+ --a11y-color-border: #4b5563;
12
+ --a11y-color-border-strong: #6b7280;
13
+ --a11y-color-primary: #60a5fa;
14
+ --a11y-color-focus: #93c5fd;
15
+ --a11y-color-danger: #f87171;
16
+ }
17
+ }
18
+ :root[data-theme=dark] {
19
+ color-scheme: dark;
20
+ --a11y-color-surface: #1f2937;
21
+ --a11y-color-surface-muted: #374151;
22
+ --a11y-color-surface-disabled: #374151;
23
+ --a11y-color-text-default: #f9fafb;
24
+ --a11y-color-text-muted: #9ca3af;
25
+ --a11y-color-text-disabled: #6b7280;
26
+ --a11y-color-border: #4b5563;
27
+ --a11y-color-border-strong: #6b7280;
28
+ --a11y-color-primary: #60a5fa;
29
+ --a11y-color-focus: #93c5fd;
30
+ --a11y-color-danger: #f87171;
31
+ }