@webtides/element-library 0.3.1 → 0.5.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 (252) hide show
  1. package/CHANGELOG.md +300 -0
  2. package/README.md +72 -56
  3. package/all.js +16 -0
  4. package/catalog.js +17 -1
  5. package/custom-elements.json +15912 -10065
  6. package/package.json +1 -1
  7. package/src/components/accordion/accordion.changelog.md +11 -0
  8. package/src/components/accordion/accordion.js +15 -3
  9. package/src/components/accordion/accordion.readme.md +27 -1
  10. package/src/components/accordion/accordion.style.js +19 -0
  11. package/src/components/app-bar/app-bar.changelog.md +24 -0
  12. package/src/components/app-bar/app-bar.define.js +3 -0
  13. package/src/components/app-bar/app-bar.js +91 -0
  14. package/src/components/app-bar/app-bar.readme.md +130 -0
  15. package/src/components/app-bar/app-bar.style.js +103 -0
  16. package/src/components/app-frame/app-frame.changelog.md +59 -0
  17. package/src/components/app-frame/app-frame.define.js +3 -0
  18. package/src/components/app-frame/app-frame.events.js +6 -0
  19. package/src/components/app-frame/app-frame.js +1085 -0
  20. package/src/components/app-frame/app-frame.readme.md +425 -0
  21. package/src/components/app-frame/app-frame.style.js +534 -0
  22. package/src/components/button/button.changelog.md +21 -0
  23. package/src/components/button/button.events.js +3 -0
  24. package/src/components/button/button.js +145 -3
  25. package/src/components/button/button.readme.md +72 -4
  26. package/src/components/button/button.style.js +167 -8
  27. package/src/components/button-group/button-group.changelog.md +10 -0
  28. package/src/components/button-group/button-group.readme.md +2 -0
  29. package/src/components/button-group/button-group.style.js +6 -2
  30. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +6 -0
  31. package/src/components/checkbox-group-field/checkbox-group-field.js +7 -2
  32. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +23 -1
  33. package/src/components/combobox-field/combobox-field.changelog.md +6 -0
  34. package/src/components/combobox-field/combobox-field.readme.md +8 -0
  35. package/src/components/combobox-field/combobox-field.style.js +2 -0
  36. package/src/components/date-field/date-field.changelog.md +6 -0
  37. package/src/components/date-field/date-field.readme.md +10 -0
  38. package/src/components/date-field/date-field.style.js +8 -3
  39. package/src/components/description-list/description-list.changelog.md +42 -0
  40. package/src/components/description-list/description-list.define.js +3 -0
  41. package/src/components/description-list/description-list.js +49 -0
  42. package/src/components/description-list/description-list.readme.md +161 -0
  43. package/src/components/description-list/description-list.style.js +169 -0
  44. package/src/components/dialog/dialog.changelog.md +7 -0
  45. package/src/components/dialog/dialog.readme.md +5 -0
  46. package/src/components/dialog/dialog.style.js +17 -2
  47. package/src/components/divider/divider.changelog.md +6 -0
  48. package/src/components/divider/divider.readme.md +1 -1
  49. package/src/components/divider/divider.style.js +6 -0
  50. package/src/components/drawer/drawer.changelog.md +7 -0
  51. package/src/components/drawer/drawer.readme.md +7 -6
  52. package/src/components/drawer/drawer.style.js +35 -2
  53. package/src/components/dropdown/dropdown.readme.md +6 -1
  54. package/src/components/file-field/file-field.changelog.md +8 -0
  55. package/src/components/file-field/file-field.js +135 -5
  56. package/src/components/file-field/file-field.readme.md +35 -6
  57. package/src/components/file-field/file-field.style.js +71 -0
  58. package/src/components/form-field/form-field.js +1 -1
  59. package/src/components/input-field/input-field.changelog.md +10 -0
  60. package/src/components/input-field/input-field.js +192 -14
  61. package/src/components/input-field/input-field.readme.md +88 -2
  62. package/src/components/input-field/input-field.style.js +2 -0
  63. package/src/components/list/list.changelog.md +30 -0
  64. package/src/components/list/list.define.js +3 -0
  65. package/src/components/list/list.js +68 -0
  66. package/src/components/list/list.readme.md +123 -0
  67. package/src/components/list/list.style.js +56 -0
  68. package/src/components/list-item/list-item.changelog.md +40 -0
  69. package/src/components/list-item/list-item.define.js +3 -0
  70. package/src/components/list-item/list-item.js +130 -0
  71. package/src/components/list-item/list-item.readme.md +144 -0
  72. package/src/components/list-item/list-item.style.js +246 -0
  73. package/src/components/menu/menu.changelog.md +44 -0
  74. package/src/components/menu/menu.define.js +3 -0
  75. package/src/components/menu/menu.events.js +5 -0
  76. package/src/components/menu/menu.js +793 -0
  77. package/src/components/menu/menu.readme.md +313 -0
  78. package/src/components/menu/menu.style.js +59 -0
  79. package/src/components/menu-group/menu-group.changelog.md +20 -0
  80. package/src/components/menu-group/menu-group.define.js +3 -0
  81. package/src/components/menu-group/menu-group.js +44 -0
  82. package/src/components/menu-group/menu-group.readme.md +74 -0
  83. package/src/components/menu-group/menu-group.style.js +38 -0
  84. package/src/components/menu-item/menu-item.changelog.md +32 -0
  85. package/src/components/menu-item/menu-item.define.js +3 -0
  86. package/src/components/menu-item/menu-item.js +168 -0
  87. package/src/components/menu-item/menu-item.readme.md +132 -0
  88. package/src/components/menu-item/menu-item.style.js +117 -0
  89. package/src/components/nav/nav.changelog.md +35 -0
  90. package/src/components/nav/nav.define.js +3 -0
  91. package/src/components/nav/nav.js +212 -0
  92. package/src/components/nav/nav.readme.md +248 -0
  93. package/src/components/nav/nav.style.js +269 -0
  94. package/src/components/nav-item/nav-item.changelog.md +25 -0
  95. package/src/components/nav-item/nav-item.define.js +3 -0
  96. package/src/components/nav-item/nav-item.js +75 -0
  97. package/src/components/nav-item/nav-item.readme.md +111 -0
  98. package/src/components/nav-item/nav-item.style.js +159 -0
  99. package/src/components/otp-field/otp-field.changelog.md +6 -0
  100. package/src/components/otp-field/otp-field.readme.md +8 -0
  101. package/src/components/otp-field/otp-field.style.js +8 -3
  102. package/src/components/pagination/pagination.changelog.md +8 -0
  103. package/src/components/pagination/pagination.js +123 -49
  104. package/src/components/pagination/pagination.readme.md +24 -6
  105. package/src/components/pagination/pagination.style.js +11 -1
  106. package/src/components/password-field/password-field.changelog.md +7 -0
  107. package/src/components/password-field/password-field.readme.md +11 -1
  108. package/src/components/password-field/password-field.style.js +2 -0
  109. package/src/components/popover/popover.changelog.md +6 -0
  110. package/src/components/popover/popover.style.js +1 -0
  111. package/src/components/radio-field/radio-field.changelog.md +6 -0
  112. package/src/components/radio-field/radio-field.js +7 -2
  113. package/src/components/radio-field/radio-field.readme.md +23 -1
  114. package/src/components/scroll-to-top/scroll-to-top.changelog.md +7 -5
  115. package/src/components/scroll-to-top/scroll-to-top.js +16 -12
  116. package/src/components/scroll-to-top/scroll-to-top.readme.md +2 -0
  117. package/src/components/segmented-field/segmented-field.changelog.md +27 -0
  118. package/src/components/segmented-field/segmented-field.define.js +3 -0
  119. package/src/components/segmented-field/segmented-field.js +175 -0
  120. package/src/components/segmented-field/segmented-field.readme.md +140 -0
  121. package/src/components/segmented-field/segmented-field.style.js +193 -0
  122. package/src/components/splitter/splitter.changelog.md +24 -0
  123. package/src/components/splitter/splitter.define.js +3 -0
  124. package/src/components/splitter/splitter.events.js +4 -0
  125. package/src/components/splitter/splitter.js +237 -0
  126. package/src/components/splitter/splitter.readme.md +164 -0
  127. package/src/components/splitter/splitter.style.js +100 -0
  128. package/src/components/status-bar/status-bar.changelog.md +25 -0
  129. package/src/components/status-bar/status-bar.define.js +3 -0
  130. package/src/components/status-bar/status-bar.js +74 -0
  131. package/src/components/status-bar/status-bar.readme.md +139 -0
  132. package/src/components/status-bar/status-bar.style.js +122 -0
  133. package/src/components/tab-group/tab-group.changelog.md +7 -0
  134. package/src/components/tab-group/tab-group.js +30 -9
  135. package/src/components/tab-group/tab-group.readme.md +14 -0
  136. package/src/components/textarea-field/textarea-field.changelog.md +6 -0
  137. package/src/components/textarea-field/textarea-field.js +14 -1
  138. package/src/components/textarea-field/textarea-field.readme.md +23 -1
  139. package/src/components/toast/toast.changelog.md +6 -0
  140. package/src/components/toast/toast.readme.md +5 -3
  141. package/src/components/toast/toast.style.js +22 -6
  142. package/src/components/toolbar/toolbar.changelog.md +24 -0
  143. package/src/components/toolbar/toolbar.define.js +3 -0
  144. package/src/components/toolbar/toolbar.js +233 -0
  145. package/src/components/toolbar/toolbar.readme.md +156 -0
  146. package/src/components/toolbar/toolbar.style.js +49 -0
  147. package/src/components/tooltip/tooltip.changelog.md +11 -0
  148. package/src/components/tooltip/tooltip.js +51 -4
  149. package/src/components/tooltip/tooltip.readme.md +26 -1
  150. package/src/components/tree/tree.changelog.md +23 -0
  151. package/src/components/tree/tree.define.js +3 -0
  152. package/src/components/tree/tree.js +138 -0
  153. package/src/components/tree/tree.readme.md +119 -0
  154. package/src/components/tree/tree.style.js +16 -0
  155. package/src/components/tree-item/tree-item.changelog.md +23 -0
  156. package/src/components/tree-item/tree-item.define.js +3 -0
  157. package/src/components/tree-item/tree-item.events.js +3 -0
  158. package/src/components/tree-item/tree-item.js +246 -0
  159. package/src/components/tree-item/tree-item.readme.md +128 -0
  160. package/src/components/tree-item/tree-item.style.js +226 -0
  161. package/src/styles/appearance.style.js +47 -0
  162. package/src/styles/choice-group.style.js +27 -1
  163. package/src/styles/input-control.style.js +87 -0
  164. package/src/styles/modal.style.js +14 -1
  165. package/src/styles/native.css +100 -0
  166. package/src/styles/size.style.js +41 -0
  167. package/src/utils/floating.js +15 -1
  168. package/src/utils/focus.js +69 -0
  169. package/src/utils/options.js +35 -0
  170. package/src/utils/scroll.js +24 -0
  171. package/src/utils/text-entry-attributes.js +13 -0
  172. package/types/all.d.ts +16 -0
  173. package/types/src/components/accordion/accordion.d.ts +3 -1
  174. package/types/src/components/app-bar/app-bar.d.ts +43 -0
  175. package/types/src/components/app-bar/app-bar.define.d.ts +1 -0
  176. package/types/src/components/app-bar/app-bar.style.d.ts +2 -0
  177. package/types/src/components/app-frame/app-frame.d.ts +497 -0
  178. package/types/src/components/app-frame/app-frame.define.d.ts +1 -0
  179. package/types/src/components/app-frame/app-frame.events.d.ts +7 -0
  180. package/types/src/components/app-frame/app-frame.style.d.ts +8 -0
  181. package/types/src/components/button/button.d.ts +61 -0
  182. package/types/src/components/button/button.events.d.ts +4 -0
  183. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +5 -2
  184. package/types/src/components/combobox-field/combobox-field.d.ts +10 -0
  185. package/types/src/components/date-field/date-field.d.ts +10 -0
  186. package/types/src/components/description-list/description-list.d.ts +34 -0
  187. package/types/src/components/description-list/description-list.define.d.ts +1 -0
  188. package/types/src/components/description-list/description-list.style.d.ts +2 -0
  189. package/types/src/components/file-field/file-field.d.ts +68 -3
  190. package/types/src/components/form-field/form-field.d.ts +1 -1
  191. package/types/src/components/input-field/input-field.d.ts +99 -0
  192. package/types/src/components/list/list.d.ts +41 -0
  193. package/types/src/components/list/list.define.d.ts +1 -0
  194. package/types/src/components/list/list.style.d.ts +2 -0
  195. package/types/src/components/list-item/list-item.d.ts +64 -0
  196. package/types/src/components/list-item/list-item.define.d.ts +1 -0
  197. package/types/src/components/list-item/list-item.style.d.ts +2 -0
  198. package/types/src/components/menu/menu.d.ts +362 -0
  199. package/types/src/components/menu/menu.define.d.ts +1 -0
  200. package/types/src/components/menu/menu.events.d.ts +6 -0
  201. package/types/src/components/menu/menu.style.d.ts +2 -0
  202. package/types/src/components/menu-group/menu-group.d.ts +24 -0
  203. package/types/src/components/menu-group/menu-group.define.d.ts +1 -0
  204. package/types/src/components/menu-group/menu-group.style.d.ts +2 -0
  205. package/types/src/components/menu-item/menu-item.d.ts +80 -0
  206. package/types/src/components/menu-item/menu-item.define.d.ts +1 -0
  207. package/types/src/components/menu-item/menu-item.style.d.ts +2 -0
  208. package/types/src/components/nav/nav.d.ts +103 -0
  209. package/types/src/components/nav/nav.define.d.ts +1 -0
  210. package/types/src/components/nav/nav.style.d.ts +2 -0
  211. package/types/src/components/nav-item/nav-item.d.ts +39 -0
  212. package/types/src/components/nav-item/nav-item.define.d.ts +1 -0
  213. package/types/src/components/nav-item/nav-item.style.d.ts +2 -0
  214. package/types/src/components/otp-field/otp-field.d.ts +10 -0
  215. package/types/src/components/pagination/pagination.d.ts +31 -2
  216. package/types/src/components/password-field/password-field.d.ts +10 -0
  217. package/types/src/components/radio-field/radio-field.d.ts +5 -2
  218. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +6 -5
  219. package/types/src/components/segmented-field/segmented-field.d.ts +85 -0
  220. package/types/src/components/segmented-field/segmented-field.define.d.ts +1 -0
  221. package/types/src/components/segmented-field/segmented-field.style.d.ts +2 -0
  222. package/types/src/components/splitter/splitter.d.ts +127 -0
  223. package/types/src/components/splitter/splitter.define.d.ts +1 -0
  224. package/types/src/components/splitter/splitter.events.d.ts +5 -0
  225. package/types/src/components/splitter/splitter.style.d.ts +2 -0
  226. package/types/src/components/status-bar/status-bar.d.ts +44 -0
  227. package/types/src/components/status-bar/status-bar.define.d.ts +1 -0
  228. package/types/src/components/status-bar/status-bar.style.d.ts +2 -0
  229. package/types/src/components/tab-group/tab-group.d.ts +17 -0
  230. package/types/src/components/textarea-field/textarea-field.d.ts +7 -0
  231. package/types/src/components/toolbar/toolbar.d.ts +96 -0
  232. package/types/src/components/toolbar/toolbar.define.d.ts +1 -0
  233. package/types/src/components/toolbar/toolbar.style.d.ts +2 -0
  234. package/types/src/components/tooltip/tooltip.d.ts +26 -0
  235. package/types/src/components/tree/tree.d.ts +62 -0
  236. package/types/src/components/tree/tree.define.d.ts +1 -0
  237. package/types/src/components/tree/tree.style.d.ts +2 -0
  238. package/types/src/components/tree-item/tree-item.d.ts +106 -0
  239. package/types/src/components/tree-item/tree-item.define.d.ts +1 -0
  240. package/types/src/components/tree-item/tree-item.events.d.ts +4 -0
  241. package/types/src/components/tree-item/tree-item.style.d.ts +2 -0
  242. package/types/src/styles/appearance.style.d.ts +31 -0
  243. package/types/src/styles/choice-group.style.d.ts +1 -1
  244. package/types/src/styles/input-control.style.d.ts +15 -0
  245. package/types/src/styles/modal.style.d.ts +5 -0
  246. package/types/src/styles/size.style.d.ts +24 -0
  247. package/types/src/utils/floating.d.ts +11 -0
  248. package/types/src/utils/focus.d.ts +25 -0
  249. package/types/src/utils/options.d.ts +17 -0
  250. package/types/src/utils/scroll.d.ts +11 -0
  251. package/types/src/utils/text-entry-attributes.d.ts +10 -0
  252. package/web-types.json +2935 -308
