@aleph-alpha/ui-library 6.3.4 → 6.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/config.js +2 -1
  2. package/dist/system/components/UiDropdownMenu/UiDropdownMenuSubContent.vue.d.ts +102 -2
  3. package/dist/system/components/UiDropdownMenu/UiDropdownMenuViewport.vue.d.ts +23 -0
  4. package/dist/system/components/UiDropdownMenu/menu-metrics.d.ts +4 -0
  5. package/dist/system/components/UiDropdownMenu/placeMobileSubmenu.d.ts +55 -0
  6. package/dist/system/components/UiDropdownMenu/types.d.ts +3 -0
  7. package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +18 -0
  8. package/dist/system/components/UiFileUploadBox/UiFileUploadBox.vue.d.ts +2 -2
  9. package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +2 -2
  10. package/dist/system/components/UiToggle/UiToggle.vue.d.ts +2 -1
  11. package/dist/system/components/UiToggle/types.d.ts +10 -2
  12. package/dist/system/components/UiToggleGroup/UiToggleGroupItem.vue.d.ts +5 -1
  13. package/dist/system/components/UiToggleGroup/types.d.ts +12 -2
  14. package/dist/system/components/core/dropdown-menu/DropdownMenuSubContent.vue.d.ts +2 -6
  15. package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +2 -2
  16. package/dist/system/components/core/toggle/Toggle.vue.d.ts +3 -1
  17. package/dist/system/components/core/toggle/index.d.ts +47 -2
  18. package/dist/system/components/core/toggle-group/ToggleGroup.vue.d.ts +3 -1
  19. package/dist/system/components/core/toggle-group/ToggleGroupItem.vue.d.ts +11 -1
  20. package/dist/system/components/core/toggle-group/context.d.ts +1 -0
  21. package/dist/system/components/core/toggle-group/index.d.ts +10 -2
  22. package/dist/system/lib.js +12660 -12479
  23. package/dist/system/patterns/UiFileUpload/UiFileUpload.vue.d.ts +2 -2
  24. package/dist/system/patterns/UiLayout/layout-shell.d.ts +171 -12
  25. package/dist/system/patterns/UiProfileCard/profile-card.d.ts +51 -1
  26. package/dist/system/patterns/UiTopBar/accessory-dropdown.d.ts +9 -4
  27. package/package.json +2 -2
  28. package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +819 -31
  29. package/src/components/UiDropdownMenu/UiDropdownMenuContent.vue +4 -1
  30. package/src/components/UiDropdownMenu/UiDropdownMenuSubContent.vue +142 -1
  31. package/src/components/UiDropdownMenu/UiDropdownMenuSubTrigger.vue +28 -0
  32. package/src/components/UiDropdownMenu/UiDropdownMenuViewport.vue +171 -0
  33. package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +326 -0
  34. package/src/components/UiDropdownMenu/__tests__/placeMobileSubmenu.test.ts +128 -0
  35. package/src/components/UiDropdownMenu/menu-metrics.ts +5 -0
  36. package/src/components/UiDropdownMenu/placeMobileSubmenu.ts +96 -0
  37. package/src/components/UiDropdownMenu/types.ts +3 -0
  38. package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +163 -0
  39. package/src/components/UiSnackbar/UiSnackbar.stories.ts +104 -32
  40. package/src/components/UiToggle/UiToggle.stories.ts +386 -261
  41. package/src/components/UiToggle/UiToggle.vue +2 -0
  42. package/src/components/UiToggle/__tests__/UiToggle.test.ts +63 -10
  43. package/src/components/UiToggle/types.ts +10 -2
  44. package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +765 -30
  45. package/src/components/UiToggleGroup/UiToggleGroup.vue +2 -0
  46. package/src/components/UiToggleGroup/UiToggleGroupItem.vue +10 -1
  47. package/src/components/UiToggleGroup/__tests__/UiToggleGroup.test.ts +83 -4
  48. package/src/components/UiToggleGroup/types.ts +12 -2
  49. package/src/components/core/dropdown-menu/DropdownMenuContent.vue +1 -1
  50. package/src/components/core/dropdown-menu/DropdownMenuItem.vue +1 -1
  51. package/src/components/core/dropdown-menu/DropdownMenuSubContent.vue +31 -20
  52. package/src/components/core/toggle/Toggle.vue +12 -5
  53. package/src/components/core/toggle/index.ts +47 -19
  54. package/src/components/core/toggle-group/ToggleGroup.vue +20 -4
  55. package/src/components/core/toggle-group/ToggleGroupItem.vue +36 -8
  56. package/src/components/core/toggle-group/context.ts +1 -0
  57. package/src/components/core/toggle-group/index.ts +10 -24
  58. package/src/patterns/UiDataTable/UiDataTableColumnFilter.vue +1 -1
  59. package/src/patterns/UiDataTable/UiDataTableFilterMenu.vue +1 -1
  60. package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +13 -6
  61. package/src/patterns/UiTopBar/accessory-dropdown.ts +5 -3
@@ -6,7 +6,7 @@ import { UiIcon } from '../UiIcon';
6
6
 
7
7
  /**
8
8
  * UiToggle is a button that maintains a pressed/unpressed state.
9
- * Use it for binary controls in toolbars (bold, italic, mute) or filter chips that should look like buttons; for grouped toggles, use `UiToggleGroup`.
9
+ * Use it for the trigger of a dropdown, popover or filter menu whose open state should stay visible, and for binary controls in toolbars (mute, wrap lines); for grouped toggles, use `UiToggleGroup`.
10
10
  */
