@sanity/ui 5.0.0-alpha.22 → 5.0.0-alpha.23

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 (127) hide show
  1. package/README.md +10 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/docs/components/avatar-counter.dsds.yaml +78 -0
  6. package/docs/components/avatar-stack.dsds.yaml +96 -0
  7. package/docs/components/avatar.dsds.yaml +115 -0
  8. package/docs/components/badge.dsds.yaml +126 -0
  9. package/docs/components/box.dsds.yaml +223 -0
  10. package/docs/components/button.dsds.yaml +284 -0
  11. package/docs/components/card.dsds.yaml +317 -0
  12. package/docs/components/checkbox.dsds.yaml +204 -0
  13. package/docs/components/code.dsds.yaml +167 -0
  14. package/docs/components/container.dsds.yaml +189 -0
  15. package/docs/components/dialog.dsds.yaml +343 -0
  16. package/docs/components/divider.dsds.yaml +93 -0
  17. package/docs/components/eyebrow.dsds.yaml +217 -0
  18. package/docs/components/flex.dsds.yaml +237 -0
  19. package/docs/components/grid.dsds.yaml +217 -0
  20. package/docs/components/h-stack.dsds.yaml +127 -0
  21. package/docs/components/heading.dsds.yaml +233 -0
  22. package/docs/components/hotkeys.dsds.yaml +60 -0
  23. package/docs/components/icon-button.dsds.yaml +220 -0
  24. package/docs/components/icon.dsds.yaml +275 -0
  25. package/docs/components/indicator-stack.dsds.yaml +98 -0
  26. package/docs/components/indicator.dsds.yaml +108 -0
  27. package/docs/components/inline.dsds.yaml +127 -0
  28. package/docs/components/kbd.dsds.yaml +59 -0
  29. package/docs/components/link.dsds.yaml +108 -0
  30. package/docs/components/list-button-item.dsds.yaml +103 -0
  31. package/docs/components/list-item-image.dsds.yaml +82 -0
  32. package/docs/components/list-item-text.dsds.yaml +80 -0
  33. package/docs/components/list-item.dsds.yaml +148 -0
  34. package/docs/components/list.dsds.yaml +162 -0
  35. package/docs/components/popover.dsds.yaml +208 -0
  36. package/docs/components/press-area.dsds.yaml +279 -0
  37. package/docs/components/radio.dsds.yaml +198 -0
  38. package/docs/components/select.dsds.yaml +214 -0
  39. package/docs/components/skip-to-content.dsds.yaml +110 -0
  40. package/docs/components/spinner.dsds.yaml +119 -0
  41. package/docs/components/switch.dsds.yaml +202 -0
  42. package/docs/components/tab.dsds.yaml +54 -0
  43. package/docs/components/tabs-list.dsds.yaml +56 -0
  44. package/docs/components/tabs-panel.dsds.yaml +54 -0
  45. package/docs/components/tabs.dsds.yaml +104 -0
  46. package/docs/components/text-area.dsds.yaml +170 -0
  47. package/docs/components/text-input.dsds.yaml +189 -0
  48. package/docs/components/text.dsds.yaml +268 -0
  49. package/docs/components/tooltip-group.dsds.yaml +90 -0
  50. package/docs/components/tooltip.dsds.yaml +216 -0
  51. package/docs/components/v-stack.dsds.yaml +155 -0
  52. package/docs/components/visually-hidden.dsds.yaml +112 -0
  53. package/docs/evals/cases.yaml +1319 -0
  54. package/docs/examples/checkbox-2.tsx +57 -0
  55. package/docs/examples/confirmation-dialogs-1.tsx +27 -0
  56. package/docs/examples/confirmation-dialogs-2.tsx +55 -0
  57. package/docs/examples/confirmation-dialogs-3.tsx +28 -0
  58. package/docs/examples/confirmation-dialogs-4.tsx +38 -0
  59. package/docs/examples/popover-1.tsx +48 -0
  60. package/docs/examples/popover-2.tsx +53 -0
  61. package/docs/foundations/accessibility-guidelines.dsds.yaml +301 -0
  62. package/docs/foundations/color-guidelines.dsds.yaml +308 -0
  63. package/docs/foundations/content-guidelines.dsds.yaml +285 -0
  64. package/docs/foundations/semantics.dsds.yaml +125 -0
  65. package/docs/foundations/spacing-guidelines.dsds.yaml +226 -0
  66. package/docs/foundations/typography-guidelines.dsds.yaml +322 -0
  67. package/docs/icons.dsds.yaml +2513 -0
  68. package/docs/index.dsds.yaml +515 -0
  69. package/docs/overview/api-essentials.dsds.yaml +221 -0
  70. package/docs/overview/component-reference.dsds.yaml +215 -0
  71. package/docs/overview/designer-contribution-model.dsds.yaml +77 -0
  72. package/docs/overview/developer-contribution-model.dsds.yaml +362 -0
  73. package/docs/overview/installation.dsds.yaml +238 -0
  74. package/docs/overview/quick-start.dsds.yaml +317 -0
  75. package/docs/overview/resources.dsds.yaml +34 -0
  76. package/docs/patterns/confirmation-dialogs.dsds.yaml +140 -0
  77. package/docs/patterns/error-messaging.dsds.yaml +58 -0
  78. package/docs/patterns/forms.dsds.yaml +356 -0
  79. package/docs/patterns/layouts.dsds.yaml +403 -0
  80. package/docs/patterns/loading-states.dsds.yaml +41 -0
  81. package/docs/patterns/messaging.dsds.yaml +72 -0
  82. package/docs/patterns/navigation.dsds.yaml +153 -0
  83. package/docs/patterns/responsive.dsds.yaml +590 -0
  84. package/docs/tokens/color.dsds.yaml +1158 -0
  85. package/docs/tokens/container-widths.dsds.yaml +131 -0
  86. package/docs/tokens/content.dsds.yaml +258 -0
  87. package/docs/tokens/content.tokens.json +180 -0
  88. package/docs/tokens/dtcg/README.md +39 -0
  89. package/docs/tokens/dtcg/css/color.css +107 -0
  90. package/docs/tokens/dtcg/css/container.css +12 -0
  91. package/docs/tokens/dtcg/css/fontFamily.css +10 -0
  92. package/docs/tokens/dtcg/css/fontWeight.css +10 -0
  93. package/docs/tokens/dtcg/css/index.css +13 -0
  94. package/docs/tokens/dtcg/css/radius.css +14 -0
  95. package/docs/tokens/dtcg/css/semantic.css +42 -0
  96. package/docs/tokens/dtcg/css/shadow.css +22 -0
  97. package/docs/tokens/dtcg/css/space.css +16 -0
  98. package/docs/tokens/dtcg/css/typography.css +69 -0
  99. package/docs/tokens/dtcg/json/color.tokens.json +911 -0
  100. package/docs/tokens/dtcg/json/container.tokens.json +44 -0
  101. package/docs/tokens/dtcg/json/fontFamily.tokens.json +10 -0
  102. package/docs/tokens/dtcg/json/fontWeight.tokens.json +18 -0
  103. package/docs/tokens/dtcg/json/radius.tokens.json +58 -0
  104. package/docs/tokens/dtcg/json/semantic.tokens.json +372 -0
  105. package/docs/tokens/dtcg/json/shadow.tokens.json +599 -0
  106. package/docs/tokens/dtcg/json/space.tokens.json +72 -0
  107. package/docs/tokens/dtcg/json/typography.tokens.json +354 -0
  108. package/docs/tokens/font-family.dsds.yaml +79 -0
  109. package/docs/tokens/font-weight.dsds.yaml +103 -0
  110. package/docs/tokens/radius.dsds.yaml +153 -0
  111. package/docs/tokens/semantic.dsds.yaml +397 -0
  112. package/docs/tokens/shadow.dsds.yaml +125 -0
  113. package/docs/tokens/space.dsds.yaml +185 -0
  114. package/docs/tokens/typography.dsds.yaml +316 -0
  115. package/llms.txt +108 -0
  116. package/package.json +5 -2
  117. package/skills/sanity-ui-5/SKILL.md +158 -0
  118. package/skills/sanity-ui-5/references/component-choice.md +37 -0
  119. package/skills/sanity-ui-5/references/components.md +145 -0
  120. package/skills/sanity-ui-5/references/forms-and-accessibility.md +189 -0
  121. package/skills/sanity-ui-5/references/migrating-from-v3.md +250 -0
  122. package/skills/sanity-ui-5/references/props-and-imports.md +169 -0
  123. package/skills/sanity-ui-5/references/setup.md +177 -0
  124. package/skills/sanity-ui-5/references/silent-failures.md +33 -0
  125. package/skills/sanity-ui-5/references/taste.md +53 -0
  126. package/skills/sanity-ui-5/references/tone-and-color.md +55 -0
  127. package/src/version.ts +2 -2
