@aleph-alpha/ui-library 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/system/components/UiDropdownMenu/useMobileSubmenuPlacement.d.ts +1 -1
- package/dist/system/icons/story-sidebar-icons.json +74 -17
- package/dist/system/lib.js +1167 -1162
- package/dist/system/patterns/UiPlaceholder/types.d.ts +1 -0
- package/dist/system/story-sidebar-icons.json +74 -17
- package/package.json +8 -3
- package/src/components/UiAccordion/UiAccordion.guidance.md +66 -0
- package/src/components/UiAccordion/UiAccordion.stories.ts +131 -139
- package/src/components/UiAlert/UiAlert.guidance.md +66 -0
- package/src/components/UiAlert/UiAlert.stories.ts +167 -143
- package/src/components/UiAlertDialog/UiAlertDialog.guidance.md +66 -0
- package/src/components/UiAlertDialog/UiAlertDialog.stories.ts +136 -112
- package/src/components/UiAutocomplete/UiAutocomplete.guidance.md +66 -0
- package/src/components/UiAutocomplete/UiAutocomplete.stories.ts +123 -99
- package/src/components/UiAvatar/UiAvatar.guidance.md +63 -0
- package/src/components/UiAvatar/UiAvatar.stories.ts +340 -0
- package/src/components/UiAvatar/UiAvatarImage.vue +5 -1
- package/src/components/UiAvatar/__tests__/UiAvatar.test.ts +14 -0
- package/src/components/UiBadge/UiBadge.guidance.md +65 -0
- package/src/components/UiBadge/UiBadge.stories.ts +325 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.guidance.md +67 -0
- package/src/components/UiBreadcrumb/UiBreadcrumb.stories.ts +165 -141
- package/src/components/UiButton/UiButton.stories.ts +5 -2
- package/src/components/UiButtonGroup/UiButtonGroup.guidance.md +63 -0
- package/src/components/UiButtonGroup/UiButtonGroup.stories.ts +91 -67
- package/src/components/UiCalendar/UiCalendar.guidance.md +65 -0
- package/src/components/UiCalendar/UiCalendar.stories.ts +103 -110
- package/src/components/UiCard/UiCard.guidance.md +65 -0
- package/src/components/UiCard/UiCard.stories.ts +393 -0
- package/src/components/UiCheckbox/UiCheckbox.guidance.md +62 -0
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +18 -56
- package/src/components/UiChip/UiChip.guidance.md +64 -0
- package/src/components/UiChip/UiChip.stories.ts +162 -138
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +291 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +2 -1
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +18 -0
- package/src/components/UiDialog/UiDialog.guidance.md +66 -0
- package/src/components/UiDialog/UiDialog.stories.ts +90 -66
- package/src/components/UiDrawer/UiDrawer.guidance.md +66 -0
- package/src/components/UiDrawer/UiDrawer.stories.ts +186 -162
- package/src/components/UiDropdownMenu/UiDropdownMenu.guidance.md +68 -0
- package/src/components/UiDropdownMenu/UiDropdownMenu.stories.ts +332 -85
- package/src/components/UiDropdownMenu/__tests__/UiDropdownMenu.test.ts +134 -0
- package/src/components/UiDropdownMenu/useMobileSubmenuPlacement.ts +23 -2
- package/src/components/UiEmpty/UiEmpty.guidance.md +66 -0
- package/src/components/UiEmpty/UiEmpty.stories.ts +370 -15
- package/src/components/UiFadeMask/UiFadeMask.stories.ts +66 -0
- package/src/components/UiField/UiField.guidance.md +63 -0
- package/src/components/UiField/UiField.stories.ts +90 -113
- package/src/components/UiFileType/UiFileType.stories.ts +254 -0
- package/src/components/UiFileUploadBox/UiFileUploadBox.stories.ts +74 -72
- package/src/components/UiIcon/UiIcon.stories.ts +256 -1
- package/src/components/UiInput/UiInput.guidance.md +64 -0
- package/src/components/UiInput/UiInput.stories.ts +132 -80
- package/src/components/UiInputGroup/UiInputGroup.guidance.md +66 -0
- package/src/components/UiInputGroup/UiInputGroup.stories.ts +127 -103
- package/src/components/UiItem/UiItem.guidance.md +66 -0
- package/src/components/UiItem/UiItem.stories.ts +81 -28
- package/src/components/UiKbd/UiKbd.guidance.md +65 -0
- package/src/components/UiKbd/UiKbd.stories.ts +373 -3
- package/src/components/UiLabel/UiLabel.guidance.md +65 -0
- package/src/components/UiLabel/UiLabel.stories.ts +163 -139
- package/src/components/UiListbox/UiListbox.stories.ts +197 -195
- package/src/components/UiNavigationMenu/UiNavigationMenu.guidance.md +66 -0
- package/src/components/UiNavigationMenu/UiNavigationMenu.stories.ts +169 -169
- package/src/components/UiPopover/UiPopover.guidance.md +65 -0
- package/src/components/UiPopover/UiPopover.stories.ts +115 -91
- package/src/components/UiProgress/UiProgress.guidance.md +65 -0
- package/src/components/UiProgress/UiProgress.stories.ts +300 -0
- package/src/components/UiRadioGroup/UiRadioGroup.guidance.md +66 -0
- package/src/components/UiRadioGroup/UiRadioGroup.stories.ts +163 -139
- package/src/components/UiRangeCalendar/UiRangeCalendar.stories.ts +128 -127
- package/src/components/UiResizable/UiResizable.guidance.md +65 -0
- package/src/components/UiResizable/UiResizable.stories.ts +176 -152
- package/src/components/UiSelect/UiSelect.guidance.md +66 -0
- package/src/components/UiSelect/UiSelect.stories.ts +150 -126
- package/src/components/UiSeparator/UiSeparator.guidance.md +64 -0
- package/src/components/UiSeparator/UiSeparator.stories.ts +350 -0
- package/src/components/UiSheet/UiSheet.guidance.md +66 -0
- package/src/components/UiSheet/UiSheet.stories.ts +194 -170
- package/src/components/UiSkeleton/UiSkeleton.guidance.md +65 -0
- package/src/components/UiSkeleton/UiSkeleton.stories.ts +253 -0
- package/src/components/UiSlider/UiSlider.guidance.md +66 -0
- package/src/components/UiSlider/UiSlider.stories.ts +150 -126
- package/src/components/UiSnackbar/UiSnackbar.guidance.md +66 -0
- package/src/components/UiSnackbar/UiSnackbar.stories.ts +106 -96
- package/src/components/UiSpinner/UiSpinner.guidance.md +65 -0
- package/src/components/UiSpinner/UiSpinner.stories.ts +249 -0
- package/src/components/UiStepper/UiStepper.guidance.md +66 -0
- package/src/components/UiStepper/UiStepper.stories.ts +142 -124
- package/src/components/UiSwitch/UiSwitch.guidance.md +66 -0
- package/src/components/UiSwitch/UiSwitch.stories.ts +170 -146
- package/src/components/UiTable/UiTable.guidance.md +66 -0
- package/src/components/UiTable/UiTable.stories.ts +530 -12
- package/src/components/UiTabs/UiTabs.guidance.md +66 -0
- package/src/components/UiTabs/UiTabs.stories.ts +174 -150
- package/src/components/UiTagsInput/UiTagsInput.stories.ts +154 -152
- package/src/components/UiTextarea/UiTextarea.guidance.md +66 -0
- package/src/components/UiTextarea/UiTextarea.stories.ts +86 -62
- package/src/components/UiToggle/UiToggle.guidance.md +66 -0
- package/src/components/UiToggle/UiToggle.stories.ts +183 -159
- package/src/components/UiToggleGroup/UiToggleGroup.guidance.md +64 -0
- package/src/components/UiToggleGroup/UiToggleGroup.stories.ts +222 -200
- package/src/components/UiTooltip/UiTooltip.guidance.md +66 -0
- package/src/components/UiTooltip/UiTooltip.stories.ts +90 -66
- package/src/patterns/UiDataTable/UiDataTable.guidance.md +66 -0
- package/src/patterns/UiDataTable/UiDataTable.stories.ts +177 -155
- package/src/patterns/UiDatePicker/UiDatePicker.guidance.md +66 -0
- package/src/patterns/UiDatePicker/UiDatePicker.stories.ts +136 -112
- package/src/patterns/UiFileUpload/UiFileItem.stories.ts +77 -75
- package/src/patterns/UiFileUpload/UiFileUpload.guidance.md +68 -0
- package/src/patterns/UiFileUpload/UiFileUpload.stories.ts +169 -145
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +103 -101
- package/src/patterns/UiLayout/UiLayoutContent.stories.ts +14 -13
- package/src/patterns/UiLayout/UiLayoutMobile.stories.ts +65 -65
- package/src/patterns/UiPlaceholder/types.ts +1 -0
- package/src/patterns/UiProfileCard/UiProfileCard.stories.ts +74 -72
- package/src/patterns/UiTopBar/UiTopBar.stories.ts +84 -82
|
@@ -4,6 +4,16 @@ import { ref } from 'vue';
|
|
|
4
4
|
import UiToggle from './UiToggle.vue';
|
|
5
5
|
import { UiIcon } from '../UiIcon';
|
|
6
6
|
import { ChevronDownIcon, ChevronUpIcon } from '@/icons/lucide';
|
|
7
|
+
import {
|
|
8
|
+
accessibilityRequirementsTemplate,
|
|
9
|
+
designNotesStory,
|
|
10
|
+
guidanceLinks,
|
|
11
|
+
guidanceSectionClass,
|
|
12
|
+
parseGuidance,
|
|
13
|
+
} from '../../../.storybook/guidance';
|
|
14
|
+
import guidanceMarkdown from './UiToggle.guidance.md?raw';
|
|
15
|
+
|
|
16
|
+
const guidance = parseGuidance(guidanceMarkdown);
|
|
7
17
|
|
|
8
18
|
/**
|
|
9
19
|
* UiToggle is a button that maintains a pressed/unpressed state.
|
|
@@ -50,6 +60,9 @@ const meta: Meta<typeof UiToggle> = {
|
|
|
50
60
|
rightIcon: ChevronDownIcon,
|
|
51
61
|
disabled: false,
|
|
52
62
|
},
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: { links: guidanceLinks(guidance) },
|
|
65
|
+
},
|
|
53
66
|
};
|
|
54
67
|
|
|
55
68
|
export default meta;
|
|
@@ -122,6 +135,176 @@ export const Default: Story = {
|
|
|
122
135
|
},
|
|
123
136
|
};
|
|
124
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Usage, guidelines, and do's and don'ts from the Figma documentation.
|
|
140
|
+
*/
|
|
141
|
+
export const DesignNotes: Story = {
|
|
142
|
+
...designNotesStory(guidance),
|
|
143
|
+
tags: ['!autodocs'],
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Accessibility guidance for toggle buttons: an explicit name when the toggle
|
|
148
|
+
* is icon-only, a name that describes the control rather than its state, and a
|
|
149
|
+
* pressed state that survives without colour — shown side by side in the
|
|
150
|
+
* default and accessible themes.
|
|
151
|
+
*/
|
|
152
|
+
export const Accessibility: Story = {
|
|
153
|
+
tags: ['!autodocs'],
|
|
154
|
+
parameters: {
|
|
155
|
+
surface: 'primary',
|
|
156
|
+
a11y: { test: 'off' },
|
|
157
|
+
chromatic: { disableSnapshot: true },
|
|
158
|
+
controls: { disable: true },
|
|
159
|
+
docs: {
|
|
160
|
+
canvas: {
|
|
161
|
+
sourceState: 'none',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
render: () => ({
|
|
166
|
+
components: { UiToggle },
|
|
167
|
+
setup() {
|
|
168
|
+
const defaultFilter = ref(true);
|
|
169
|
+
const accessibleFilter = ref(true);
|
|
170
|
+
return { defaultFilter, accessibleFilter };
|
|
171
|
+
},
|
|
172
|
+
template: `
|
|
173
|
+
<section class="${guidanceSectionClass}">
|
|
174
|
+
<div>
|
|
175
|
+
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
176
|
+
Accessibility
|
|
177
|
+
</h2>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
${accessibilityRequirementsTemplate(guidance.accessibility, 'Requirements')}
|
|
181
|
+
|
|
182
|
+
<div class="flex flex-col gap-6">
|
|
183
|
+
<div class="flex flex-col gap-2">
|
|
184
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
185
|
+
Name an icon-only toggle explicitly
|
|
186
|
+
</h3>
|
|
187
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
188
|
+
<code>leftIcon</code> and <code>rightIcon</code> render
|
|
189
|
+
<code>aria-hidden</code>, so a toggle that carries nothing but a
|
|
190
|
+
chevron has no accessible name. Give it an
|
|
191
|
+
<code>aria-label</code>; without one, screen readers announce only
|
|
192
|
+
"button".
|
|
193
|
+
</p>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div class="flex flex-col gap-2">
|
|
197
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
198
|
+
Name the control, not its state
|
|
199
|
+
</h3>
|
|
200
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
201
|
+
Pressed and unpressed are announced through
|
|
202
|
+
<code>aria-pressed</code>, which the component sets for you. Label
|
|
203
|
+
the toggle "Filter", not "Filter (open)" or "Close filters", so
|
|
204
|
+
the name stays correct in both states.
|
|
205
|
+
</p>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div class="flex flex-col gap-2">
|
|
209
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
210
|
+
Keep the visible text in the accessible name
|
|
211
|
+
</h3>
|
|
212
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
213
|
+
When the toggle has a label, let that text be the name and skip
|
|
214
|
+
the <code>aria-label</code>. An override that does not contain the
|
|
215
|
+
visible words leaves speech-input users unable to activate the
|
|
216
|
+
control by saying what they see (WCAG 2.5.3 Label in Name).
|
|
217
|
+
</p>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div class="flex flex-col gap-2">
|
|
221
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
222
|
+
A chevron is a hint, not the state
|
|
223
|
+
</h3>
|
|
224
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
225
|
+
Chevrons suggest that something opens, but they are decorative and
|
|
226
|
+
never announced. Whether the toggle is pressed travels through
|
|
227
|
+
<code>aria-pressed</code> alone, so the icons may stay fixed — as
|
|
228
|
+
they do here — without costing assistive technology any
|
|
229
|
+
information.
|
|
230
|
+
</p>
|
|
231
|
+
</div>
|
|
232
|
+
|
|
233
|
+
<div class="flex flex-col gap-2">
|
|
234
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
235
|
+
Do not rely on the fill alone
|
|
236
|
+
</h3>
|
|
237
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
238
|
+
The default variant is borderless until it is pressed, and
|
|
239
|
+
<code>soft</code> makes that fill quieter still. Both are fine for
|
|
240
|
+
sighted users because <code>aria-pressed</code> carries the same
|
|
241
|
+
information to everyone else (WCAG 1.4.1 Use of Color) — but in a
|
|
242
|
+
dense toolbar prefer the <code>outline</code> variant so the
|
|
243
|
+
unpressed buttons stay discoverable, and keep
|
|
244
|
+
<code>soft</code> for menu triggers, where the open menu is itself
|
|
245
|
+
a second signal.
|
|
246
|
+
</p>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<div class="flex flex-col gap-2">
|
|
250
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
251
|
+
All three sizes are large enough to tap
|
|
252
|
+
</h3>
|
|
253
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
254
|
+
The sizes differ in padding rather than in a fixed box, and every
|
|
255
|
+
one of them clears the 24×24px floor in WCAG 2.5.8 Target Size
|
|
256
|
+
(Minimum) without extra spacing around the button.
|
|
257
|
+
</p>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<div class="flex flex-col gap-2">
|
|
261
|
+
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
262
|
+
Enable accessibility theme
|
|
263
|
+
</h3>
|
|
264
|
+
<p class="body-m-regular text-content-on-surface-primary">
|
|
265
|
+
When accessibility is required, enable our accessibility theme.
|
|
266
|
+
This increases contrast and makes sure there are no color contrast
|
|
267
|
+
issues.
|
|
268
|
+
</p>
|
|
269
|
+
</div>
|
|
270
|
+
</div>
|
|
271
|
+
|
|
272
|
+
<div class="grid gap-4 md:grid-cols-2">
|
|
273
|
+
<div class="flex flex-col gap-3">
|
|
274
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
275
|
+
Default
|
|
276
|
+
</h3>
|
|
277
|
+
<div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
|
|
278
|
+
<UiToggle v-model="defaultFilter" variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
279
|
+
Filter
|
|
280
|
+
</UiToggle>
|
|
281
|
+
<UiToggle variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
282
|
+
Sort
|
|
283
|
+
</UiToggle>
|
|
284
|
+
<UiToggle variant="outline" :left-icon="Columns3Icon" aria-label="Columns" />
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
|
|
288
|
+
<div class="accessible-theme flex flex-col gap-3">
|
|
289
|
+
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
290
|
+
Accessible
|
|
291
|
+
</h3>
|
|
292
|
+
<div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
|
|
293
|
+
<UiToggle v-model="accessibleFilter" variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
294
|
+
Filter
|
|
295
|
+
</UiToggle>
|
|
296
|
+
<UiToggle variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
297
|
+
Sort
|
|
298
|
+
</UiToggle>
|
|
299
|
+
<UiToggle variant="outline" :left-icon="Columns3Icon" aria-label="Columns" />
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</div>
|
|
303
|
+
</section>
|
|
304
|
+
`,
|
|
305
|
+
}),
|
|
306
|
+
};
|
|
307
|
+
|
|
125
308
|
const pressedTemplateSource = `<script setup lang="ts">
|
|
126
309
|
import { UiToggle } from '@aleph-alpha/ui-library'
|
|
127
310
|
import { ChevronDownIcon, ChevronUpIcon } from '@aleph-alpha/ui-library/icons'
|
|
@@ -795,165 +978,6 @@ export const AllStates: Story = {
|
|
|
795
978
|
},
|
|
796
979
|
};
|
|
797
980
|
|
|
798
|
-
/**
|
|
799
|
-
* Accessibility guidance for toggle buttons: an explicit name when the toggle
|
|
800
|
-
* is icon-only, a name that describes the control rather than its state, and a
|
|
801
|
-
* pressed state that survives without colour — shown side by side in the
|
|
802
|
-
* default and accessible themes.
|
|
803
|
-
*/
|
|
804
|
-
export const Accessibility: Story = {
|
|
805
|
-
tags: ['!autodocs'],
|
|
806
|
-
parameters: {
|
|
807
|
-
a11y: { test: 'off' },
|
|
808
|
-
chromatic: { disableSnapshot: true },
|
|
809
|
-
controls: { disable: true },
|
|
810
|
-
docs: {
|
|
811
|
-
canvas: {
|
|
812
|
-
sourceState: 'none',
|
|
813
|
-
},
|
|
814
|
-
},
|
|
815
|
-
},
|
|
816
|
-
render: () => ({
|
|
817
|
-
components: { UiToggle },
|
|
818
|
-
setup() {
|
|
819
|
-
const defaultFilter = ref(true);
|
|
820
|
-
const accessibleFilter = ref(true);
|
|
821
|
-
return { defaultFilter, accessibleFilter };
|
|
822
|
-
},
|
|
823
|
-
template: `
|
|
824
|
-
<section class="flex flex-col gap-6 p-4">
|
|
825
|
-
<div>
|
|
826
|
-
<h2 class="heading-m font-bold text-content-on-surface-primary">
|
|
827
|
-
Accessibility
|
|
828
|
-
</h2>
|
|
829
|
-
</div>
|
|
830
|
-
|
|
831
|
-
<div class="flex flex-col gap-6">
|
|
832
|
-
<div class="flex flex-col gap-2">
|
|
833
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
834
|
-
Name an icon-only toggle explicitly
|
|
835
|
-
</h3>
|
|
836
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
837
|
-
<code>leftIcon</code> and <code>rightIcon</code> render
|
|
838
|
-
<code>aria-hidden</code>, so a toggle that carries nothing but a
|
|
839
|
-
chevron has no accessible name. Give it an
|
|
840
|
-
<code>aria-label</code>; without one, screen readers announce only
|
|
841
|
-
"button".
|
|
842
|
-
</p>
|
|
843
|
-
</div>
|
|
844
|
-
|
|
845
|
-
<div class="flex flex-col gap-2">
|
|
846
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
847
|
-
Name the control, not its state
|
|
848
|
-
</h3>
|
|
849
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
850
|
-
Pressed and unpressed are announced through
|
|
851
|
-
<code>aria-pressed</code>, which the component sets for you. Label
|
|
852
|
-
the toggle "Filter", not "Filter (open)" or "Close filters", so
|
|
853
|
-
the name stays correct in both states.
|
|
854
|
-
</p>
|
|
855
|
-
</div>
|
|
856
|
-
|
|
857
|
-
<div class="flex flex-col gap-2">
|
|
858
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
859
|
-
Keep the visible text in the accessible name
|
|
860
|
-
</h3>
|
|
861
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
862
|
-
When the toggle has a label, let that text be the name and skip
|
|
863
|
-
the <code>aria-label</code>. An override that does not contain the
|
|
864
|
-
visible words leaves speech-input users unable to activate the
|
|
865
|
-
control by saying what they see (WCAG 2.5.3 Label in Name).
|
|
866
|
-
</p>
|
|
867
|
-
</div>
|
|
868
|
-
|
|
869
|
-
<div class="flex flex-col gap-2">
|
|
870
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
871
|
-
A chevron is a hint, not the state
|
|
872
|
-
</h3>
|
|
873
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
874
|
-
Chevrons suggest that something opens, but they are decorative and
|
|
875
|
-
never announced. Whether the toggle is pressed travels through
|
|
876
|
-
<code>aria-pressed</code> alone, so the icons may stay fixed — as
|
|
877
|
-
they do here — without costing assistive technology any
|
|
878
|
-
information.
|
|
879
|
-
</p>
|
|
880
|
-
</div>
|
|
881
|
-
|
|
882
|
-
<div class="flex flex-col gap-2">
|
|
883
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
884
|
-
Do not rely on the fill alone
|
|
885
|
-
</h3>
|
|
886
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
887
|
-
The default variant is borderless until it is pressed, and
|
|
888
|
-
<code>soft</code> makes that fill quieter still. Both are fine for
|
|
889
|
-
sighted users because <code>aria-pressed</code> carries the same
|
|
890
|
-
information to everyone else (WCAG 1.4.1 Use of Color) — but in a
|
|
891
|
-
dense toolbar prefer the <code>outline</code> variant so the
|
|
892
|
-
unpressed buttons stay discoverable, and keep
|
|
893
|
-
<code>soft</code> for menu triggers, where the open menu is itself
|
|
894
|
-
a second signal.
|
|
895
|
-
</p>
|
|
896
|
-
</div>
|
|
897
|
-
|
|
898
|
-
<div class="flex flex-col gap-2">
|
|
899
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
900
|
-
All three sizes are large enough to tap
|
|
901
|
-
</h3>
|
|
902
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
903
|
-
The sizes differ in padding rather than in a fixed box, and every
|
|
904
|
-
one of them clears the 24×24px floor in WCAG 2.5.8 Target Size
|
|
905
|
-
(Minimum) without extra spacing around the button.
|
|
906
|
-
</p>
|
|
907
|
-
</div>
|
|
908
|
-
|
|
909
|
-
<div class="flex flex-col gap-2">
|
|
910
|
-
<h3 class="body-m-medium text-content-on-surface-primary">
|
|
911
|
-
Enable accessibility theme
|
|
912
|
-
</h3>
|
|
913
|
-
<p class="body-m-regular text-content-on-surface-primary">
|
|
914
|
-
When accessibility is required, enable our accessibility theme.
|
|
915
|
-
This increases contrast and makes sure there are no color contrast
|
|
916
|
-
issues.
|
|
917
|
-
</p>
|
|
918
|
-
</div>
|
|
919
|
-
</div>
|
|
920
|
-
|
|
921
|
-
<div class="grid gap-4 md:grid-cols-2">
|
|
922
|
-
<div class="flex flex-col gap-3">
|
|
923
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
924
|
-
Default
|
|
925
|
-
</h3>
|
|
926
|
-
<div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
|
|
927
|
-
<UiToggle v-model="defaultFilter" variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
928
|
-
Filter
|
|
929
|
-
</UiToggle>
|
|
930
|
-
<UiToggle variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
931
|
-
Sort
|
|
932
|
-
</UiToggle>
|
|
933
|
-
<UiToggle variant="outline" :left-icon="Columns3Icon" aria-label="Columns" />
|
|
934
|
-
</div>
|
|
935
|
-
</div>
|
|
936
|
-
|
|
937
|
-
<div class="accessible-theme flex flex-col gap-3">
|
|
938
|
-
<h3 class="label-m-medium text-center text-content-on-surface-primary">
|
|
939
|
-
Accessible
|
|
940
|
-
</h3>
|
|
941
|
-
<div class="flex min-h-20 items-center justify-center gap-2 border border-border-surface-default p-6">
|
|
942
|
-
<UiToggle v-model="accessibleFilter" variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
943
|
-
Filter
|
|
944
|
-
</UiToggle>
|
|
945
|
-
<UiToggle variant="outline" :left-icon="ChevronUpIcon" :right-icon="ChevronDownIcon">
|
|
946
|
-
Sort
|
|
947
|
-
</UiToggle>
|
|
948
|
-
<UiToggle variant="outline" :left-icon="Columns3Icon" aria-label="Columns" />
|
|
949
|
-
</div>
|
|
950
|
-
</div>
|
|
951
|
-
</div>
|
|
952
|
-
</section>
|
|
953
|
-
`,
|
|
954
|
-
}),
|
|
955
|
-
};
|
|
956
|
-
|
|
957
981
|
// Test-only stories drive the test-runner (interactive/a11y checks) but are
|
|
958
982
|
// hidden from the Storybook sidebar and docs via the `!dev` / `!autodocs`
|
|
959
983
|
// tags. They keep the implicit `test` tag, so they still run in CI and appear
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
figma: '29211:71763'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<!-- Synced from Figma by scripts/sync-figma-docs.mjs. Edit the copy in Figma: changes made here are overwritten. -->
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
The Toggle Group component joins related toggles into a single control. The shared edge says these options belong to one question, and the pressed one answers it.
|
|
10
|
+
|
|
11
|
+
Use it where the options are few, short and best seen at once — a view mode, an alignment, a time range. Tabs switch what is displayed rather than setting a value, and Select is right once the list is long.
|
|
12
|
+
|
|
13
|
+
### One question, few answers
|
|
14
|
+
|
|
15
|
+
A toggle group only reads cleanly when it stays small:
|
|
16
|
+
|
|
17
|
+
- Every toggle answers the same question
|
|
18
|
+
- Labels are short and parallel, often a single word or icon
|
|
19
|
+
- One toggle is pressed at a time, unless the group is genuinely multi-select
|
|
20
|
+
- The group never grows past what fits on one line
|
|
21
|
+
|
|
22
|
+
### Width follows the layout
|
|
23
|
+
|
|
24
|
+
The group has two ways to size itself:
|
|
25
|
+
|
|
26
|
+
1. Hug where the group sits beside other controls
|
|
27
|
+
2. Fill where it spans a column or a panel
|
|
28
|
+
3. One width behaviour per context, so groups align
|
|
29
|
+
4. Going to Select rather than wrapping to a second line
|
|
30
|
+
|
|
31
|
+
### Consistency
|
|
32
|
+
|
|
33
|
+
Every toggle group is built from the same parts:
|
|
34
|
+
|
|
35
|
+
- Toggle group, hugging or filling its container
|
|
36
|
+
- Up to six toggles, of one variant and size
|
|
37
|
+
- A pressed state on the selected toggle
|
|
38
|
+
- One width behaviour per context
|
|
39
|
+
|
|
40
|
+
## Do
|
|
41
|
+
|
|
42
|
+
- Keep every toggle in the group answering the same question
|
|
43
|
+
- Use short, parallel labels, or icons with tooltips
|
|
44
|
+
- Use one variant and one size across the group
|
|
45
|
+
- Choose hug or fill by context, and keep it consistent
|
|
46
|
+
- Move to Select rather than letting the group wrap
|
|
47
|
+
|
|
48
|
+
## Don't
|
|
49
|
+
|
|
50
|
+
- Put unrelated options in one group
|
|
51
|
+
- Let the group wrap to a second line
|
|
52
|
+
- Mix variants or sizes inside a group
|
|
53
|
+
- Use a toggle group to switch views — use Tabs
|
|
54
|
+
- Leave the group with nothing pressed when a value is required
|
|
55
|
+
- Use icons with no tooltip where the meaning is not obvious
|
|
56
|
+
|
|
57
|
+
## Accessibility
|
|
58
|
+
|
|
59
|
+
- The pressed toggle differs from the others in fill and border, not colour alone
|
|
60
|
+
- Focus is visible on the individual toggle and never clipped by a neighbour's shared edge
|
|
61
|
+
- Every toggle keeps a comfortable target size where the shared edge tightens spacing
|
|
62
|
+
- Icon-only toggles carry a tooltip, so the set can be read
|
|
63
|
+
- The group reads left to right, in the order the options should be considered
|
|
64
|
+
- Disabled toggles in the group are distinguishable by more than reduced opacity
|