@@ -1,5 +1,6 @@
1
1
  import { TemplateElement, defineElement, html, classMap, spreadAttributes } from '@webtides/element-js';
2
2
  import style from './button.style.js';
3
+ import Events from './button.events.js';
3
4
 
4
5
  /**
5
6
  * The ARIA attributes of the element that its control takes over. The control is what has the
@@ -54,8 +55,18 @@ const SUBMITTER_ATTRIBUTES = ['form', 'formaction', 'formenctype', 'formmethod',
54
55
  * what they do on a native button. A `click` listener of the page that calls `preventDefault()`
55
56
  * keeps the button from submitting or resetting.
56
57
  *
58
+ * In a container that gives its controls a size and an appearance, an `el-toolbar`, the button
59
+ * takes them from it, while the page has not set `size` or `appearance` on the button itself.
60
+ *
61
+ * With `toggle` the button stays pressed: a click flips `pressed`, the control says so to assistive
62
+ * technology (`aria-pressed`), and the button shows it. A `click` listener of the page that calls
63
+ * `preventDefault()` keeps the button from flipping, as it keeps it from submitting.
64
+ *
57
65
  * @element el-button
58
66
  *
67
+ * @fires {CustomEvent<{ pressed: boolean }>} button-toggle - Fired when a click has flipped a
68
+ * toggle button. `detail.pressed` is the new state. Not fired when `pressed` is set from a script.
69
+ *
59
70
  * @slot - The button's label.
60
71
  * @slot prefix - A presentational prefix icon or similar element.
61
72
  * @slot suffix - A presentational suffix icon or similar element.
@@ -80,6 +91,10 @@ const SUBMITTER_ATTRIBUTES = ['form', 'formaction', 'formenctype', 'formmethod',
80
91
  * @property {boolean} loading - Shows a spinner and blocks interaction.
81
92
  * @property {boolean} disabled - Disables the button. Reflected to the `disabled` attribute, which is
82
93
  * there while the button is disabled and gone while it is not.
94
+ * @property {boolean} toggle - The button is a toggle button: it stays pressed. A click flips
95
+ * `pressed`, and the control has `aria-pressed`. Ignored when `href` is set. Default `false`.
96
+ * @property {boolean} pressed - Whether a toggle button is pressed. Reflected to the `pressed`
97
+ * attribute of a toggle button. Without `toggle` it does nothing. Default `false`.
83
98
  * @property {'button'|'submit'|'reset'} type - Behaviour when activated. `submit` / `reset` act on
84
99
  * the form of the button: the nearest ancestor `<form>`, or the one its `form` attribute names.
85
100
  * Ignored when `href` is set. Default `'button'`.
@@ -99,7 +114,14 @@ export default class Button extends TemplateElement {
99
114
  static formAssociated = true;
100
115
 
101
116
  static get observedAttributes() {
102
- return [...ARIA_ATTRIBUTES, ...Object.keys(ARIA_RELATIONS), ...SUBMITTER_ATTRIBUTES, 'disabled'];
117
+ return [
118
+ ...ARIA_ATTRIBUTES,
119
+ ...Object.keys(ARIA_RELATIONS),
120
+ ...SUBMITTER_ATTRIBUTES,
121
+ 'disabled',
122
+ 'size',
123
+ 'appearance',
124
+ ];
103
125
  }
104
126
 
105
127
  /**
@@ -116,6 +138,19 @@ export default class Button extends TemplateElement {
116
138
  */