@@ -0,0 +1,57 @@
1
+ import {Checkbox} from '@sanity/ui'
2
+
3
+ // Row selection in a table. Each Checkbox is named by the row's name cell with
4
+ // aria-labelledby, so screen readers announce "Select Ada Lovelace" without printing
5
+ // the name beside every checkbox. The header checkbox has no visible text to point at,
6
+ // so it uses aria-label.
7
+ //
8
+ // The header checkbox is the "select all" parent: `indeterminate` renders the
9
+ // mixed mark when some but not all rows are selected. Set `checked` false
10
+ // while indeterminate is true — the mixed mark replaces the tick.
11
+
12
+ export function SelectableRows({
13
+ rows,
14
+ selected,
15
+ onToggleRow,
16
+ onToggleAll,
17
+ }: {
18
+ rows: {id: string; name: string}[]
19
+ selected: string[]
20
+ onToggleRow: (id: string) => void
21
+ onToggleAll: (checked: boolean) => void
22
+ }) {
23
+ const allSelected = rows.length > 0 && selected.length === rows.length
24
+ const someSelected = selected.length > 0 && !allSelected
25
+
26
+ return (
27
+ <table>
28
+ <thead>
29
+ <tr>
30
+ <th>
31
+ <Checkbox
32
+ aria-label="Select all rows"
33
+ checked={allSelected}
34
+ indeterminate={someSelected}
35
+ onChange={(event) => onToggleAll(event.currentTarget.checked)}
36
+ />
37
+ </th>
38
+ <th>Name</th>
39
+ </tr>
40
+ </thead>
41
+ <tbody>
42
+ {rows.map((row) => (
43
+ <tr key={row.id}>
44
+ <td>
45
+ <Checkbox
46
+ aria-labelledby={`row-${row.id}-name`}
47
+ checked={selected.includes(row.id)}
48
+ onChange={() => onToggleRow(row.id)}
49
+ />
50
+ </td>
51
+ <td id={`row-${row.id}-name`}>{row.name}</td>
52
+ </tr>
53
+ ))}
54
+ </tbody>
55
+ </table>
56
+ )
57
+ }
@@ -0,0 +1,27 @@
1
+ import {Button, Dialog, Flex, Text} from '@sanity/ui'
2
+
3
+ // A confirmation as a Dialog. A Dialog is a gating decision: it blocks the page until
4
+ // the user chooses.
5
+ export function DeleteDialog({
6
+ open,
7
+ onCancel,
8
+ onConfirm,
9
+ }: {
10
+ open: boolean
11
+ onCancel: () => void
12
+ onConfirm: () => void
13
+ }) {
14
+ return (
15
+ <Dialog header="Delete document?" open={open} onClose={onCancel}>
16
+ <Dialog.Content>
17
+ <Text>This can't be undone.</Text>
18
+ </Dialog.Content>
19
+ <Dialog.Footer>
20
+ <Flex gap={3} justifyContent="flex-end">
21
+ <Button text="Cancel" level="secondary" onClick={onCancel} />
22
+ <Button text="Delete" tone="critical" onClick={onConfirm} />
23
+ </Flex>
24
+ </Dialog.Footer>
25
+ </Dialog>
26
+ )
27
+ }
@@ -0,0 +1,55 @@
1
+ import {Popover, Box, VStack, Text, Button, Flex} from '@sanity/ui'
2
+ import {type ReactNode, useEffect, useRef} from 'react'
3
+
4
+ // Focuses the first button, Cancel, each time the panel opens. A destructive
5
+ // confirm should start on the safe action. See popover-1.tsx for why this uses an
6
+ // effect instead of autoFocus.
7
+ function FocusOnOpen({children}: {children: ReactNode}) {
8
+ const ref = useRef<HTMLDivElement>(null)
9
+
10
+ useEffect(() => {
11
+ ref.current?.querySelector<HTMLElement>('button')?.focus()
12
+ }, [])
13
+
14
+ return <div ref={ref}>{children}</div>
15
+ }
16
+
17
+ export function DeleteRowConfirm({onConfirm, message}: {onConfirm: () => void; message: string}) {
18
+ // Popover is uncontrolled — the trigger opens it and the browser closes it.
19
+ // There is no open/onClose prop, and Escape and outside-click dismissal come
20
+ // from the browser. To close it yourself after confirming, call the native
21
+ // popover API on the content element.
22
+ const contentRef = useRef<HTMLDivElement>(null)
23
+
24
+ return (
25
+ <Popover
26
+ placement="top"
27
+ content={
28
+ <Box ref={contentRef} padding={3}>
29
+ <FocusOnOpen>
30
+ <VStack gap={3}>
31
+ <Text size={1}>{message}</Text>
32
+ <Flex gap={2} justifyContent="flex-end">
33
+ <Button
34
+ text="Cancel"
35
+ level="secondary"
36
+ onClick={() => contentRef.current?.hidePopover()}
37
+ />
38
+ <Button
39
+ text="Delete"
40
+ tone="critical"
41
+ onClick={() => {
42
+ onConfirm()
43
+ contentRef.current?.hidePopover()
44
+ }}
45
+ />
46
+ </Flex>
47
+ </VStack>
48
+ </FocusOnOpen>
49
+ </Box>
50
+ }
51
+ >
52
+ <Button text="Delete" tone="critical" level="tertiary" />
53
+ </Popover>
54
+ )
55
+ }
@@ -0,0 +1,28 @@
1
+ import {Button} from '@sanity/ui'
2
+
3
+ // ✗ Confirm is available before the reference count resolves.
4
+ export function ConfirmImmediately({onConfirm}: {onConfirm: () => void}) {
5
+ return <Button text="Confirm" tone="critical" onClick={onConfirm} />
6
+ }
7
+
8
+ // ✓ Confirm waits for the count, and names the consequence directly. The button
9
+ // stays focusable while it is blocked: aria-disabled blocks the action, and the
10
+ // click handler does nothing until the count arrives.
11
+ export function ConfirmAfterCount({
12
+ referenceCount,
13
+ onConfirm,
14
+ }: {
15
+ referenceCount: number | null
16
+ onConfirm: () => void
17
+ }) {
18
+ const ready = referenceCount != null
19
+
20
+ return (
21
+ <Button
22
+ text={ready ? `Delete (${referenceCount} refs)` : 'Checking references…'}
23
+ tone="critical"
24
+ aria-disabled={!ready}
25
+ onClick={ready ? onConfirm : undefined}
26
+ />
27
+ )
28
+ }
@@ -0,0 +1,38 @@
1
+ import {Button, Dialog, Flex, Text} from '@sanity/ui'
2
+
3
+ // ✗ No focus trap, no Escape handling, no focus return on close.
4
+ export function HandRolledDialog({onConfirm}: {onConfirm: () => void}) {
5
+ return (
6
+ <div style={{position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.4)'}}>
7
+ <div style={{background: 'white', padding: 24, margin: 'auto'}}>
8
+ <p>Delete this document?</p>
9
+ <button onClick={onConfirm}>Delete</button>
10
+ </div>
11
+ </div>
12
+ )
13
+ }
14
+
15
+ // ✓ Dialog handles the backdrop, focus trap, Escape, and the close button.
16
+ export function DeleteDialog({
17
+ open,
18
+ onCancel,
19
+ onConfirm,
20
+ }: {
21
+ open: boolean
22
+ onCancel: () => void
23
+ onConfirm: () => void
24
+ }) {
25
+ return (
26
+ <Dialog header="Delete document?" open={open} onClose={onCancel}>
27
+ <Dialog.Content>
28
+ <Text>This can't be undone.</Text>
29
+ </Dialog.Content>
30
+ <Dialog.Footer>
31
+ <Flex gap={3} justifyContent="flex-end">
32
+ <Button text="Cancel" level="secondary" onClick={onCancel} />
33
+ <Button text="Delete" tone="critical" onClick={onConfirm} />
34
+ </Flex>
35
+ </Dialog.Footer>
36
+ </Dialog>
37
+ )
38
+ }
@@ -0,0 +1,48 @@
1
+ import {Button, Checkbox, Flex, Popover, Select, Text, VStack} from '@sanity/ui'
2
+ import {type ReactNode, useEffect, useRef} from 'react'
3
+
4
+ // Focuses the first control inside the panel. Popover keeps its content mounted
5
+ // while it is closed, and the effect runs again each time the panel opens. Popover
6
+ // does not move focus on its own, so this keeps keyboard and screen reader users
7
+ // from being left on the trigger.
8
+ function FocusOnOpen({children}: {children: ReactNode}) {
9
+ const ref = useRef<HTMLDivElement>(null)
10
+
11
+ useEffect(() => {
12
+ ref.current?.querySelector<HTMLElement>('select, input, button')?.focus()
13
+ }, [])
14
+
15
+ return <div ref={ref}>{children}</div>
16
+ }
17
+
18
+ // A filter panel. Opening it moves focus to the first filter.
19
+ export function FilterPopover() {
20
+ return (
21
+ <Popover
22
+ content={
23
+ <FocusOnOpen>
24
+ <VStack gap={3}>
25
+ <VStack gap={1}>
26
+ <Text as="label" size={1} htmlFor="filter-status">
27
+ Status
28
+ </Text>
29
+ <Select id="filter-status">
30
+ <option value="all">All</option>
31
+ <option value="draft">Draft</option>
32
+ <option value="published">Published</option>
33
+ </Select>
34
+ </VStack>
35
+ <Flex alignItems="center" gap={2}>
36
+ <Checkbox id="only-mine" />
37
+ <Text as="label" size={1} htmlFor="only-mine">
38
+ Only my documents
39
+ </Text>
40
+ </Flex>
41
+ </VStack>
42
+ </FocusOnOpen>
43
+ }
44
+ >
45
+ <Button text="Filters" level="secondary" />
46
+ </Popover>
47
+ )
48
+ }
@@ -0,0 +1,53 @@
1
+ import {Button, Popover, Text, TextInput, VStack} from '@sanity/ui'
2
+ import {type ReactNode, useEffect, useRef, useState} from 'react'
3
+
4
+ // Focuses the first control inside the panel each time the panel opens. See
5
+ // popover-1.tsx for why this uses an effect instead of autoFocus.
6
+ function FocusOnOpen({children}: {children: ReactNode}) {
7
+ const ref = useRef<HTMLDivElement>(null)
8
+
9
+ useEffect(() => {
10
+ ref.current?.querySelector<HTMLElement>('input, button')?.focus()
11
+ }, [])
12
+
13
+ return <div ref={ref}>{children}</div>
14
+ }
15
+
16
+ // Close the popover from code once the form inside it is submitted.
17
+ // The ref on Popover reaches the native popover element, so the browser's own
18
+ // showPopover(), hidePopover() and togglePopover() are available on it.
19
+ export function RenamePopover({name, onRename}: {name: string; onRename: (next: string) => void}) {
20
+ const popoverRef = useRef<HTMLDivElement>(null)
21
+ const [value, setValue] = useState(name)
22
+
23
+ return (
24
+ <Popover
25
+ ref={popoverRef}
26
+ content={
27
+ <FocusOnOpen>
28
+ <form
29
+ onSubmit={(event) => {
30
+ event.preventDefault()
31
+ onRename(value)
32
+ popoverRef.current?.hidePopover()
33
+ }}
34
+ >
35
+ <VStack gap={2}>
36
+ <Text as="label" size={1} htmlFor="rename">
37
+ Name
38
+ </Text>
39
+ <TextInput
40
+ id="rename"
41
+ value={value}
42
+ onChange={(e) => setValue(e.currentTarget.value)}
43
+ />
44
+ <Button type="submit" text="Save" />
45
+ </VStack>
46
+ </form>
47
+ </FocusOnOpen>
48
+ }
49
+ >
50
+ <Button level="secondary" text="Rename" />
51
+ </Popover>
52
+ )
53
+ }
@@ -0,0 +1,301 @@
1
+ kind: sanity.foundation
2
+ id: accessibility-guidelines
3
+ name: Accessibility guidelines
4
+ description: Rules, requirements and the review checklist for accessible color, content, iconography, motion, spacing, and typography in Sanity UI.
5
+ metadata:
6
+ tags:
7
+ - concept
8
+ - accessibility
9
+ - WCAG
10
+ - color
11
+ - contrast
12
+ - motion
13
+ - typography
14
+ - spacing
15
+ - iconography
16
+ - content
17
+ - aria-label
18
+ - prefers-reduced-motion
19
+ - color vision
20
+ - target size
21
+ - reflow
22
+ - text spacing
23
+ - icon contrast
24
+ - checklist
25
+ - review
26
+ status:
27
+ status: stable
28
+ sections:
29
+ - kind: guidelines
30
+ for: all
31
+ framing: how-to-use
32
+ items:
33
+ - id: wcag-22-aa-baseline
34
+ level: must
35
+ statement: WCAG 2.2 Level AA is the baseline across all foundations. Keyboard navigation, screen reader support, and touch targets belong in the spec from the start — not added after. No accessibility requirement trades for aesthetics.
36
+ refines:
37
+ - to: shared-foundations#wcag-22-aa-baseline
38
+ - id: contrast-minimums
39
+ level: must
40
+ statement: 'Color contrast must meet WCAG 2.2 Level AA: 4.5:1 for text, and 3:1 for large text (24px, or 18.66px bold) and for UI components and graphics (WCAG 1.4.3, 1.4.11).'
41
+ checks:
42
+ - href: axe-core:color-contrast
43
+ role: test
44
+ note: axe-core rule implementing SC 1.4.3
45
+ checkedBy: automated
46
+ refs:
47
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html
48
+ rel: relates-to
49
+ role: WCAG 2.2 Understanding SC 1.4.3 Contrast (Minimum)
50
+ - href: https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html
51
+ rel: relates-to
52
+ role: WCAG 2.2 Understanding SC 1.4.11 Non-text Contrast
53
+ - level: must
54
+ statement: 'Color must survive color vision deficiency and grayscale. Run the palette and key UI through a CVD simulator and a grayscale check. Test all three CVD types: deutan, protan, and tritan. A pair that survives one can collapse under another. Categorical colors (chart series, status) must stay distinct.'
55
+ - level: must
56
+ statement: 'Focus rings must survive forced colors. Forced-colors mode ignores `box-shadow` and falls back to the `outline` property (WCAG 2.4.7). A focus ring built only with `box-shadow` and `outline: none` disappears entirely under forced colors. Set `outline-color: transparent` instead of `outline: none` so forced-colors mode can override it with a system color. Apply the same swap to `border-color: transparent` instead of `border: 0` on inputs.'
57
+ - level: must
58
+ statement: Read-only content is not disabled, so it must still meet the contrast requirement. Only disabled controls are exempt.
59
+ - level: should
60
+ statement: Verify under forced colors. Check key UI under forced-colors and Windows High Contrast Mode. Boundaries that rely on background fill alone disappear there. Use the separator token, not a background shift alone, to define edges.
61
+ - level: must-not
62
+ statement: Severity must not ride on hue alone. `critical`, `caution`, and `positive` must differ by icon, label, and placement, not color. This is the sole-carrier rule applied to severity. Severity must be legible without color.
63
+ - kind: guidelines
64
+ for: all
65
+ framing: how-to-use
66
+ items:
67
+ - refs:
68
+ - to: shared-foundations#tone-signals-state
69
+ rel: same-as
70
+ - refs:
71
+ - to: shared-foundations#tone-paired-with-second-channel
72
+ rel: same-as
73
+ - refs:
74
+ - to: shared-foundations#icon-only-control-needs-name
75
+ rel: same-as
76
+ - level: must
77
+ statement: An icon paired with a value needs its own alternative. An icon next to a count or value (a comment icon next to "3") needs a text alternative distinct from any wrapping control's name (WCAG 1.1.1). Fold the value into the wrapping control's accessible name too — "3 comments," not "Open comments" (WCAG 4.1.2).
78
+ - level: must
79
+ statement: A purely decorative graphic still needs a text alternative. WCAG 1.1.1 requires an alternative for every image, even a decorative one — an empty alternative is valid, a missing one is not. Mark decorative avatars, illustrations, and status graphics with `role="presentation"` or `alt=""`.
80
+ - id: disabled-control-no-tooltip
81
+ level: must
82
+ statement: Disabled controls must explain themselves. A disabled control can't surface a reason through a tooltip. Put the reason in reachable text, or use `aria-disabled` (see Tooltips).
83
+ - level: must
84
+ statement: An icon-only button's `aria-label` persists across every state. Do not remove it or swap it out conditionally.
85
+ - level: should-not
86
+ statement: Don't duplicate an accessible name that already exists. A decorative preview image's `alt` can repeat text already present in the surrounding accessible name — mark that image decorative instead of announcing the name twice.
87
+ - refs:
88
+ - to: content-guidelines#plain-language
89
+ rel: same-as
90
+ - kind: guidelines
91
+ for: all
92
+ framing: how-to-use
93
+ items:
94
+ - id: touch-target-minimum
95
+ level: must
96
+ statement: "Any interactive control's hit area must be at least 24×24 CSS pixels (WCAG 2.5.8, AA) — not necessarily the visible size."
97
+ - level: must-not
98
+ statement: Never put `aria-selected` on a `<div>`, `<button>` or `<a>`. It is valid only on the option, row, tab, gridcell and treeitem roles. Use `aria-current` on those elements instead.
99
+ - level: must-not
100
+ statement: Never carry meaning by icon color alone. Shape and position must tell states apart; color supplements. A `positive` and a `critical` icon must differ in vector shape, not only in tone (WCAG 1.4.1).
101
+ refs:
102
+ - to: color-guidelines#second-channel-required
103
+ rel: relates-to
104
+ - kind: guidelines
105
+ for: all
106
+ framing: how-to-use
107
+ items:
108
+ - id: respect-reduced-motion
109
+ level: must
110
+ statement: Provide a reduced-motion alternative for every non-essential animation. Check `prefers-reduced-motion` and remove movement (translate, scale, rotate) — don't just slow it down. When uncertain whether motion is essential, treat it as non-essential. An instant state change is the safest fallback; a short opacity fade is acceptable where it aids comprehension.
111
+ - id: reduced-motion-v5-reset
112
+ level: must
113
+ statement: "v5's reduced-motion CSS reset stops all animations, including essential ones like Spinner's rotation. Any loading or live state that communicates through movement must also use text or an `aria-live` announcement — motion alone cannot carry the message."
114
+ - id: reduced-motion-state-distinction
115
+ level: must
116
+ statement: Before and after states must stay visually distinct under reduced motion. Pair every animated state change with a persistent change in shape, color, text, icon, or position that remains after the motion ends. Spec the reduced variant next to the full-motion transition.
117
+ - id: pause-looping-motion
118
+ level: must
119
+ statement: No autoplaying or looping motion without a pause or stop control. Continuous, non-interaction motion (carousels, animated backgrounds, looping video) needs an accessible way to stop it (WCAG 2.2.2 Pause, Stop, Hide, Level A). The pause or stop control meets WCAG 2.5.8 Target Size, 24 by 24 CSS px.
120
+ - id: motion-not-only-channel
121
+ level: must-not
122
+ statement: Motion must not be the only channel for a state change. A state change that rides on movement alone disappears under reduced motion. Pair it with a persistent change in shape, color, text, icon, or position that remains after the motion ends. The change must also reach assistive technology, through a moved focus or an `aria-live` announcement, not motion alone.
123
+ - id: no-flashing
124
+ level: must-not
125
+ statement: No content flashes more than three times per second. This applies to any rapid change in brightness or color, including pulsing attention cues and loading shimmers (WCAG 2.3.1 Three Flashes, Level A — this is a seizure risk, not a preference).
126
+ - kind: guidelines
127
+ for: all
128
+ framing: how-to-use
129
+ items:
130
+ - refs:
131
+ - to: spacing-guidelines#back-groups-with-markup
132
+ rel: same-as
133
+ - level: must
134
+ statement: Layouts must reflow at a 320px-equivalent viewport. Content must reflow without two-dimensional scrolling at a 320 CSS px viewport (WCAG 1.4.10 Reflow, AA). This matches 1280px at 400% zoom. Reflow must keep all information and function. Reduce large spacing values with responsive arrays. Content that needs two-dimensional layout, such as a large data table, is exempt.
135
+ - id: target-size-minimum
136
+ level: must
137
+ statement: "Tight spacing must not shrink hit targets. A dense layout may use the 2.5.8 spacing exception: a target under 24px passes when a 24px-diameter circle centered on it does not overlap a neighboring target's circle."
138
+ refs:
139
+ - to: accessibility-guidelines#touch-target-minimum
140
+ rel: relates-to
141
+ - level: should
142
+ statement: 'Spacing and type scale with browser zoom. The token files ship both in `px`, so they grow together when the user zooms, and layouts hold together (WCAG 1.4.4 Resize Text, AA). They do not follow a larger default font size set in the browser. Note: this does not by itself satisfy WCAG 1.4.12 Text Spacing.'
143
+ - kind: guidelines
144
+ for: all
145
+ framing: how-to-use
146
+ items:
147
+ - refs:
148
+ - to: color-guidelines#second-channel-required
149
+ rel: same-as
150
+ - level: must
151
+ statement: Text must resize and reflow. Text must resize to 200% without loss of content or function, and reflow at a 320px viewport with no horizontal scroll (WCAG 1.4.4, 1.4.10). Text sizes come from the type tokens in `px`, not from the document's base font size. The consuming app must not ship `user-scalable=no` or `maximum-scale=1`.
152
+ - level: must
153
+ statement: Layouts must survive text-spacing overrides. The layout must hold when users override line height to 1.5×, paragraph spacing to 2×, letter spacing to 0.12em, and word spacing to 0.16em (WCAG 1.4.12). The failure comes from wrapping components in fixed-height containers or applying `textOverflow="ellipsis"` where text needs to wrap.
154
+ - kind: guidelines
155
+ for: agent
156
+ framing: how-to-use
157
+ items:
158
+ - level: must
159
+ statement: Meaning must not be carried by color, motion, or icon appearance alone — always pair with a persistent, perceivable alternative such as an icon, label, or shape change.
160
+ - refs:
161
+ - to: shared-foundations#icon-only-control-needs-name
162
+ rel: same-as
163
+ - kind: steps
164
+ for: all
165
+ ordered: false
166
+ title: 'Checklist: semantic structure'
167
+ items:
168
+ - title: 'If the component has an `as` prop, the doc lists when to use each semantic element value.'
169
+ description: 'WCAG 1.3.1 A'
170
+ - title: 'If the component has an `as` prop, the doc warns which elements carry behavioral contracts the component does not fulfil.'
171
+ description: 'WCAG 4.1.2 A'
172
+ - title: 'If the component can render as `<nav>`, `<section>`, `<aside>`, `<form>`, `<header>` or `<footer>`, the doc states the labeling requirement for each.'
173
+ description: 'WCAG 1.3.1 A'
174
+ - title: 'If the component renders `<ul>` or `<ol>`, the doc states that `role="list"` is needed when `list-style: none` is applied.'
175
+ description: 'WCAG 1.3.1 A'
176
+ - title: 'If the component renders a heading, it takes its level through `as` (`as="h2"`, `as="h3"`) and the doc states that levels follow the page hierarchy.'
177
+ description: 'WCAG 1.3.1 A, 2.4.6 AA'
178
+ - kind: steps
179
+ for: all
180
+ ordered: false
181
+ title: 'Checklist: keyboard and focus'
182
+ items:
183
+ - title: 'If the component is interactive, the doc names the keys that activate it: Enter, Space, or both.'
184
+ description: 'WCAG 2.1.1 A'
185
+ - title: 'If the component is a layout primitive, the doc warns against CSS `order`, reverse flex directions and grid reordering that break visual-to-DOM order.'
186
+ description: 'WCAG 1.3.2 A'
187
+ - title: 'If the component opens an overlay, the doc states where focus moves on open and where it returns on close.'
188
+ description: 'WCAG 2.4.3 A'
189
+ - title: 'A clickable toggle region, such as an expand/collapse header, is a real `<button>`, not a `<div>` with `onClick`.'
190
+ description: 'WCAG 2.1.1 A'
191
+ - title: 'UI that appears only on a pointer gesture, such as a selection toolbar or a hover popover, has a documented keyboard path.'
192
+ description: 'WCAG 2.1.1 A'
193
+ - title: 'A drag-based resize handle responds to arrow keys once focused.'
194
+ description: 'WCAG 2.1.1 A'
195
+ - title: 'A drag-to-reorder pattern cancels when the pointer is released outside the drop zone, and has a single-pointer alternative that needs no drag.'
196
+ description: 'WCAG 2.5.2 A, 2.5.7 AA'
197
+ - kind: steps
198
+ for: all
199
+ ordered: false
200
+ title: 'Checklist: names, roles and states'
201
+ items:
202
+ - title: 'Every interactive element has a documented accessible name source: visible text, `aria-label` or `aria-labelledby`. An icon-only button uses `aria-label`.'
203
+ description: 'WCAG 4.1.2 A'
204
+ - title: 'If the component triggers a popup or expandable region, the trigger documents `aria-expanded`.'
205
+ description: 'WCAG 4.1.2 A'
206
+ - title: 'If the component updates content dynamically, the doc names the live region: `aria-live="polite"` for status, `aria-live="assertive"` for errors.'
207
+ description: 'WCAG 4.1.3 AA'
208
+ - title: 'If the component is a two-state toggle, `aria-pressed` is documented and the label describes the action, not the state.'
209
+ description: 'WCAG 4.1.2 A'
210
+ - title: 'If the component has a selected or current state, the doc names `aria-selected` or `aria-current` for it, following the `aria-selected` rule above.'
211
+ description: 'WCAG 4.1.2 A'
212
+ - title: 'If the component builds an application layout, the doc maps regions to labeled landmarks: `<nav>`, `<main>`, `<aside>`.'
213
+ description: 'WCAG 2.4.1 A'
214
+ - title: 'The component does not nest one interactive role inside another, such as an `<a>` inside a `role="option"` row or a `<button>` inside a `<button>`.'
215
+ description: 'WCAG 4.1.2 A'
216
+ - kind: steps
217
+ for: all
218
+ ordered: false
219
+ title: 'Checklist: non-text alternatives'
220
+ items:
221
+ - title: "An icon next to a count or value has its own text alternative, distinct from any wrapping control's name."
222
+ description: 'WCAG 1.1.1 A'
223
+ - title: 'A decorative avatar, illustration or status graphic is marked `role="presentation"` or `alt=""`, not left with no alternative.'
224
+ description: 'WCAG 1.1.1 A'
225
+ - title: 'A status indicator, such as a colored dot, is backed by a shape or icon difference and a text alternative.'
226
+ description: 'WCAG 1.4.1 A'
227
+ - kind: steps
228
+ for: all
229
+ ordered: false
230
+ title: 'Checklist: contrast and color'
231
+ items:
232
+ - title: 'Every text and UI color pair meets the contrast requirement above, in both light and dark mode. Check input borders, placeholder text, and a selected row against every text color it holds; these are the common failures.'
233
+ description: 'WCAG 1.4.3, 1.4.11 AA'
234
+ - title: 'Keyboard focus rings stay visible in forced-colors mode: `outline-color: transparent`, not `outline: none`.'
235
+ description: 'WCAG 2.4.7 AA'
236
+ - title: 'Every use of semantic color (positive, caution, critical) is paired with an icon, a text label or a shape.'
237
+ description: 'WCAG 1.4.1 A'
238
+ - kind: steps
239
+ for: all
240
+ ordered: false
241
+ title: 'Checklist: motion, timing and targets'
242
+ items:
243
+ - title: 'All animations and transitions honor `prefers-reduced-motion`.'
244
+ description: 'WCAG 2.3.3 AAA, treated as the baseline'
245
+ - title: 'An auto-dismissing message, such as a toast or transient banner, pauses on hover and focus, or offers a way to extend or turn off the timing.'
246
+ description: 'WCAG 2.2.1 A'
247
+ - title: "Every interactive target is at least 24\u00d724 CSS px, or small targets are spaced so a 24px circle on each does not overlap."
248
+ description: 'WCAG 2.5.8 AA'
249
+ - kind: steps
250
+ for: all
251
+ ordered: false
252
+ title: 'Checklist: reflow and text spacing'
253
+ items:
254
+ - title: 'The component works at 400% zoom, a 320px viewport, without horizontal scrolling.'
255
+ description: 'WCAG 1.4.10 AA'
256
+ - title: "The component holds when users override text spacing: line height 1.5\u00d7, paragraph spacing 2\u00d7, letter spacing 0.12em, word spacing 0.16em."
257
+ description: 'WCAG 1.4.12 AA'
258
+ - kind: steps
259
+ for: all
260
+ ordered: false
261
+ title: 'Checklist: form errors'
262
+ items:
263
+ - title: "An input's error state links its message through `aria-describedby`, not color or an icon alone."
264
+ description: 'WCAG 3.3.1 A'
265
+ - title: 'Where practical, the error message suggests a fix, not only the problem.'
266
+ description: 'WCAG 3.3.3 AA'
267
+ - title: "A custom field inside a `fieldset`/`legend` has its own accessible name through `aria-labelledby`, not only the group's."
268
+ description: 'WCAG 4.1.2 A'
269
+ - kind: section
270
+ for: all
271
+ freeform:
272
+ - title: Content
273
+ body: |-
274
+ Most accessibility rules sit with the content type they govern; the cross-cutting ones live here. The developer owns the ARIA wiring; the writer owns the words that wiring carries.
275
+
276
+ Known limitation: right-to-left text has edge cases this doc can't resolve. When a content rule can't be met accessibly, the accessible path wins.
277
+ - title: Motion
278
+ body: |-
279
+ Reduced motion resolves in v5's global reset, not per component. Under `prefers-reduced-motion: reduce`, the reset shortens every CSS animation and transition to `0.01ms` and limits every animation to one iteration, so component authors get correct behavior for free. That also stops looping animations such as Spinner's rotation. Respect the preference in JS-driven animation as well, since the CSS query does not cover `requestAnimationFrame` or WAAPI work.
280
+
281
+ ```css
282
+ .panel {
283
+ transition: transform 200ms ease-out;
284
+ }
285
+
286
+ @media (prefers-reduced-motion: reduce) {
287
+ .panel {
288
+ /* 0.01ms, not 0ms, so transitionend still fires and JS awaiting it doesn't hang */
289
+ transition-duration: 0.01ms; /* instant; movement removed, state still changes */
290
+ }
291
+ }
292
+ ```
293
+
294
+ ```js
295
+ const reduce = window.matchMedia('(prefers-reduced-motion: reduce)').matches
296
+ ```
297
+ - kind: section
298
+ for: agent
299
+ freeform:
300
+ - title: Intent
301
+ body: Use this guide to verify that color choices, content patterns, iconography, motion, spacing, and typography decisions meet WCAG 2.2 accessibility requirements in Sanity UI. When reviewing a component doc or building a component, work through every checklist item that applies.