11
11
  const meta: Meta<typeof UiToggle> = {
12
12
  title: 'Components/UiToggle',
@@ -15,7 +15,7 @@ const meta: Meta<typeof UiToggle> = {
15
15
  argTypes: {
16
16
  variant: {
17
17
  control: 'select',
18
- options: ['default', 'outline', 'soft'],
18
+ options: ['default', 'ghost', 'outline'],
19
19
  description: 'The visual style variant',
20
20
  },
21
21
  size: {
@@ -23,6 +23,19 @@ const meta: Meta<typeof UiToggle> = {
23
23
  options: ['default', 'sm', 'lg'],
24
24
  description: 'The size of the toggle',
25
25
  },
26
+ soft: {
27
+ control: 'boolean',
28
+ description:
29
+ 'Fills the pressed state with the subtle hover overlay instead of a muted surface. Intended for dropdown and popover triggers',
30
+ },
31
+ leftIcon: {
32
+ control: 'text',
33
+ description: 'Icon rendered before the label',
34
+ },
35
+ rightIcon: {
36
+ control: 'text',
37
+ description: 'Icon rendered after the label',
38
+ },
26
39
  disabled: {
27
40
  control: 'boolean',
28
41
  description: 'Whether the toggle is disabled',
@@ -31,6 +44,9 @@ const meta: Meta<typeof UiToggle> = {
31
44
  args: {
32
45
  variant: 'default',
33
46
  size: 'default',
47
+ soft: false,
48
+ leftIcon: 'chevron-up',
49
+ rightIcon: 'chevron-down',
34
50
  disabled: false,
35
51
  },
36
52
  };
@@ -45,28 +61,35 @@ type Story = StoryObj<typeof UiToggle>;
45
61
  const onUpdate = fn();
46
62
 
47
63
  const defaultTemplateSource = `<script setup lang="ts">
48
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
64
+ import { UiToggle } from '@aleph-alpha/ui-library'
49
65
  </script>
50
66
 
51
67
  <template>
52
- <UiToggle aria-label="Bold">
53
- <UiIcon name="bold" />
68
+ <UiToggle left-icon="chevron-up" right-icon="chevron-down">
69
+ Filter
54
70
  </UiToggle>
55
71
  </template>`;
56
72
 
57
73
  /**
58
- * Default toggle, resting in the unpressed state. The icon is decorative, so an
59
- * icon-only toggle needs an explicit `aria-label` to have a name at all — and
60
- * that name describes the control ("Bold"), never its current state.
74
+ * Default toggle, resting in the unpressed state. `leftIcon` and `rightIcon`
75
+ * frame the label; both icons render `aria-hidden`, so the visible text is the
76
+ * whole accessible name and no `aria-label` is needed.
61
77
  */
62
78
  export const Default: Story = {
63
79
  render: (args) => ({
64
- components: { UiToggle, UiIcon },
80
+ components: { UiToggle },
65
81
  setup() {
66
82
  return { args };
67
83
  },
68
- template: `<UiToggle :variant="args.variant" :size="args.size" :disabled="args.disabled" aria-label="Bold">
69
- <UiIcon name="bold" />
84
+ template: `<UiToggle
85
+ :variant="args.variant"
86
+ :size="args.size"
87
+ :soft="args.soft"
88
+ :left-icon="args.leftIcon"
89
+ :right-icon="args.rightIcon"
90
+ :disabled="args.disabled"
91
+ >
92
+ Filter
70
93
  </UiToggle>`,
71
94
  }),
72
95
  parameters: {
@@ -80,13 +103,13 @@ export const Default: Story = {
80
103
  // Scenario (Toggle): the resting unpressed state. Nothing is activated
81
104
  // here, so the visual snapshot stays stable.
82
105
  const canvas = within(canvasElement);
83
- const toggle = canvas.getByRole('button', { name: 'Bold' });
106
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
84
107
 
85
108
  await step(
86
109
  'interaction: the toggle is a button with an accessible name (WCAG 4.1.2)',
87
110
  async () => {
88
111
  await expect(toggle).toBeVisible();
89
- await expect(toggle).toHaveAccessibleName('Bold');
112
+ await expect(toggle).toHaveAccessibleName('Filter');
90
113
  },
91
114
  );
92
115
 
@@ -98,12 +121,12 @@ export const Default: Story = {
98
121
  };
99
122
 
100
123
  const pressedTemplateSource = `<script setup lang="ts">
101
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
124
+ import { UiToggle } from '@aleph-alpha/ui-library'
102
125
  </script>
103
126
 
104
127
  <template>
105
- <UiToggle default-value aria-label="Bold">
106
- <UiIcon name="bold" />
128
+ <UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">
129
+ Filter
107
130
  </UiToggle>
108
131
  </template>`;
109
132
 
@@ -114,9 +137,9 @@ import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
114
137
  */
115
138
  export const Pressed: Story = {
116
139
  render: () => ({
117
- components: { UiToggle, UiIcon },
118
- template: `<UiToggle default-value aria-label="Bold">
119
- <UiIcon name="bold" />
140
+ components: { UiToggle },
141
+ template: `<UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">
142
+ Filter
120
143
  </UiToggle>`,
121
144
  }),
122
145
  parameters: {
@@ -131,7 +154,7 @@ export const Pressed: Story = {
131
154
  // Scenario (Toggle): the resting pressed state. Non-mutating, so the
132
155
  // visual snapshot stays stable.
133
156
  const canvas = within(canvasElement);
134
- const toggle = canvas.getByRole('button', { name: 'Bold' });
157
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
135
158
 
136
159
  await step(
137
160
  'interaction: the toggle rests in the pressed state',
@@ -150,12 +173,12 @@ export const Pressed: Story = {
150
173
  };
151
174
 
152
175
  const outlineTemplateSource = `<script setup lang="ts">
153
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
176
+ import { UiToggle } from '@aleph-alpha/ui-library'
154
177
  </script>
155
178
 
156
179
  <template>
157
- <UiToggle variant="outline" aria-label="Bold">
158
- <UiIcon name="bold" />
180
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">
181
+ Filter
159
182
  </UiToggle>
160
183
  </template>`;
161
184
 
@@ -166,9 +189,9 @@ import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
166
189
  */
167
190
  export const Outline: Story = {
168
191
  render: () => ({
169
- components: { UiToggle, UiIcon },
170
- template: `<UiToggle variant="outline" aria-label="Bold">
171
- <UiIcon name="bold" />
192
+ components: { UiToggle },
193
+ template: `<UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">
194
+ Filter
172
195
  </UiToggle>`,
173
196
  }),
174
197
  parameters: {
@@ -183,12 +206,58 @@ export const Outline: Story = {
183
206
  // Scenario (Toggle): a style variation carries the same semantics as the
184
207
  // default one. Non-mutating, so the visual snapshot stays stable.
185
208
  const canvas = within(canvasElement);
186
- const toggle = canvas.getByRole('button', { name: 'Bold' });
209
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
187
210
 
188
211
  await step(
189
212
  'interaction: the outline variant exposes the same name and state',
190
213
  async () => {
191
- await expect(toggle).toHaveAccessibleName('Bold');
214
+ await expect(toggle).toHaveAccessibleName('Filter');
215
+ await expect(toggle).toHaveAttribute('aria-pressed', 'false');
216
+ },
217
+ );
218
+ },
219
+ };
220
+
221
+ const ghostTemplateSource = `<script setup lang="ts">
222
+ import { UiToggle } from '@aleph-alpha/ui-library'
223
+ </script>
224
+
225
+ <template>
226
+ <UiToggle variant="ghost" left-icon="chevron-up" right-icon="chevron-down">
227
+ Filter
228
+ </UiToggle>
229
+ </template>`;
230
+
231
+ /**
232
+ * Ghost variant: borderless like the default one, for toolbars and top bars
233
+ * that supply their own framing. Unpressed it reads as plain text, so the
234
+ * pressed fill and `aria-pressed` carry the entire state.
235
+ */
236
+ export const Ghost: Story = {
237
+ render: () => ({
238
+ components: { UiToggle },
239
+ template: `<UiToggle variant="ghost" left-icon="chevron-up" right-icon="chevron-down">
240
+ Filter
241
+ </UiToggle>`,
242
+ }),
243
+ parameters: {
244
+ controls: { disable: true },
245
+ docs: {
246
+ source: {
247
+ code: ghostTemplateSource,
248
+ },
249
+ },
250
+ },
251
+ play: async ({ canvasElement, step }) => {
252
+ // Scenario (Toggle): a style variation carries the same semantics as the
253
+ // default one. Non-mutating, so the visual snapshot stays stable.
254
+ const canvas = within(canvasElement);
255
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
256
+
257
+ await step(
258
+ 'interaction: the ghost variant exposes the same name and state',
259
+ async () => {
260
+ await expect(toggle).toHaveAccessibleName('Filter');
192
261
  await expect(toggle).toHaveAttribute('aria-pressed', 'false');
193
262
  },
194
263
  );
@@ -196,24 +265,29 @@ export const Outline: Story = {
196
265
  };
197
266
 
198
267
  const softTemplateSource = `<script setup lang="ts">
199
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
268
+ import { UiToggle } from '@aleph-alpha/ui-library'
200
269
  </script>
201
270
 
202
271
  <template>
203
- <UiToggle variant="soft" aria-label="Bold">
204
- <UiIcon name="bold" />
272
+ <UiToggle soft default-value left-icon="chevron-up" right-icon="chevron-down">
273
+ Filter
205
274
  </UiToggle>
206
275
  </template>`;
207
276
 
208
277
  /**
209
- * Soft variant, which fills with a subtle accent instead of the solid one when
210
- * pressed. The quieter fill is why `aria-pressed` matters here.
278
+ * The `soft` flag swaps the pressed fill from a muted surface to the subtle
279
+ * hover overlay, leaving every other state untouched. It exists mainly for
280
+ * dropdown and popover triggers: while the menu is open the trigger should read
281
+ * as merely lit up, not as a second filled button competing with the menu. See
282
+ * `UiDropdownMenu` → "With Soft Toggle Trigger" for that composition. Shown
283
+ * pressed here, since that is the only state it changes — and because the fill
284
+ * is this quiet, `aria-pressed` is what assistive technology relies on.
211
285
  */
212
286
  export const Soft: Story = {
213
287
  render: () => ({
214
- components: { UiToggle, UiIcon },
215
- template: `<UiToggle variant="soft" aria-label="Bold">
216
- <UiIcon name="bold" />
288
+ components: { UiToggle },
289
+ template: `<UiToggle soft default-value left-icon="chevron-up" right-icon="chevron-down">
290
+ Filter
217
291
  </UiToggle>`,
218
292
  }),
219
293
  parameters: {
@@ -228,43 +302,44 @@ export const Soft: Story = {
228
302
  // Scenario (Toggle): a style variation carries the same semantics as the
229
303
  // default one. Non-mutating, so the visual snapshot stays stable.
230
304
  const canvas = within(canvasElement);
231
- const toggle = canvas.getByRole('button', { name: 'Bold' });
305
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
232
306
 
233
307
  await step(
234
- 'interaction: the soft variant exposes the same name and state',
308
+ 'interaction: the soft pressed fill still reports the pressed state',
235
309
  async () => {
236
- await expect(toggle).toHaveAccessibleName('Bold');
237
- await expect(toggle).toHaveAttribute('aria-pressed', 'false');
310
+ await expect(toggle).toHaveAccessibleName('Filter');
311
+ await expect(toggle).toHaveAttribute('aria-pressed', 'true');
238
312
  },
239
313
  );
240
314
  },
241
315
  };
242
316
 
243
317
  const iconOnlyTemplateSource = `<script setup lang="ts">
244
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
318
+ import { UiToggle } from '@aleph-alpha/ui-library'
245
319
  </script>
246
320
 
247
321
  <template>
248
322
  <div class="flex items-center gap-2">
249
- <UiToggle aria-label="Bold"><UiIcon name="bold" /></UiToggle>
250
- <UiToggle aria-label="Italic"><UiIcon name="italic" /></UiToggle>
251
- <UiToggle aria-label="Underline"><UiIcon name="underline" /></UiToggle>
323
+ <UiToggle left-icon="chevron-down" aria-label="Filter" />
324
+ <UiToggle left-icon="chevron-up" aria-label="Sort" />
325
+ <UiToggle left-icon="columns3" aria-label="Columns" />
252
326
  </div>
253
327
  </template>`;
254
328
 
255
329
  /**
256
- * Icon-only toggles, as used in a formatting toolbar. `UiIcon` renders
330
+ * Icon-only toggles, for toolbars too tight for a label. `UiIcon` renders
257
331
  * `aria-hidden`, so without an `aria-label` these buttons would reach assistive
258
- * technology with no name at all.
332
+ * technology with no name at all — and that name describes the control
333
+ * ("Filter"), never its current state.
259
334
  */
260
335
  export const IconOnly: Story = {
261
336
  render: () => ({
262
- components: { UiToggle, UiIcon },
337
+ components: { UiToggle },
263
338
  template: `
264
339
  <div class="flex items-center gap-2">
265
- <UiToggle aria-label="Bold"><UiIcon name="bold" /></UiToggle>
266
- <UiToggle aria-label="Italic"><UiIcon name="italic" /></UiToggle>
267
- <UiToggle aria-label="Underline"><UiIcon name="underline" /></UiToggle>
340
+ <UiToggle left-icon="chevron-down" aria-label="Filter" />
341
+ <UiToggle left-icon="chevron-up" aria-label="Sort" />
342
+ <UiToggle left-icon="columns3" aria-label="Columns" />
268
343
  </div>
269
344
  `,
270
345
  }),
@@ -284,7 +359,7 @@ export const IconOnly: Story = {
284
359
  await step(
285
360
  'screen-reader: every icon-only toggle carries a name (WCAG 1.1.1 / 4.1.2)',
286
361
  async () => {
287
- for (const name of ['Bold', 'Italic', 'Underline']) {
362
+ for (const name of ['Filter', 'Sort', 'Columns']) {
288
363
  await expect(
289
364
  canvas.getByRole('button', { name }),
290
365
  ).toHaveAccessibleName(name);
@@ -296,7 +371,7 @@ export const IconOnly: Story = {
296
371
  'screen-reader: the decorative icon is hidden from assistive technology',
297
372
  async () => {
298
373
  const icon = canvas
299
- .getByRole('button', { name: 'Bold' })
374
+ .getByRole('button', { name: 'Filter' })
300
375
  .querySelector('svg');
301
376
  await expect(icon).toHaveAttribute('aria-hidden', 'true');
302
377
  },
@@ -305,28 +380,23 @@ export const IconOnly: Story = {
305
380
  };
306
381
 
307
382
  const withTextTemplateSource = `<script setup lang="ts">
308
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
383
+ import { UiToggle } from '@aleph-alpha/ui-library'
309
384
  </script>
310
385
 
311
386
  <template>
312
- <UiToggle>
313
- <UiIcon name="italic" />
314
- Italic
315
- </UiToggle>
387
+ <UiToggle>Filter</UiToggle>
316
388
  </template>`;
317
389
 
318
390
  /**
319
- * Toggle with a text label. The visible text already names the button, so no
320
- * `aria-label` is needed — and adding one that disagrees with the text would
321
- * break speech input (WCAG 2.5.3 Label in Name).
391
+ * Both icons are optional: a toggle with nothing but a text label is a valid
392
+ * filter chip. The visible text already names the button, so no `aria-label` is
393
+ * needed — and adding one that disagrees with the text would break speech input
394
+ * (WCAG 2.5.3 Label in Name).
322
395
  */
323
396
  export const WithText: Story = {
324
397
  render: () => ({
325
- components: { UiToggle, UiIcon },
326
- template: `<UiToggle>
327
- <UiIcon name="italic" />
328
- Italic
329
- </UiToggle>`,
398
+ components: { UiToggle },
399
+ template: `<UiToggle>Filter</UiToggle>`,
330
400
  }),
331
401
  parameters: {
332
402
  controls: { disable: true },
@@ -340,38 +410,38 @@ export const WithText: Story = {
340
410
  // Scenario (Toggle): usage with text. Non-mutating, so the visual snapshot
341
411
  // stays stable.
342
412
  const canvas = within(canvasElement);
343
- const toggle = canvas.getByRole('button', { name: 'Italic' });
413
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
344
414
 
345
415
  await step(
346
416
  'screen-reader: the visible text is the accessible name (WCAG 2.5.3 Label in Name)',
347
417
  async () => {
348
- await expect(toggle).toHaveAccessibleName('Italic');
418
+ await expect(toggle).toHaveAccessibleName('Filter');
349
419
  await expect(toggle).not.toHaveAttribute('aria-label');
350
- await expect(canvas.getByText('Italic')).toBeVisible();
420
+ await expect(canvas.getByText('Filter')).toBeVisible();
351
421
  },
352
422
  );
353
423
  },
354
424
  };
355
425
 
356
426
  const smallTemplateSource = `<script setup lang="ts">
357
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
427
+ import { UiToggle } from '@aleph-alpha/ui-library'
358
428
  </script>
359
429
 
360
430
  <template>
361
- <UiToggle size="sm" aria-label="Italic">
362
- <UiIcon name="italic" />
431
+ <UiToggle size="sm" left-icon="chevron-up" right-icon="chevron-down">
432
+ Filter
363
433
  </UiToggle>
364
434
  </template>`;
365
435
 
366
436
  /**
367
- * Small size — the tightest of the three, and still 32×32px, comfortably over
368
- * the 24×24px floor in WCAG 2.5.8 Target Size (Minimum).
437
+ * Small size — the tightest of the three, for dense toolbars and table headers.
438
+ * It still clears the 24×24px floor in WCAG 2.5.8 Target Size (Minimum).
369
439
  */
370
440
  export const Small: Story = {
371
441
  render: () => ({
372
- components: { UiToggle, UiIcon },
373
- template: `<UiToggle size="sm" aria-label="Italic">
374
- <UiIcon name="italic" />
442
+ components: { UiToggle },
443
+ template: `<UiToggle size="sm" left-icon="chevron-up" right-icon="chevron-down">
444
+ Filter
375
445
  </UiToggle>`,
376
446
  }),
377
447
  parameters: {
@@ -386,7 +456,7 @@ export const Small: Story = {
386
456
  // Scenario (Toggle): the smallest size variation still has to be tappable.
387
457
  // Non-mutating, so the visual snapshot stays stable.
388
458
  const canvas = within(canvasElement);
389
- const toggle = canvas.getByRole('button', { name: 'Italic' });
459
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
390
460
 
391
461
  await step(
392
462
  'mobile: the small toggle meets the minimum target size (WCAG 2.5.8)',
@@ -400,12 +470,12 @@ export const Small: Story = {
400
470
  };
401
471
 
402
472
  const largeTemplateSource = `<script setup lang="ts">
403
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
473
+ import { UiToggle } from '@aleph-alpha/ui-library'
404
474
  </script>
405
475
 
406
476
  <template>
407
- <UiToggle size="lg" aria-label="Italic">
408
- <UiIcon name="italic" />
477
+ <UiToggle size="lg" left-icon="chevron-up" right-icon="chevron-down">
478
+ Filter
409
479
  </UiToggle>
410
480
  </template>`;
411
481
 
@@ -414,9 +484,9 @@ import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
414
484
  */
415
485
  export const Large: Story = {
416
486
  render: () => ({
417
- components: { UiToggle, UiIcon },
418
- template: `<UiToggle size="lg" aria-label="Italic">
419
- <UiIcon name="italic" />
487
+ components: { UiToggle },
488
+ template: `<UiToggle size="lg" left-icon="chevron-up" right-icon="chevron-down">
489
+ Filter
420
490
  </UiToggle>`,
421
491
  }),
422
492
  parameters: {
@@ -431,7 +501,7 @@ export const Large: Story = {
431
501
  // Scenario (Toggle): the largest size variation. Non-mutating, so the
432
502
  // visual snapshot stays stable.
433
503
  const canvas = within(canvasElement);
434
- const toggle = canvas.getByRole('button', { name: 'Italic' });
504
+ const toggle = canvas.getByRole('button', { name: 'Filter' });
435
505
 
436
506
  await step(
437
507
  'mobile: the large toggle meets the minimum target size (WCAG 2.5.8)',
@@ -445,16 +515,16 @@ export const Large: Story = {
445
515
  };
446
516
 
447
517
  const disabledTemplateSource = `<script setup lang="ts">
448
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
518
+ import { UiToggle } from '@aleph-alpha/ui-library'
449
519
  </script>
450
520
 
451
521
  <template>
452
522
  <div class="flex items-center gap-2">
453
- <UiToggle disabled aria-label="Underline">
454
- <UiIcon name="underline" />
523
+ <UiToggle disabled left-icon="chevron-up" right-icon="chevron-down">
524
+ Filter
455
525
  </UiToggle>
456
- <UiToggle disabled default-value aria-label="Strikethrough">
457
- <UiIcon name="strikethrough" />
526
+ <UiToggle disabled default-value left-icon="chevron-up" right-icon="chevron-down">
527
+ Sort
458
528
  </UiToggle>
459
529
  </div>
460
530
  </template>`;
@@ -469,17 +539,17 @@ export const Disabled: Story = {
469
539
  disabled: true,
470
540
  },
471
541
  render: () => ({
472
- components: { UiToggle, UiIcon },
542
+ components: { UiToggle },
473
543
  setup() {
474
544
  return { onUpdate };
475
545
  },
476
546
  template: `
477
547
  <div class="flex items-center gap-2">
478
- <UiToggle disabled aria-label="Underline" @update:model-value="onUpdate">
479
- <UiIcon name="underline" />
548
+ <UiToggle disabled left-icon="chevron-up" right-icon="chevron-down" @update:model-value="onUpdate">
549
+ Filter
480
550
  </UiToggle>
481
- <UiToggle disabled default-value aria-label="Strikethrough" @update:model-value="onUpdate">
482
- <UiIcon name="strikethrough" />
551
+ <UiToggle disabled default-value left-icon="chevron-up" right-icon="chevron-down" @update:model-value="onUpdate">
552
+ Sort
483
553
  </UiToggle>
484
554
  </div>
485
555
  `,
@@ -498,8 +568,8 @@ export const Disabled: Story = {
498
568
  // so the snapshot stays stable.
499
569
  onUpdate.mockClear();
500
570
  const canvas = within(canvasElement);
501
- const unpressed = canvas.getByRole('button', { name: 'Underline' });
502
- const pressed = canvas.getByRole('button', { name: 'Strikethrough' });
571
+ const unpressed = canvas.getByRole('button', { name: 'Filter' });
572
+ const pressed = canvas.getByRole('button', { name: 'Sort' });
503
573
 
504
574
  await step(
505
575
  'interaction: both toggles report the disabled state (WCAG 4.1.2)',
@@ -540,7 +610,7 @@ export const Disabled: Story = {
540
610
  };
541
611
 
542
612
  const allStatesTemplateSource = `<script setup lang="ts">
543
- import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
613
+ import { UiToggle } from '@aleph-alpha/ui-library'
544
614
  </script>
545
615
 
546
616
  <template>
@@ -549,31 +619,41 @@ import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
549
619
  <div>
550
620
  <p class="body-14-medium mb-2">Variants</p>
551
621
  <div class="flex items-center gap-2">
552
- <UiToggle aria-label="Bold"><UiIcon name="bold" /></UiToggle>
553
- <UiToggle default-value aria-label="Bold"><UiIcon name="bold" /></UiToggle>
554
- <UiToggle variant="outline" aria-label="Italic"><UiIcon name="italic" /></UiToggle>
555
- <UiToggle variant="outline" default-value aria-label="Italic"><UiIcon name="italic" /></UiToggle>
556
- <UiToggle variant="soft" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
557
- <UiToggle variant="soft" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
622
+ <UiToggle left-icon="chevron-up" right-icon="chevron-down">Filter</UiToggle>
623
+ <UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">Filter</UiToggle>
624
+ <UiToggle variant="ghost" left-icon="chevron-up" right-icon="chevron-down">Sort</UiToggle>
625
+ <UiToggle variant="ghost" default-value left-icon="chevron-up" right-icon="chevron-down">Sort</UiToggle>
626
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">Columns</UiToggle>
627
+ <UiToggle variant="outline" default-value left-icon="chevron-up" right-icon="chevron-down">Columns</UiToggle>
628
+ </div>
629
+ </div>
630
+
631
+ <!-- Pressed fill: muted surface vs the soft overlay used by menu triggers -->
632
+ <div>
633
+ <p class="body-14-medium mb-2">Pressed fill</p>
634
+ <div class="flex items-center gap-2">
635
+ <UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">Density</UiToggle>
636
+ <UiToggle soft default-value left-icon="chevron-up" right-icon="chevron-down">Density</UiToggle>
558
637
  </div>
559
638
  </div>
560
639
 
561
640
  <!-- Sizes -->
562
641
  <div>
563
642
  <p class="body-14-medium mb-2">Sizes</p>
564
- <div class="flex items-end gap-2">
565
- <UiToggle size="sm" aria-label="Align left"><UiIcon name="align-left" /></UiToggle>
566
- <UiToggle aria-label="Align center"><UiIcon name="align-center" /></UiToggle>
567
- <UiToggle size="lg" aria-label="Align right"><UiIcon name="align-right" /></UiToggle>
643
+ <div class="flex items-center gap-2">
644
+ <UiToggle size="sm" left-icon="chevron-up" right-icon="chevron-down">Small</UiToggle>
645
+ <UiToggle left-icon="chevron-up" right-icon="chevron-down">Default</UiToggle>
646
+ <UiToggle size="lg" left-icon="chevron-up" right-icon="chevron-down">Large</UiToggle>
568
647
  </div>
569
648
  </div>
570
649
 
571
- <!-- With text -->
650
+ <!-- Label only, and icon only -->
572
651
  <div>
573
- <p class="body-14-medium mb-2">With Text</p>
652
+ <p class="body-14-medium mb-2">Without both icons</p>
574
653
  <div class="flex items-center gap-2">
575
- <UiToggle><UiIcon name="italic" /> Italic</UiToggle>
576
- <UiToggle default-value><UiIcon name="italic" /> Italic</UiToggle>
654
+ <UiToggle>Rows</UiToggle>
655
+ <UiToggle default-value>Rows</UiToggle>
656
+ <UiToggle left-icon="chevron-down" aria-label="Expand" />
577
657
  </div>
578
658
  </div>
579
659
 
@@ -581,66 +661,75 @@ import { UiToggle, UiIcon } from '@aleph-alpha/ui-library'
581
661
  <div>
582
662
  <p class="body-14-medium mb-2">Disabled</p>
583
663
  <div class="flex items-center gap-2">
584
- <UiToggle disabled aria-label="Underline"><UiIcon name="underline" /></UiToggle>
585
- <UiToggle disabled default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
586
- <UiToggle disabled variant="outline" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
587
- <UiToggle disabled variant="outline" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
588
- <UiToggle disabled variant="soft" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
589
- <UiToggle disabled variant="soft" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
664
+ <UiToggle disabled left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
665
+ <UiToggle disabled default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
666
+ <UiToggle disabled variant="outline" left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
667
+ <UiToggle disabled variant="outline" default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
668
+ <UiToggle disabled soft left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
669
+ <UiToggle disabled soft default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
590
670
  </div>
591
671
  </div>
592
672
  </div>
593
673
  </template>`;
594
674
 
595
675
  /**
596
- * Every combination side by side: the three variants unpressed and pressed, the
597
- * three sizes, usage with text, and the disabled states. Each pressed toggle
598
- * sits next to its unpressed twin so the pressed styling can be compared
599
- * directly.
676
+ * Every combination side by side: the three variants unpressed and pressed,
677
+ * both pressed fills, the three sizes, the toggle without one or both icons,
678
+ * and the disabled states. Each pressed toggle sits next to its unpressed twin
679
+ * so the pressed styling can be compared directly.
600
680
  */
601
681
  export const AllStates: Story = {
602
682
  render: () => ({
603
- components: { UiToggle, UiIcon },
683
+ components: { UiToggle },
604
684
  template: `
605
685
  <div class="flex flex-col gap-6">
606
686
  <div>
607
687
  <p class="body-14-medium mb-2">Variants</p>
608
688
  <div class="flex items-center gap-2">
609
- <UiToggle aria-label="Bold"><UiIcon name="bold" /></UiToggle>
610
- <UiToggle default-value aria-label="Bold"><UiIcon name="bold" /></UiToggle>
611
- <UiToggle variant="outline" aria-label="Italic"><UiIcon name="italic" /></UiToggle>
612
- <UiToggle variant="outline" default-value aria-label="Italic"><UiIcon name="italic" /></UiToggle>
613
- <UiToggle variant="soft" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
614
- <UiToggle variant="soft" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
689
+ <UiToggle left-icon="chevron-up" right-icon="chevron-down">Filter</UiToggle>
690
+ <UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">Filter</UiToggle>
691
+ <UiToggle variant="ghost" left-icon="chevron-up" right-icon="chevron-down">Sort</UiToggle>
692
+ <UiToggle variant="ghost" default-value left-icon="chevron-up" right-icon="chevron-down">Sort</UiToggle>
693
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">Columns</UiToggle>
694
+ <UiToggle variant="outline" default-value left-icon="chevron-up" right-icon="chevron-down">Columns</UiToggle>
695
+ </div>
696
+ </div>
697
+
698
+ <div>
699
+ <p class="body-14-medium mb-2">Pressed fill</p>
700
+ <div class="flex items-center gap-2">
701
+ <UiToggle default-value left-icon="chevron-up" right-icon="chevron-down">Density</UiToggle>
702
+ <UiToggle soft default-value left-icon="chevron-up" right-icon="chevron-down">Density</UiToggle>
615
703
  </div>
616
704
  </div>
617
705
 
618
706
  <div>
619
707
  <p class="body-14-medium mb-2">Sizes</p>
620
- <div class="flex items-end gap-2">
621
- <UiToggle size="sm" aria-label="Align left"><UiIcon name="align-left" /></UiToggle>
622
- <UiToggle aria-label="Align center"><UiIcon name="align-center" /></UiToggle>
623
- <UiToggle size="lg" aria-label="Align right"><UiIcon name="align-right" /></UiToggle>
708
+ <div class="flex items-center gap-2">
709
+ <UiToggle variant="outline" size="sm" left-icon="chevron-up" right-icon="chevron-down">Small</UiToggle>
710
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">Default</UiToggle>
711
+ <UiToggle variant="outline" size="lg" left-icon="chevron-up" right-icon="chevron-down">Large</UiToggle>
624
712
  </div>
625
713
  </div>
626
714
 
627
715
  <div>
628
- <p class="body-14-medium mb-2">With Text</p>
716
+ <p class="body-14-medium mb-2">Without both icons</p>
629
717
  <div class="flex items-center gap-2">
630
- <UiToggle><UiIcon name="italic" /> Italic</UiToggle>
631
- <UiToggle default-value><UiIcon name="italic" /> Italic</UiToggle>
718
+ <UiToggle>Rows</UiToggle>
719
+ <UiToggle default-value>Rows</UiToggle>
720
+ <UiToggle left-icon="chevron-down" aria-label="Expand" />
632
721
  </div>
633
722
  </div>
634
723
 
635
724
  <div>
636
725
  <p class="body-14-medium mb-2">Disabled</p>
637
726
  <div class="flex items-center gap-2">
638
- <UiToggle disabled aria-label="Underline"><UiIcon name="underline" /></UiToggle>
639
- <UiToggle disabled default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
640
- <UiToggle disabled variant="outline" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
641
- <UiToggle disabled variant="outline" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
642
- <UiToggle disabled variant="soft" aria-label="Underline"><UiIcon name="underline" /></UiToggle>
643
- <UiToggle disabled variant="soft" default-value aria-label="Underline"><UiIcon name="underline" /></UiToggle>
727
+ <UiToggle disabled left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
728
+ <UiToggle disabled default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
729
+ <UiToggle disabled variant="outline" left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
730
+ <UiToggle disabled variant="outline" default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
731
+ <UiToggle disabled soft left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
732
+ <UiToggle disabled soft default-value left-icon="chevron-up" right-icon="chevron-down">Export</UiToggle>
644
733
  </div>
645
734
  </div>
646
735
  </div>
@@ -675,12 +764,23 @@ export const AllStates: Story = {
675
764
  'interaction: pressed and unpressed twins differ in state, not in name',
676
765
  async () => {
677
766
  const [unpressed, pressed] = canvas.getAllByRole('button', {
678
- name: 'Bold',
767
+ name: 'Filter',
679
768
  });
680
769
  await expect(unpressed).toHaveAttribute('aria-pressed', 'false');
681
770
  await expect(pressed).toHaveAttribute('aria-pressed', 'true');
682
771
  },
683
772
  );
773
+
774
+ await step(
775
+ 'interaction: the soft fill does not change what is announced',
776
+ async () => {
777
+ const [muted, soft] = canvas.getAllByRole('button', {
778
+ name: 'Density',
779
+ });
780
+ await expect(muted).toHaveAttribute('aria-pressed', 'true');
781
+ await expect(soft).toHaveAttribute('aria-pressed', 'true');
782
+ },
783
+ );
684
784
  },
685
785
  };
686
786
 
@@ -703,11 +803,11 @@ export const Accessibility: Story = {
703
803
  },
704
804
  },
705
805
  render: () => ({
706
- components: { UiToggle, UiIcon },
806
+ components: { UiToggle },
707
807
  setup() {
708
- const defaultBold = ref(true);
709
- const accessibleBold = ref(true);
710
- return { defaultBold, accessibleBold };
808
+ const defaultFilter = ref(true);
809
+ const accessibleFilter = ref(true);
810
+ return { defaultFilter, accessibleFilter };
711
811
  },
712
812
  template: `
713
813
  <section class="flex flex-col gap-6 p-4">
@@ -723,10 +823,11 @@ export const Accessibility: Story = {
723
823
  Name an icon-only toggle explicitly
724
824
  </h3>
725
825
  <p class="body-16-regular text-content-on-surface-primary">
726
- <code>UiIcon</code> renders <code>aria-hidden</code>, so a toggle
727
- that contains nothing but an icon has no accessible name. Give it
728
- an <code>aria-label</code>; without one, screen readers announce
729
- only "button".
826
+ <code>leftIcon</code> and <code>rightIcon</code> render
827
+ <code>aria-hidden</code>, so a toggle that carries nothing but a
828
+ chevron has no accessible name. Give it an
829
+ <code>aria-label</code>; without one, screen readers announce only
830
+ "button".
730
831
  </p>
731
832
  </div>
732
833
 
@@ -737,8 +838,8 @@ export const Accessibility: Story = {
737
838
  <p class="body-16-regular text-content-on-surface-primary">
738
839
  Pressed and unpressed are announced through
739
840
  <code>aria-pressed</code>, which the component sets for you. Label
740
- the toggle "Bold", not "Bold (pressed)" or "Turn bold off", so the
741
- name stays correct in both states.
841
+ the toggle "Filter", not "Filter (open)" or "Close filters", so
842
+ the name stays correct in both states.
742
843
  </p>
743
844
  </div>
744
845
 
@@ -747,24 +848,39 @@ export const Accessibility: Story = {
747
848
  Keep the visible text in the accessible name
748
849
  </h3>
749
850
  <p class="body-16-regular text-content-on-surface-primary">
750
- When the toggle has text, let that text be the name and skip the
751
- <code>aria-label</code>. An override that does not contain the
851
+ When the toggle has a label, let that text be the name and skip
852
+ the <code>aria-label</code>. An override that does not contain the
752
853
  visible words leaves speech-input users unable to activate the
753
854
  control by saying what they see (WCAG 2.5.3 Label in Name).
754
855
  </p>
755
856
  </div>
756
857
 
858
+ <div class="flex flex-col gap-2">
859
+ <h3 class="body-16-medium text-content-on-surface-primary">
860
+ A chevron is a hint, not the state
861
+ </h3>
862
+ <p class="body-16-regular text-content-on-surface-primary">
863
+ Chevrons suggest that something opens, but they are decorative and
864
+ never announced. Whether the toggle is pressed travels through
865
+ <code>aria-pressed</code> alone, so the icons may stay fixed — as
866
+ they do here — without costing assistive technology any
867
+ information.
868
+ </p>
869
+ </div>
870
+
757
871
  <div class="flex flex-col gap-2">
758
872
  <h3 class="body-16-medium text-content-on-surface-primary">
759
873
  Do not rely on the fill alone
760
874
  </h3>
761
875
  <p class="body-16-regular text-content-on-surface-primary">
762
- The default variant is borderless until it is pressed, so the only
763
- visual difference is the accent fill. That is fine for sighted
764
- users because <code>aria-pressed</code> carries the same
876
+ The default variant is borderless until it is pressed, and
877
+ <code>soft</code> makes that fill quieter still. Both are fine for
878
+ sighted users because <code>aria-pressed</code> carries the same
765
879
  information to everyone else (WCAG 1.4.1 Use of Color) — but in a
766
880
  dense toolbar prefer the <code>outline</code> variant so the
767
- unpressed buttons stay discoverable.
881
+ unpressed buttons stay discoverable, and keep
882
+ <code>soft</code> for menu triggers, where the open menu is itself
883
+ a second signal.
768
884
  </p>
769
885
  </div>
770
886
 
@@ -773,9 +889,9 @@ export const Accessibility: Story = {
773
889
  All three sizes are large enough to tap
774
890
  </h3>
775
891
  <p class="body-16-regular text-content-on-surface-primary">
776
- Small is 32×32px, default 36×36px and large 40×40px, so every size
777
- clears the 24×24px floor in WCAG 2.5.8 Target Size (Minimum)
778
- without extra padding.
892
+ The sizes differ in padding rather than in a fixed box, and every
893
+ one of them clears the 24×24px floor in WCAG 2.5.8 Target Size
894
+ (Minimum) without extra spacing around the button.
779
895
  </p>
780
896
  </div>
781
897
 
@@ -797,15 +913,13 @@ export const Accessibility: Story = {
797
913
  Default
798
914
  </h3>
799
915
  <div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
800
- <UiToggle v-model="defaultBold" variant="outline" aria-label="Bold">
801
- <UiIcon name="bold" />
802
- </UiToggle>
803
- <UiToggle variant="outline" aria-label="Italic">
804
- <UiIcon name="italic" />
916
+ <UiToggle v-model="defaultFilter" variant="outline" left-icon="chevron-up" right-icon="chevron-down">
917
+ Filter
805
918
  </UiToggle>
806
- <UiToggle variant="outline" aria-label="Underline">
807
- <UiIcon name="underline" />
919
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">
920
+ Sort
808
921
  </UiToggle>
922
+ <UiToggle variant="outline" left-icon="columns3" aria-label="Columns" />
809
923
  </div>
810
924
  </div>
811
925
 
@@ -814,15 +928,13 @@ export const Accessibility: Story = {
814
928
  Accessible
815
929
  </h3>
816
930
  <div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
817
- <UiToggle v-model="accessibleBold" variant="outline" aria-label="Bold">
818
- <UiIcon name="bold" />
819
- </UiToggle>
820
- <UiToggle variant="outline" aria-label="Italic">
821
- <UiIcon name="italic" />
931
+ <UiToggle v-model="accessibleFilter" variant="outline" left-icon="chevron-up" right-icon="chevron-down">
932
+ Filter
822
933
  </UiToggle>
823
- <UiToggle variant="outline" aria-label="Underline">
824
- <UiIcon name="underline" />
934
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">
935
+ Sort
825
936
  </UiToggle>
937
+ <UiToggle variant="outline" left-icon="columns3" aria-label="Columns" />
826
938
  </div>
827
939
  </div>
828
940
  </div>
@@ -837,53 +949,64 @@ export const Accessibility: Story = {
837
949
  // in the automated report under their `test - …` name. `name`/`tags` must be
838
950
  // literal properties so Storybook's static CSF indexer can read them.
839
951
 
840
- // Shared render for the test scenarios: a formatting toolbar with an icon-only
841
- // toggle that starts unpressed, one that starts pressed, one labelled by its
842
- // visible text, and a disabled one — a single fixture covering naming, both
843
- // resting states, activation, and the disabled guard. The three sizes sit
844
- // alongside so the target-size checks have something to measure.
952
+ // Shared render for the test scenarios: a filter bar with a menu trigger that
953
+ // starts unpressed, one that starts pressed, an icon-only one, and a disabled
954
+ // one — a single fixture covering naming, both resting states, activation, and
955
+ // the disabled guard. The three sizes sit alongside so the target-size checks
956
+ // have something to measure.
845
957
  function renderTestToggles() {
846
958
  return {
847
959
  components: { UiToggle, UiIcon },
848
960
  setup() {
849
- const bold = ref(false);
850
- return { bold, onUpdate };
961
+ const filter = ref(false);
962
+ return { filter, onUpdate };
851
963
  },
852
964
  template: `
853
965
  <div class="flex flex-col items-start gap-4">
854
966
  <div class="flex items-center gap-2">
855
967
  <UiToggle
856
- v-model="bold"
968
+ v-model="filter"
857
969
  variant="outline"
858
- aria-label="Bold"
970
+ left-icon="chevron-up"
971
+ right-icon="chevron-down"
859
972
  @update:model-value="onUpdate"
860
973
  >
861
- <UiIcon name="bold" />
974
+ Filter
862
975
  </UiToggle>
863
976
 
864
- <UiToggle variant="outline" default-value aria-label="Italic">
865
- <UiIcon name="italic" />
977
+ <UiToggle
978
+ variant="outline"
979
+ default-value
980
+ left-icon="chevron-up"
981
+ right-icon="chevron-down"
982
+ >
983
+ Sort
866
984
  </UiToggle>
867
985
 
868
- <UiToggle variant="outline">
869
- <UiIcon name="underline" />
870
- Underline
986
+ <UiToggle variant="outline" aria-label="Columns">
987
+ <UiIcon name="columns3" />
871
988
  </UiToggle>
872
989
 
873
- <UiToggle variant="outline" disabled default-value aria-label="Strikethrough">
874
- <UiIcon name="strikethrough" />
990
+ <UiToggle
991
+ variant="outline"
992
+ disabled
993
+ default-value
994
+ left-icon="chevron-up"
995
+ right-icon="chevron-down"
996
+ >
997
+ Density
875
998
  </UiToggle>
876
999
  </div>
877
1000
 
878
1001
  <div class="flex items-end gap-2">
879
- <UiToggle size="sm" variant="outline" aria-label="Align left">
880
- <UiIcon name="align-left" />
1002
+ <UiToggle size="sm" variant="outline" left-icon="chevron-up" right-icon="chevron-down">
1003
+ Small
881
1004
  </UiToggle>
882
- <UiToggle variant="outline" aria-label="Align center">
883
- <UiIcon name="align-center" />
1005
+ <UiToggle variant="outline" left-icon="chevron-up" right-icon="chevron-down">
1006
+ Default
884
1007
  </UiToggle>
885
- <UiToggle size="lg" variant="outline" aria-label="Align right">
886
- <UiIcon name="align-right" />
1008
+ <UiToggle size="lg" variant="outline" left-icon="chevron-up" right-icon="chevron-down">
1009
+ Large
887
1010
  </UiToggle>
888
1011
  </div>
889
1012
  </div>
@@ -911,20 +1034,20 @@ export const ToggleBehavior: Story = {
911
1034
  },
912
1035
  },
913
1036
  play: async ({ canvasElement, step }) => {
914
- // Scenario (Toggle): a pointer user presses a toggle, releases it again,
1037
+ // Scenario (Toggle): a pointer user presses a trigger, releases it again,
915
1038
  // releases a second one that started pressed, and finds the disabled one
916
1039
  // unresponsive.
917
1040
  onUpdate.mockClear();
918
1041
  const canvas = within(canvasElement);
919
- const bold = canvas.getByRole('button', { name: 'Bold' });
920
- const italic = canvas.getByRole('button', { name: 'Italic' });
1042
+ const filter = canvas.getByRole('button', { name: 'Filter' });
1043
+ const sort = canvas.getByRole('button', { name: 'Sort' });
921
1044
 
922
1045
  await step(
923
1046
  'interaction: activating the toggle presses it and emits the new value',
924
1047
  async () => {
925
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
926
- await userEvent.click(bold);
927
- await expect(bold).toHaveAttribute('aria-pressed', 'true');
1048
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
1049
+ await userEvent.click(filter);
1050
+ await expect(filter).toHaveAttribute('aria-pressed', 'true');
928
1051
  await expect(onUpdate).toHaveBeenCalledWith(true);
929
1052
  },
930
1053
  );
@@ -932,8 +1055,8 @@ export const ToggleBehavior: Story = {
932
1055
  await step(
933
1056
  'interaction: activating it again releases it back to unpressed',
934
1057
  async () => {
935
- await userEvent.click(bold);
936
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
1058
+ await userEvent.click(filter);
1059
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
937
1060
  await expect(onUpdate).toHaveBeenLastCalledWith(false);
938
1061
  },
939
1062
  );
@@ -941,35 +1064,32 @@ export const ToggleBehavior: Story = {
941
1064
  await step(
942
1065
  'interaction: a toggle that starts pressed releases independently',
943
1066
  async () => {
944
- await expect(italic).toHaveAttribute('aria-pressed', 'true');
945
- await userEvent.click(italic);
946
- await expect(italic).toHaveAttribute('aria-pressed', 'false');
1067
+ await expect(sort).toHaveAttribute('aria-pressed', 'true');
1068
+ await userEvent.click(sort);
1069
+ await expect(sort).toHaveAttribute('aria-pressed', 'false');
947
1070
  // The neighbour is untouched — these are independent toggles, not a
948
1071
  // radio group.
949
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
1072
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
950
1073
  },
951
1074
  );
952
1075
 
953
1076
  await step(
954
1077
  'interaction: a toggle with text is activated by clicking its label text',
955
1078
  async () => {
956
- const underline = canvas.getByRole('button', { name: 'Underline' });
957
- await userEvent.click(canvas.getByText('Underline'));
958
- await expect(underline).toHaveAttribute('aria-pressed', 'true');
1079
+ await userEvent.click(canvas.getByText('Sort'));
1080
+ await expect(sort).toHaveAttribute('aria-pressed', 'true');
959
1081
  },
960
1082
  );
961
1083
 
962
1084
  await step(
963
1085
  'interaction: a disabled toggle does not change state (WCAG 4.1.2)',
964
1086
  async () => {
965
- const strikethrough = canvas.getByRole('button', {
966
- name: 'Strikethrough',
967
- });
968
- await expect(strikethrough).toBeDisabled();
1087
+ const density = canvas.getByRole('button', { name: 'Density' });
1088
+ await expect(density).toBeDisabled();
969
1089
  // Disabled controls render with pointer-events: none, so bypass the
970
1090
  // check and assert the click is still a no-op.
971
- await userEvent.click(strikethrough, { pointerEventsCheck: 0 });
972
- await expect(strikethrough).toHaveAttribute('aria-pressed', 'true');
1091
+ await userEvent.click(density, { pointerEventsCheck: 0 });
1092
+ await expect(density).toHaveAttribute('aria-pressed', 'true');
973
1093
  },
974
1094
  );
975
1095
  },
@@ -995,20 +1115,20 @@ export const KeyboardNavigation: Story = {
995
1115
  },
996
1116
  },
997
1117
  play: async ({ canvasElement, step }) => {
998
- // Scenario (Toggle): a keyboard user tabs to the first toggle, presses it
999
- // with both Space and Enter, moves on through the toolbar, and never lands
1000
- // on the disabled toggle.
1118
+ // Scenario (Toggle): a keyboard user tabs to the first trigger, presses it
1119
+ // with both Space and Enter, moves on through the bar, and never lands on
1120
+ // the disabled toggle.
1001
1121
  onUpdate.mockClear();
1002
1122
  const canvas = within(canvasElement);
1003
- const bold = canvas.getByRole('button', { name: 'Bold' });
1004
- const italic = canvas.getByRole('button', { name: 'Italic' });
1005
- const strikethrough = canvas.getByRole('button', { name: 'Strikethrough' });
1123
+ const filter = canvas.getByRole('button', { name: 'Filter' });
1124
+ const sort = canvas.getByRole('button', { name: 'Sort' });
1125
+ const density = canvas.getByRole('button', { name: 'Density' });
1006
1126
 
1007
1127
  await step(
1008
1128
  'keyboard: the toggle is reachable with Tab (WCAG 2.1.1 Keyboard)',
1009
1129
  async () => {
1010
1130
  await userEvent.tab();
1011
- await expect(bold).toHaveFocus();
1131
+ await expect(filter).toHaveFocus();
1012
1132
  },
1013
1133
  );
1014
1134
 
@@ -1016,7 +1136,7 @@ export const KeyboardNavigation: Story = {
1016
1136
  'keyboard: the focused toggle shows a visible focus indicator (WCAG 2.4.7)',
1017
1137
  async () => {
1018
1138
  // `ui-focus-ring` replaces the browser default with the library ring.
1019
- const { boxShadow, outlineStyle } = getComputedStyle(bold);
1139
+ const { boxShadow, outlineStyle } = getComputedStyle(filter);
1020
1140
  await expect(outlineStyle).toBe('none');
1021
1141
  await expect(boxShadow).not.toBe('none');
1022
1142
  },
@@ -1024,13 +1144,13 @@ export const KeyboardNavigation: Story = {
1024
1144
 
1025
1145
  await step('keyboard: Space presses the toggle', async () => {
1026
1146
  await userEvent.keyboard(' ');
1027
- await expect(bold).toHaveAttribute('aria-pressed', 'true');
1147
+ await expect(filter).toHaveAttribute('aria-pressed', 'true');
1028
1148
  await expect(onUpdate).toHaveBeenCalledWith(true);
1029
1149
  });
1030
1150
 
1031
1151
  await step('keyboard: Enter releases it again', async () => {
1032
1152
  await userEvent.keyboard('{Enter}');
1033
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
1153
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
1034
1154
  await expect(onUpdate).toHaveBeenLastCalledWith(false);
1035
1155
  });
1036
1156
 
@@ -1038,13 +1158,13 @@ export const KeyboardNavigation: Story = {
1038
1158
  'keyboard: Tab follows DOM order and skips the disabled toggle (WCAG 2.4.3 Focus Order)',
1039
1159
  async () => {
1040
1160
  await userEvent.tab();
1041
- await expect(italic).toHaveFocus();
1161
+ await expect(sort).toHaveFocus();
1042
1162
  await userEvent.tab();
1043
1163
  await expect(
1044
- canvas.getByRole('button', { name: 'Underline' }),
1164
+ canvas.getByRole('button', { name: 'Columns' }),
1045
1165
  ).toHaveFocus();
1046
1166
  await userEvent.tab();
1047
- await expect(strikethrough).not.toHaveFocus();
1167
+ await expect(density).not.toHaveFocus();
1048
1168
  },
1049
1169
  );
1050
1170
  },
@@ -1072,10 +1192,10 @@ export const ScreenReader: Story = {
1072
1192
  // Scenario (Toggle): assistive tech reads each control as a toggle button
1073
1193
  // with a name, and is told which are pressed and which are unavailable.
1074
1194
  const canvas = within(canvasElement);
1075
- const bold = canvas.getByRole('button', { name: 'Bold' });
1076
- const italic = canvas.getByRole('button', { name: 'Italic' });
1077
- const underline = canvas.getByRole('button', { name: 'Underline' });
1078
- const strikethrough = canvas.getByRole('button', { name: 'Strikethrough' });
1195
+ const filter = canvas.getByRole('button', { name: 'Filter' });
1196
+ const sort = canvas.getByRole('button', { name: 'Sort' });
1197
+ const columns = canvas.getByRole('button', { name: 'Columns' });
1198
+ const density = canvas.getByRole('button', { name: 'Density' });
1079
1199
 
1080
1200
  await step(
1081
1201
  'screen-reader: every control exposes a button role (WCAG 4.1.2)',
@@ -1089,40 +1209,45 @@ export const ScreenReader: Story = {
1089
1209
  await step(
1090
1210
  'screen-reader: an icon-only toggle is named by its aria-label (WCAG 1.1.1)',
1091
1211
  async () => {
1092
- await expect(bold).toHaveAccessibleName('Bold');
1093
- await expect(italic).toHaveAccessibleName('Italic');
1212
+ await expect(columns).toHaveAccessibleName('Columns');
1213
+ await expect(columns.querySelector('svg')).toHaveAttribute(
1214
+ 'aria-hidden',
1215
+ 'true',
1216
+ );
1094
1217
  },
1095
1218
  );
1096
1219
 
1097
1220
  await step(
1098
- 'screen-reader: a toggle with text is named by that text (WCAG 2.5.3)',
1221
+ 'screen-reader: a toggle with text is named by that text alone (WCAG 2.5.3)',
1099
1222
  async () => {
1100
- await expect(underline).toHaveAccessibleName('Underline');
1101
- await expect(underline).not.toHaveAttribute('aria-label');
1223
+ // The chevrons are decorative, so the name is the label and nothing
1224
+ // else.
1225
+ await expect(filter).toHaveAccessibleName('Filter');
1226
+ await expect(filter).not.toHaveAttribute('aria-label');
1102
1227
  },
1103
1228
  );
1104
1229
 
1105
1230
  await step(
1106
1231
  'screen-reader: the pressed and unpressed states are announced (WCAG 4.1.2)',
1107
1232
  async () => {
1108
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
1109
- await expect(italic).toHaveAttribute('aria-pressed', 'true');
1233
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
1234
+ await expect(sort).toHaveAttribute('aria-pressed', 'true');
1110
1235
  },
1111
1236
  );
1112
1237
 
1113
1238
  await step(
1114
1239
  'screen-reader: an unavailable toggle announces its disabled state (WCAG 4.1.2)',
1115
1240
  async () => {
1116
- await expect(strikethrough).toBeDisabled();
1117
- await expect(strikethrough).toHaveAttribute('aria-pressed', 'true');
1241
+ await expect(density).toBeDisabled();
1242
+ await expect(density).toHaveAttribute('aria-pressed', 'true');
1118
1243
  },
1119
1244
  );
1120
1245
 
1121
1246
  await step(
1122
1247
  'screen-reader: the announced state follows the interaction (WCAG 4.1.2)',
1123
1248
  async () => {
1124
- await userEvent.click(bold);
1125
- await expect(bold).toHaveAttribute('aria-pressed', 'true');
1249
+ await userEvent.click(filter);
1250
+ await expect(filter).toHaveAttribute('aria-pressed', 'true');
1126
1251
  },
1127
1252
  );
1128
1253
  },
@@ -1152,7 +1277,7 @@ export const ZoomMagnification: Story = {
1152
1277
  // Scenario (Toggle): at 200% page zoom every toggle keeps its name and
1153
1278
  // still presses.
1154
1279
  const canvas = within(canvasElement);
1155
- const bold = canvas.getByRole('button', { name: 'Bold' });
1280
+ const filter = canvas.getByRole('button', { name: 'Filter' });
1156
1281
 
1157
1282
  await step(
1158
1283
  'zoom: preview is magnified to 200% (WCAG 1.4.4 Resize Text)',
@@ -1168,13 +1293,13 @@ export const ZoomMagnification: Story = {
1168
1293
  await expect(toggle).toBeVisible();
1169
1294
  await expect(toggle).toHaveAccessibleName();
1170
1295
  }
1171
- await expect(canvas.getByText('Underline')).toBeVisible();
1296
+ await expect(canvas.getByText('Filter')).toBeVisible();
1172
1297
  },
1173
1298
  );
1174
1299
 
1175
1300
  await step('zoom: the toggle stays operable when magnified', async () => {
1176
- await userEvent.click(bold);
1177
- await expect(bold).toHaveAttribute('aria-pressed', 'true');
1301
+ await userEvent.click(filter);
1302
+ await expect(filter).toHaveAttribute('aria-pressed', 'true');
1178
1303
  });
1179
1304
  },
1180
1305
  };
@@ -1201,15 +1326,15 @@ export const MobileBreakpoint: Story = {
1201
1326
  },
1202
1327
  },
1203
1328
  play: async ({ canvasElement, step }) => {
1204
- // Scenario (Toggle): at the 320px mobile breakpoint the toolbar stays on
1329
+ // Scenario (Toggle): at the 320px mobile breakpoint the filter bar stays on
1205
1330
  // screen, every size is big enough to tap, and the toggle still presses by
1206
1331
  // touch and by keyboard.
1207
1332
  onUpdate.mockClear();
1208
1333
  const canvas = within(canvasElement);
1209
- const bold = canvas.getByRole('button', { name: 'Bold' });
1334
+ const filter = canvas.getByRole('button', { name: 'Filter' });
1210
1335
 
1211
1336
  await step(
1212
- 'mobile: the toolbar fits the 320px viewport without clipping (WCAG 1.4.10 Reflow)',
1337
+ 'mobile: the filter bar fits the 320px viewport without clipping (WCAG 1.4.10 Reflow)',
1213
1338
  async () => {
1214
1339
  for (const toggle of canvas.getAllByRole('button')) {
1215
1340
  await expect(toggle).toBeVisible();
@@ -1223,9 +1348,9 @@ export const MobileBreakpoint: Story = {
1223
1348
  await step(
1224
1349
  'mobile: every size meets the minimum touch-target size (WCAG 2.5.8)',
1225
1350
  async () => {
1226
- // sm is 32×32, default 36×36 and lg 40×40, so the toggle carries the
1227
- // target on its own without help from a surrounding label.
1228
- for (const name of ['Align left', 'Align center', 'Align right']) {
1351
+ // The sizes differ in padding, so each one carries the target on its
1352
+ // own without help from a surrounding label.
1353
+ for (const name of ['Small', 'Default', 'Large']) {
1229
1354
  const { width, height } = canvas
1230
1355
  .getByRole('button', { name })
1231
1356
  .getBoundingClientRect();
@@ -1239,9 +1364,9 @@ export const MobileBreakpoint: Story = {
1239
1364
  'mobile: stays keyboard operable — Tab focuses and Space presses (WCAG 2.1.1)',
1240
1365
  async () => {
1241
1366
  await userEvent.tab();
1242
- await expect(bold).toHaveFocus();
1367
+ await expect(filter).toHaveFocus();
1243
1368
  await userEvent.keyboard(' ');
1244
- await expect(bold).toHaveAttribute('aria-pressed', 'true');
1369
+ await expect(filter).toHaveAttribute('aria-pressed', 'true');
1245
1370
  await expect(onUpdate).toHaveBeenCalledWith(true);
1246
1371
  },
1247
1372
  );
@@ -1249,8 +1374,8 @@ export const MobileBreakpoint: Story = {
1249
1374
  await step(
1250
1375
  'mobile: tapping the toggle releases it at the 320px breakpoint',
1251
1376
  async () => {
1252
- await userEvent.click(bold);
1253
- await expect(bold).toHaveAttribute('aria-pressed', 'false');
1377
+ await userEvent.click(filter);
1378
+ await expect(filter).toHaveAttribute('aria-pressed', 'false');
1254
1379
  await expect(onUpdate).toHaveBeenLastCalledWith(false);
1255
1380
  },
1256
1381
  );