117
139
  _keydownRoot = undefined;
118
140
 
141
+ /**
142
+ * Which of `size` and `appearance` the page has set on the button itself, see `_isOwn()`.
143
+ * @private
144
+ * @type {Set<string> | undefined}
145
+ */
146
+ _ownLook = undefined;
147
+
148
+ /**
149
+ * Whether the button is writing a property to its attribute right now, see `reflectProperty()`.
150
+ * @private
151
+ */
152
+ _reflecting = false;
153
+
119
154
  constructor() {
120
155
  super({
121
156
  styles: [style],
@@ -130,6 +165,8 @@ export default class Button extends TemplateElement {
130
165
  size: { reflect: true },
131
166
  // For the platform the attribute is what disables the element, see `reflectProperty()`.
132
167
  disabled: { reflect: true },
168
+ // The attribute of a toggle button says whether it is pressed, see `reflectProperty()`.
169
+ pressed: { reflect: true },
133
170
  // What a form submits is text. element-js parses every attribute, so that text which
134
171
  // reads as a number arrives as one: "1.50" as 1.5.
135
172
  name: { parse: false },
@@ -148,6 +185,8 @@ export default class Button extends TemplateElement {
148
185
  caret: false,
149
186
  loading: false,
150
187
  disabled: false,
188
+ toggle: false,
189
+ pressed: false,
151
190
  type: 'button',
152
191
  name: '',
153
192
  value: '',
@@ -158,11 +197,58 @@ export default class Button extends TemplateElement {
158
197
  };
159
198
  }
160
199
 
200
+ connectedCallback() {
201
+ // Before element-js writes the defaults onto the element: after that, every button has a
202
+ // `size` and an `appearance` attribute, and nothing says who wrote them. A framework may
203
+ // have set them as properties before the element was connected.
204
+ this._ownLook ??= new Set(
205
+ ['size', 'appearance'].filter((name) => this.hasAttribute(name) || Object.hasOwn(this, name)),
206
+ );
207
+ super.connectedCallback();
208
+ }
209
+
210
+ /**
211
+ * Whether the page has given the button a `size` or an `appearance` of its own. A button
212
+ * without one takes it from a container that gives one to its controls, a toolbar. The
213
+ * template marks the control with the answer, and the stylesheet reads the mark.
214
+ *
215
+ * On the server no attribute has been written by the element: the ones that are there are
216
+ * the ones of the page.
217
+ * @private
218
+ * @param {'size' | 'appearance'} name
219
+ * @returns {boolean}
220
+ */
221
+ _isOwn(name) {
222
+ if (!this._ownLook) return !!this.hasAttribute?.(name);
223
+ // A value that is not the default was set by someone: the watcher has not run yet when the
224
+ // button renders with a value it has just got from a script.
225
+ return this._ownLook.has(name) || this[name] !== this.properties()[name];
226
+ }
227
+
161
228
  /** Whether the button renders as a link rather than a native button. */
162
229
  get isLink() {
163
230
  return !!this.href;
164
231
  }
165
232
 
233
+ /**
234
+ * Whether the button is a toggle button: one that stays pressed. A link leads somewhere, it
235
+ * has no state to stay in.
236
+ */
237
+ get isToggle() {
238
+ return !!this.toggle && !this.isLink;
239
+ }
240
+
241
+ watch() {
242
+ return {
243
+ // A button that becomes a toggle gets the attribute of its state.
244
+ toggle: () => this.reflectProperty({ property: 'pressed', newValue: this.pressed }),
245
+ // A size or an appearance that is set later, as an attribute or from a script, is the
246
+ // button's own from then on.
247
+ size: () => this._ownLook?.add('size'),
248
+ appearance: () => this._ownLook?.add('appearance'),
249
+ };
250
+ }
251
+
166
252
  /**
167
253
  * An ARIA attribute of the element, or one it shares with a native submit button, was set,
168
254
  * changed or removed. They are no properties of the component: the template and the submit
@@ -179,6 +265,16 @@ export default class Button extends TemplateElement {
179
265
  if (newValue === 'false' || newValue === '') this.removeAttribute('disabled');
180
266
  return;
181
267
  }
268
+ if (name === 'size' || name === 'appearance') {
269
+ // The page has written the attribute, after the button was connected: the size or the
270
+ // appearance is the button's own from now on, also when it is the default. The button
271
+ // writes the two itself as well, which says nothing.
272
+ if (this._ownLook && !this._reflecting && newValue !== null && !this._ownLook.has(name)) {
273
+ this._ownLook.add(name);
274
+ if (this.$refs?.control) this.requestUpdate();
275
+ }
276
+ return;
277
+ }
182
278
  if (oldValue !== newValue && this.$refs?.control) this.requestUpdate();
183
279
  }
184
280
 
@@ -196,8 +292,18 @@ export default class Button extends TemplateElement {
196
292
  * @param {{ property: string, newValue: unknown }} options
197
293
  */
198
294
  reflectProperty(options) {
295
+ if (options.property === 'pressed') {
296
+ this._reflectPressed(options.newValue);
297
+ return;
298
+ }
199
299
  if (options.property !== 'disabled') {
200
- super.reflectProperty(options);
300
+ // `attributeChangedCallback()` runs before `setAttribute()` returns.
301
+ this._reflecting = true;
302
+ try {
303
+ super.reflectProperty(options);
304
+ } finally {
305
+ this._reflecting = false;
306
+ }
201
307
  return;
202
308
  }
203
309
  if (!options.newValue) this.removeAttribute('disabled');
@@ -206,6 +312,24 @@ export default class Button extends TemplateElement {
206
312
  if (options.newValue === null) this.disabled = false;
207
313
  }
208
314
 
315
+ /**
316
+ * `pressed` is the attribute of a toggle button: `"true"` or `"false"`, so that the page can
317
+ * read the state and select by it. On a button that is no toggle the attribute says nothing,
318
+ * and the element does not write it there.
319
+ * @private
320
+ * @param {unknown} pressed
321
+ */
322
+ _reflectPressed(pressed) {
323
+ // element-js reads an attribute that is gone as `null`. The property stays a boolean.
324
+ if (pressed === null || pressed === undefined || pressed === '') {
325
+ this.pressed = false;
326
+ return;
327
+ }
328
+ if (!this.isToggle) return;
329
+ const text = pressed ? 'true' : 'false';
330
+ if (this.getAttribute('pressed') !== text) this.setAttribute('pressed', text);
331
+ }
332
+
209
333
  afterUpdate() {
210
334
  this._syncAriaRelations();
211
335
  this._syncSubmitter();
@@ -270,6 +394,14 @@ export default class Button extends TemplateElement {
270
394
  return;
271
395
  }
272
396
  if (this.isLink) return;
397
+ // A toggle flips once the page has had the click, and not when a listener has
398
+ // prevented it: as a native checkbox takes its check mark back then.
399
+ if (this.isToggle) {
400
+ this._afterListeners(event, () => {
401
+ this.pressed = !this.pressed;
402
+ this.dispatch(Events.TOGGLE, { pressed: this.pressed });
403
+ });
404
+ }
273
405
  // The control is in the shadow root, where it has no form. A submit goes through
274
406
  // the native submit button of the element, a reset to the form of the element.
275
407
  // Both are taken here, while the button is not disabled, and act once the page
@@ -391,7 +523,13 @@ export default class Button extends TemplateElement {
391
523
  * @returns {Object<string, string | undefined>}
392
524
  */
393
525
  _ariaAttributes() {
394
- return Object.fromEntries(ARIA_ATTRIBUTES.map((name) => [name, this.getAttribute(name) || undefined]));
526
+ const attributes = Object.fromEntries(
527
+ ARIA_ATTRIBUTES.map((name) => [name, this.getAttribute(name) || undefined]),
528
+ );
529
+ // The state of a toggle button is its own. Without `toggle` the `aria-pressed` of the page
530
+ // goes through as it is, and a button that has neither has no `aria-pressed`.
531
+ if (this.isToggle) attributes['aria-pressed'] = this.pressed ? 'true' : 'false';
532
+ return attributes;
395
533
  }
396
534
 
397
535
  /**
@@ -432,6 +570,8 @@ export default class Button extends TemplateElement {
432
570
  'button--circle': !!this.circle,
433
571
  'button--loading': !!this.loading,
434
572
  'button--caret': !!this.caret,
573
+ 'button--inherit-size': !this._isOwn('size'),
574
+ 'button--inherit-appearance': !this._isOwn('appearance'),
435
575
  };
436
576
  const disabled = this._isDisabled();
437
577
 
@@ -481,3 +621,5 @@ export default class Button extends TemplateElement {
481
621
  export function define() {
482
622
  defineElement('el-button', Button);
483
623
  }
624
+
625
+ export { Events };
@@ -51,6 +51,8 @@ import '@webtides/element-library/button/define';
51
51
  | `caret` | `boolean` | `false` | Appends a dropdown caret after the label. |
52
52
  | `loading` | `boolean` | `false` | Shows a spinner and blocks interaction. |
53
53
  | `disabled` | `boolean` | `false` | Disables the button. Reflected: the attribute is there while the button is disabled, see [In a form](#in-a-form). |
54
+ | `toggle` | `boolean` | `false` | The button is a toggle button: a click flips `pressed`, see [A toggle button](#a-toggle-button). Button-only. |
55
+ | `pressed` | `boolean` | `false` | Whether a toggle button is pressed. Reflected on a toggle button (`pressed="true"` / `"false"`). Without `toggle` it does nothing. |
54
56
  | `type` | `string` | `'button'` | `button`, `submit` or `reset`. `submit` / `reset` act on the form of the button, see [In a form](#in-a-form). Button-only. |
55
57
  | `name` | `string` | `''` | Name submitted with the form, when the form is submitted with this button. Button-only. |
56
58
  | `value` | `string` | `''` | Value submitted under that name. Button-only. |
@@ -71,7 +73,11 @@ The attributes `form`, `formaction`, `formenctype`, `formmethod`, `formnovalidat
71
73
 
72
74
  #### Events
73
75
 
74
- _None custom — native `click`, `focus` and `blur` behave as usual._
76
+ | Name | Detail | Description |
77
+ | --- | --- | --- |
78
+ | `button-toggle` | `{ pressed: boolean }` | Fired when a click has flipped a toggle button. `detail.pressed` is the new state. Not fired when `pressed` is set from a script. |
79
+
80
+ Native `click`, `focus` and `blur` behave as usual.
75
81
 
76
82
  #### Slots
77
83
 
@@ -122,6 +128,68 @@ The three properties are independent of each other, and every combination works.
122
128
 
123
129
  The `hidden` attribute hides the button.
124
130
 
131
+ ## In a toolbar
132
+
133
+ An [`el-toolbar`](../toolbar/toolbar.readme.md) gives its controls one size and one appearance. A button takes them from the toolbar while the page has not set `size` or `appearance` on the button itself:
134
+
135
+ ```html
136
+ <el-toolbar label="Message" size="small" appearance="outlined">
137
+ <el-button>Reply</el-button>
138
+ <!-- small, outlined -->
139
+ <el-button size="large">Archive</el-button>
140
+ <!-- large, outlined -->
141
+ <el-button variant="brand" appearance="filled">Send</el-button>
142
+ <!-- small, filled -->
143
+ </el-toolbar>
144
+ ```
145
+
146
+ - A button that names its own keeps it, also when that is the default: `appearance="filled"`, `size="medium"`. It counts as named when the page wrote the attribute, when a script set the property before the button was connected, or when either changes later.
147
+ - The toolbar does not write to the button. It says its size and its appearance in CSS properties that are inherited, and the button reads them in its stylesheet. The `size` and `appearance` attributes of the button keep their own values, `medium` and `filled` for a button that names none.
148
+ - It works at any depth: for a button in an `el-button-group` of the toolbar, and for the anchor of an `el-popover`.
149
+ - Outside of a toolbar nothing changes.
150
+
151
+ ## In the frame of an application
152
+
153
+ A button with `data-navigation-toggle` opens the navigation of an [`el-app-frame`](../app-frame/app-frame.readme.md) where the frame is narrow and the navigation is a drawer. Where the navigation is a column beside the content, there is nothing to open, and the button is not there. The frame says so in a CSS property that is inherited, and the button reads it in its own stylesheet: that holds before any script has run. Outside of a frame the attribute changes nothing.
154
+
155
+ ```html
156
+ <el-button data-navigation-toggle circle="true" aria-label="Navigation"><svg aria-hidden="true">…</svg></el-button>
157
+ ```
158
+
159
+ In an [`el-status-bar`](../status-bar/status-bar.readme.md) a button is as high as the bar and plain, and has its small text. Its focus ring is inside of it there: around the button there is the edge of the bar, and under the bar the edge of the screen. The bar says all of that in CSS properties that are inherited.
160
+
161
+ ## A toggle button
162
+
163
+ With `toggle` the button stays pressed: "Bold" in the toolbar of an editor, "Mute", a filter above a list, the star of a favourite.
164
+
165
+ ```html
166
+ <el-button toggle="true" appearance="outlined">Bold</el-button>
167
+ <el-button toggle="true" pressed="true" appearance="outlined">Italic</el-button>
168
+ <el-button toggle="true" appearance="plain" circle="true" aria-label="Favourite">★</el-button>
169
+ ```
170
+
171
+ ```js
172
+ button.addEventListener('button-toggle', (event) => {
173
+ editor.bold = event.detail.pressed;
174
+ });
175
+ ```
176
+
177
+ - **The state** is `pressed`, a property and an attribute (`pressed="true"`, `pressed="false"`). A toggle button writes the attribute itself, so a stylesheet can select it: `el-button[pressed='true']`.
178
+ - **A click flips it**, and so do the Space and the Enter key. Then the button fires `button-toggle`. A `click` listener of the page that calls `preventDefault()` keeps the button from flipping. Setting `pressed` from a script changes the state and fires nothing.
179
+ - **A screen reader** announces a toggle button with its state: the control has `aria-pressed="true"` or `"false"`. A button without `toggle` has no `aria-pressed`.
180
+ - **A pressed button shows it** with a ring inside of its edge, in the colour of its label, in every variant and appearance. An `outlined` and a `plain` button get a tint of their text colour as well; a fill is not changed, the label on it would lose contrast. The ring is a shape and a border: it tells the button apart without a colour, and stays where the user forces colours, a little wider. It is the `::before` of the control (`::part(base)::before`).
181
+ - **In an `el-button-group`** a pressed button keeps its joined corners and the line to its neighbour; the ring has the corners of the button.
182
+ - **In server-rendered markup** `aria-pressed` and the ring are there before the script has run. The click needs the script.
183
+
184
+ `aria-pressed` that the page sets itself, on a button without `toggle`, goes to the control as before, and no click changes it. Such a button shows the ring as well.
185
+
186
+ #### What it is not
187
+
188
+ - **Not a value of a form.** A toggle button submits nothing. A setting that is saved with a form is an [`el-switch-field`](../switch-field/switch-field.readme.md) or an [`el-checkbox-field`](../checkbox-field/checkbox-field.readme.md).
189
+ - **Not a button whose name changes with its state.** A button that reads "Mute" and then "Unmute" says its state with its name, and is no toggle: with `aria-pressed` on top a screen reader would announce "Unmute, pressed". Give a toggle button one name that stays ("Mute"), and let the state say the rest.
190
+ - **Not one choice of several.** A toggle button knows nothing of its neighbours: in a row of them, any number can be pressed. A row of which one is chosen at a time is an [`el-segmented-field`](../segmented-field/segmented-field.readme.md).
191
+ - **Not a link.** `toggle` is ignored on a button with `href`.
192
+
125
193
  ## In a form
126
194
 
127
195
  An `el-button` of the type `submit` submits its form as a native submit button does, and one of the type `reset` resets it.
@@ -184,8 +252,7 @@ The element itself has no role. What takes the focus and what a screen reader an
184
252
  <!-- An icon button gets its name -->
185
253
  <el-button circle="true" aria-label="Add">+</el-button>
186
254
 
187
- <!-- A toggle, a button that opens something -->
188
- <el-button aria-pressed="true">Bold</el-button>
255
+ <!-- A button that opens something -->
189
256
  <el-button aria-expanded="false" aria-controls="filters">Filters</el-button>
190
257
 
191
258
  <!-- Described by a text elsewhere in the page -->
@@ -198,7 +265,8 @@ The element itself has no role. What takes the focus and what a screen reader an
198
265
  | `aria-label`, `aria-description`, `aria-expanded`, `aria-haspopup`, `aria-pressed`, `aria-current` | As the same attribute, with every change. |
199
266
  | `aria-labelledby`, `aria-describedby`, `aria-controls` | As references to the elements they name. An id does not reach out of the shadow root the control is in. |
200
267
 
201
- - The attributes stay on the element as well, where a stylesheet can select them: `el-button[aria-pressed='true']`.
268
+ - The attributes stay on the element as well, where a stylesheet can select them: `el-button[aria-expanded='true']`.
269
+ - `aria-pressed` is the state of a button that stays pressed. With [`toggle`](#a-toggle-button) the button keeps that state itself, and an `aria-pressed` of the page gives way to it.
202
270
  - An empty attribute counts as not set.
203
271
  - `aria-disabled` and `aria-busy` are not passed on. The button sets them itself, from `disabled` and `loading`.
204
272
  - The elements behind an id are looked up in the document, or in the shadow root the button is used in, when the button renders. An element that comes into the page later is found once the attribute is set again.
@@ -11,6 +11,13 @@ const style = css`
11
11
  vertical-align: middle;
12
12
  }
13
13
 
14
+ /* The button that opens the navigation of an el-app-frame is not there where the navigation
15
+ is a column beside the content. The frame says so in a property that is inherited, so this
16
+ holds before any script has run. Outside of a frame the button is as any other. */
17
+ :host([data-navigation-toggle]) {
18
+ display: var(--_el-context-navigation-toggle-display, inline-block);
19
+ }
20
+
14
21
  /* ── Base control ─────────────────────────────────────────────────────── */
15
22
 
16
23
  .button {
@@ -22,9 +29,14 @@ const style = css`
22
29
  align-items: center;
23
30
  justify-content: center;
24
31
  gap: var(--el-space-2, 0.5em);
25
- width: 100%;
26
- min-height: var(--_el-size-height);
27
- padding: var(--_el-size-padding-block) var(--_el-size-padding-inline);
32
+ /* The size of the button: its own, from the size module. A button in a toolbar reads the
33
+ size of the toolbar first, see "In a container" below. */
34
+ --_el-button-height: var(--_el-size-height);
35
+ --_el-button-padding-block: var(--_el-size-padding-block);
36
+ --_el-button-padding-inline: var(--_el-size-padding-inline);
37
+ --_el-button-font-size: var(--_el-size-font-size);
38
+ min-height: var(--_el-button-height);
39
+ padding: var(--_el-button-padding-block) var(--_el-button-padding-inline);
28
40
  border: var(--el-border-width, 1px) solid transparent;
29
41
  /* The radius of the shape on all four corners. A row of joined buttons (el-button-group)
30
42
  takes it away from the corners that face a neighbour, with --_el-group-radius-start
@@ -34,8 +46,14 @@ const style = css`
34
46
  border-end-start-radius: var(--_el-group-radius-start, var(--_el-button-radius));
35
47
  border-start-end-radius: var(--_el-group-radius-end, var(--_el-button-radius));
36
48
  border-end-end-radius: var(--_el-group-radius-end, var(--_el-button-radius));
49
+ /* And with a neighbour in front the control lies on the border of that neighbour: it is
50
+ pulled over the element by the width the group names (--_el-group-overlap), and is
51
+ wider than the element by as much, so it ends where the element ends. Outside of a
52
+ group the width is nothing. */
53
+ margin-inline-start: calc(-1 * var(--_el-group-overlap, 0px));
54
+ width: calc(100% + var(--_el-group-overlap, 0px));
37
55
  font-family: var(--el-font-family, inherit);
38
- font-size: var(--_el-size-font-size);
56
+ font-size: var(--_el-button-font-size);
39
57
  font-weight: 600;
40
58
  line-height: var(--el-line-height, 1.5);
41
59
  text-align: center;
@@ -82,7 +100,9 @@ const style = css`
82
100
  gives it one. */
83
101
  .button:focus-visible {
84
102
  outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, transparent);
85
- outline-offset: var(--el-focus-ring-offset, 2px);
103
+ /* A container that has the edge of the screen around it, an el-status-bar, says where the
104
+ ring is: inside of the button. */
105
+ outline-offset: var(--_el-context-focus-ring-offset, var(--el-focus-ring-offset, 2px));
86
106
  }
87
107
 
88
108
  /* Without a theme the ring is inside of the control, in the colour of the label. Nothing says
@@ -124,6 +144,54 @@ const style = css`
124
144
  text-decoration: underline;
125
145
  }
126
146
 
147
+ /* ── Pressed ──────────────────────────────────────────────────────────── */
148
+
149
+ /* A toggle button that is pressed (aria-pressed, from the toggle property or from the page)
150
+ has a ring inside of its edge, in the colour of its label. The ring is a shape, so it tells
151
+ the button apart in every variant and appearance, and without a colour to rely on: it is a
152
+ border, which forced colours keep. It has the corners of the button, the joined ones of a
153
+ group as well, and leaves the border of the button alone: the line to a neighbour stays. */
154
+ .button[aria-pressed='true']::before {
155
+ content: '';
156
+ position: absolute;
157
+ inset: 0;
158
+ border: 0.125rem solid currentColor;
159
+ border-radius: inherit;
160
+ pointer-events: none;
161
+ }
162
+
163
+ /* A button without a fill gets a tint of its text colour as well, one step more than under
164
+ the pointer. A fill is not changed: the text on it would lose contrast. */
165
+ :host([appearance='outlined']) .button[aria-pressed='true'],
166
+ :host([appearance='plain']) .button[aria-pressed='true'] {
167
+ background: color-mix(in srgb, currentColor 16%, transparent);
168
+ }
169
+
170
+ @media (hover: hover) {
171
+ :host([appearance='outlined']) .button[aria-pressed='true']:hover,
172
+ :host([appearance='plain']) .button[aria-pressed='true']:hover {
173
+ background: color-mix(in srgb, currentColor 20%, transparent);
174
+ }
175
+ }
176
+
177
+ :host([appearance='outlined']) .button[aria-pressed='true']:active,
178
+ :host([appearance='plain']) .button[aria-pressed='true']:active {
179
+ background: color-mix(in srgb, currentColor 28%, transparent);
180
+ }
181
+
182
+ /* Without a theme the focus ring is inside of the control as well. It moves further in, so a
183
+ pressed button with the focus shows two rings and not one that is a little wider. */
184
+ .button[aria-pressed='true']:focus-visible::after {
185
+ inset: calc(var(--el-border-width, 1px) + 0.25rem);
186
+ }
187
+
188
+ /* Forced colours leave the ring as the only mark: it is wider there. */
189
+ @media (forced-colors: active) {
190
+ .button[aria-pressed='true']::before {
191
+ border-width: 0.1875rem;
192
+ }
193
+ }
194
+
127
195
  /* ── Shapes ───────────────────────────────────────────────────────────── */
128
196
 
129
197
  .button--pill {
@@ -132,8 +200,8 @@ const style = css`
132
200
 
133
201
  .button--circle {
134
202
  --_el-button-radius: 50%;
135
- width: var(--_el-size-height);
136
- height: var(--_el-size-height);
203
+ width: var(--_el-button-height);
204
+ height: var(--_el-button-height);
137
205
  min-height: 0;
138
206
  padding: 0;
139
207
  aspect-ratio: 1;
@@ -151,6 +219,97 @@ const style = css`
151
219
  border-inline-start-color: var(--_el-group-divider, var(--_el-variant-fill-border));
152
220
  }
153
221
 
222
+ /* ── In a container ───────────────────────────────────────────────────── */
223
+
224
+ /* A container that gives its controls one size and one appearance, a toolbar, says so in
225
+ properties that are inherited (see sizeContextStyle() and appearanceContextStyle()). A
226
+ button reads them while the page has not set the attribute on the button itself: the
227
+ template marks the control then. Outside of such a container the properties are not set,
228
+ and every value below falls back to the one the button has without them. */
229
+
230
+ .button--inherit-size {
231
+ --_el-button-height: var(--_el-context-size-height, var(--_el-size-height));
232
+ --_el-button-padding-block: var(--_el-context-size-padding-block, var(--_el-size-padding-block));
233
+ --_el-button-padding-inline: var(--_el-context-size-padding-inline, var(--_el-size-padding-inline));
234
+ --_el-button-font-size: var(--_el-context-size-font-size, var(--_el-size-font-size));
235
+ }
236
+
237
+ /* The appearance of the container is a switch that is set or not. In front of a value it gives
238
+ a property that is valid only where the switch is set. */
239
+ .button--inherit-appearance {
240
+ --_el-button-if-plain: var(--_el-context-appearance-plain) transparent;
241
+ --_el-button-if-outlined: var(--_el-context-appearance-outlined) transparent;
242
+ --_el-button-if-outlined-border: var(--_el-context-appearance-outlined) var(--_el-variant-border);
243
+ --_el-button-if-plain-text: var(--_el-context-appearance-plain) var(--_el-variant-text);
244
+ --_el-button-if-outlined-text: var(--_el-context-appearance-outlined) var(--_el-variant-text);
245
+ --_el-button-if-plain-none: var(--_el-context-appearance-plain) none;
246
+ --_el-button-if-outlined-none: var(--_el-context-appearance-outlined) none;
247
+ }
248
+
249
+ /* The three colours of the appearance module, and the line to a neighbour in a group. The
250
+ rules weigh as much as the ones for a filled button and come after them. A button whose
251
+ appearance is its own has no mark, and keeps the rules of its attribute. */
252
+ :host .button--inherit-appearance {
253
+ background: var(--_el-button-if-plain, var(--_el-button-if-outlined, var(--_el-variant-fill)));
254
+ border-color: var(--_el-button-if-plain, var(--_el-button-if-outlined-border, var(--_el-variant-fill-border)));
255
+ border-inline-start-color: var(
256
+ --_el-button-if-plain,
257
+ var(--_el-button-if-outlined-border, var(--_el-group-divider, var(--_el-variant-fill-border)))
258
+ );
259
+ color: var(--_el-button-if-plain-text, var(--_el-button-if-outlined-text, var(--_el-variant-on-fill)));
260
+ }
261
+
262
+ /* Under the pointer and pressed down: a tint of the text colour where the button has no fill,
263
+ as an outlined button has. A plain button of a toolbar gets it as well: it is an icon as a
264
+ rule, and an icon has nothing to underline. */
265
+ @media (hover: hover) {
266
+ :host .button--inherit-appearance:hover {
267
+ --_el-button-if-plain-tint: var(--_el-context-appearance-plain)
268
+ color-mix(in srgb, currentColor 12%, transparent);
269
+ --_el-button-if-outlined-tint: var(--_el-context-appearance-outlined)
270
+ color-mix(in srgb, currentColor 12%, transparent);
271
+ background: var(--_el-button-if-plain-tint, var(--_el-button-if-outlined-tint, var(--_el-variant-fill)));
272
+ filter: var(--_el-button-if-plain-none, var(--_el-button-if-outlined-none, brightness(0.95)));
273
+ }
274
+ }
275
+
276
+ :host .button--inherit-appearance:active {
277
+ --_el-button-if-plain-tint: var(--_el-context-appearance-plain)
278
+ color-mix(in srgb, currentColor 24%, transparent);
279
+ --_el-button-if-outlined-tint: var(--_el-context-appearance-outlined)
280
+ color-mix(in srgb, currentColor 24%, transparent);
281
+ background: var(--_el-button-if-plain-tint, var(--_el-button-if-outlined-tint, var(--_el-variant-fill)));
282
+ filter: var(--_el-button-if-plain-none, var(--_el-button-if-outlined-none, brightness(0.88)));
283
+ }
284
+
285
+ /* A pressed toggle button: the tint of a button without a fill, one step more than under the
286
+ pointer. */
287
+ :host .button--inherit-appearance[aria-pressed='true'] {
288
+ --_el-button-if-plain-tint: var(--_el-context-appearance-plain)
289
+ color-mix(in srgb, currentColor 16%, transparent);
290
+ --_el-button-if-outlined-tint: var(--_el-context-appearance-outlined)
291
+ color-mix(in srgb, currentColor 16%, transparent);
292
+ background: var(--_el-button-if-plain-tint, var(--_el-button-if-outlined-tint, var(--_el-variant-fill)));
293
+ }
294
+
295
+ @media (hover: hover) {
296
+ :host .button--inherit-appearance[aria-pressed='true']:hover {
297
+ --_el-button-if-plain-tint: var(--_el-context-appearance-plain)
298
+ color-mix(in srgb, currentColor 20%, transparent);
299
+ --_el-button-if-outlined-tint: var(--_el-context-appearance-outlined)
300
+ color-mix(in srgb, currentColor 20%, transparent);
301
+ background: var(--_el-button-if-plain-tint, var(--_el-button-if-outlined-tint, var(--_el-variant-fill)));
302
+ }
303
+ }
304
+
305
+ :host .button--inherit-appearance[aria-pressed='true']:active {
306
+ --_el-button-if-plain-tint: var(--_el-context-appearance-plain)
307
+ color-mix(in srgb, currentColor 28%, transparent);
308
+ --_el-button-if-outlined-tint: var(--_el-context-appearance-outlined)
309
+ color-mix(in srgb, currentColor 28%, transparent);
310
+ background: var(--_el-button-if-plain-tint, var(--_el-button-if-outlined-tint, var(--_el-variant-fill)));
311
+ }
312
+
154
313
  /* ── Touch screens ────────────────────────────────────────────────────── */
155
314
 
156
315
  /* On a coarse pointer no size or shape falls below --el-touch-target in either direction.
@@ -158,7 +317,7 @@ const style = css`
158
317
  @media (any-pointer: coarse) {
159
318
  .button {
160
319
  min-width: var(--el-touch-target, auto);
161
- min-height: max(var(--_el-size-height), var(--el-touch-target, 0px));
320
+ min-height: max(var(--_el-button-height), var(--el-touch-target, 0px));
162
321
  }
163
322
 
164
323
  /* A circle has a fixed width and height. The minimum wins over both, so it stays round. */
@@ -12,6 +12,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.5.0] - 2026-11-27
16
+
17
+ ### Changed
18
+
19
+ - A page that put the overlap back itself, with a negative margin for the buttons of a group, takes that rule out: the buttons would lie on each other by two borders. ([#206](https://github.com/webtides/element-library/issues/206))
20
+
21
+ ### Fixed
22
+
23
+ - The buttons of a group lie on the border of their neighbour on a page whose stylesheet takes the margin off every element (`* { margin: 0 }`, the reset of Tailwind CSS v4). The group pulled a button over the border of the one in front of it with a negative margin of the button (`::slotted`), and a rule of the page wins over such a rule: two outlined buttons had two lines between them, and the group was wider by a border for every button after the first. The group names the width of the border in a property that inherits now (`--_el-group-overlap`), and the button pulls its control over it. ([#206](https://github.com/webtides/element-library/issues/206))
24
+
15
25
  ## [0.3.0] - 2026-11-17
16
26
 
17
27
  ### Added
@@ -68,6 +68,8 @@ _None._ The group takes the radius and the border width from the tokens of the t
68
68
 
69
69
  The group does this with its stylesheet alone. It runs no script on its buttons and writes nothing onto them: a button that is added, moved or taken away is joined at once, and a server-rendered group does not change when the elements take over.
70
70
 
71
+ It tells its buttons in properties that inherit, and a button joins itself: the group takes nothing from the margin, the padding or the border of the elements slotted into it. So a reset of the page that takes the margin off every element (`* { margin: 0 }`) changes nothing. The element of a button with a neighbour in front stands beside that neighbour; its control, which has the border, lies on the border of the neighbour.
72
+
71
73
  ## What the buttons bring
72
74
 
73
75
  `variant`, `appearance`, `size`, `pill` and `disabled` stay with every button. The group does not pass anything on. Give every button of a group the same `size`; a mix of appearances works, a mix of sizes does not line up.
@@ -19,11 +19,15 @@ const style = css`
19
19
  /* With a neighbour in front: square corners at the start, and the border at the start lies on
20
20
  the border at the end of that neighbour, so the two share one line. For a filled button
21
21
  that line is a quarter of its text colour on its fill, which shows between two fills of
22
- one colour. currentColor is taken where the button paints the line, not here. */
22
+ one colour. currentColor is taken where the button paints the line, not here.
23
+
24
+ The group names the width of that border, and the button pulls its control over it. A
25
+ margin of the slotted element would do the same, and would be gone on a page that takes
26
+ the margin off every element: a rule of the page wins over a ::slotted rule. */
23
27
  ::slotted(:not(:first-child)) {
24
28
  --_el-group-radius-start: 0px;
25
29
  --_el-group-divider: color-mix(in srgb, currentColor 25%, transparent);
26
- margin-inline-start: calc(-1 * var(--el-border-width, 1px));
30
+ --_el-group-overlap: var(--el-border-width, 1px);
27
31
  }
28
32
 
29
33
  /* With a neighbour behind: square corners at the end. */
@@ -12,6 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.5.0] - 2026-11-27
16
+
17
+ ### Added
18
+
19
+ - An option can show something in front of its label: `color` is a colour that is drawn as a dot, `icon` the address of an SVG symbol, as an option of `el-segmented-field` has it. Things a user knows by their colour, tags or calendars, are found by it where they are chosen. Both are decorations, hidden from assistive technology: the label stays the name of the option. They are part of the option, so they work for options as an attribute and as a property, and are in server-rendered markup. The dot keeps its colour where the user forces colours. ([#198](https://github.com/webtides/element-library/issues/198))
20
+
15
21
  ## [0.3.0] - 2026-11-17
16
22
 
17
23
  ### Added