@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,233 @@
1
+ kind: component
2
+ id: heading
3
+ name: Heading
4
+ description: Displays heading text to create logical hierarchy and page structure.
5
+ metadata:
6
+ tags: [typography, heading, title, hierarchy, semantic, h1, h2, h3, h4, h5, h6, section]
7
+ status:
8
+ status: stable
9
+ sections:
10
+ - kind: guidelines
11
+ for: all
12
+ framing: when-to-use
13
+ title: When to use
14
+ items:
15
+ - level: should
16
+ statement: To establish the semantic structure of a page (page title, section header, subsection).
17
+ - level: should
18
+ statement: To group text and elements into logical, navigable sections.
19
+ - level: should-not
20
+ statement: For visual emphasis or decorative purposes (stat values, hero numbers, big quotes). Use Text with size 3+ instead.
21
+ alternatives:
22
+ - to: text
23
+ - level: should-not
24
+ statement: To emphasize text inside a paragraph. Use Text with weight='bold'.
25
+ alternatives:
26
+ - to: text
27
+ - kind: guidelines
28
+ for: agent
29
+ framing: when-to-use
30
+ title: When to use
31
+ items:
32
+ - level: should-not
33
+ statement: Don't use Heading for body copy and non-structural typographic emphasis. Use Text instead.
34
+ alternatives:
35
+ - to: text
36
+ - level: should-not
37
+ statement: Don't use Heading to label a TextInput, Select or other input. Use a label element linked with htmlFor instead.
38
+ alternatives:
39
+ - to: text
40
+ note: Visible label text for a form field, set with as='label'.
41
+ - kind: guidelines
42
+ for: all
43
+ framing: how-to-use
44
+ items:
45
+ - refs:
46
+ - to: semantics#heading-as-explicit
47
+ rel: same-as
48
+ - refs:
49
+ - to: semantics#heading-level-from-outline
50
+ rel: same-as
51
+ - refs:
52
+ - to: semantics#one-h1-per-page
53
+ rel: same-as
54
+ - refs:
55
+ - to: semantics#heading-levels-sequential
56
+ rel: same-as
57
+ - id: heading-no-icons
58
+ level: should-not
59
+ statement: A Heading carries no icon — not a leading glyph, not a trailing one, and not an Icon composed beside the heading text. A heading is found by its level and its position in the outline, not by decoration. When a section genuinely needs a symbol, place it on an adjacent element that has its own accessible name rather than inside the Heading.
60
+ checks:
61
+ - href: ../evals/cases.yaml
62
+ role: agent-test
63
+ checkedBy: assisted
64
+ refines:
65
+ - to: shared-foundations#no-emojis
66
+ $extensions:
67
+ io.jev:
68
+ type: boolean
69
+ - id: heading-is-semantic-not-decorative
70
+ level: must-not
71
+ statement: Don't use Heading for visual differentiation alone — use Text with weight or size instead. Every Heading instance should introduce or label a distinct content section, not just make text appear large, bold, or visually prominent.
72
+ example:
73
+ title: How to satisfy this
74
+ description: Read the heading text in context and confirm it functions as a title or label for the content that follows. Check that removing the heading would leave a section without a navigable label in the page outline.
75
+ alternatives:
76
+ - to: text
77
+ checkedBy: manual
78
+ - id: heading-no-emojis
79
+ level: must-not
80
+ statement: Never use an emoji as a start-aligned icon on a Heading, and never place an emoji anywhere in heading text. In the leading position an emoji reads as an icon but carries none of Icon's sizing, alignment, or accessible-name behaviour, and assistive technology announces its CLDR name as part of the heading — corrupting the outline that heading levels exist to provide.
81
+ checks:
82
+ - href: ../evals/cases.yaml
83
+ role: agent-test
84
+ checkedBy: assisted
85
+ refines:
86
+ - to: shared-foundations#no-emojis
87
+ $extensions:
88
+ io.jev:
89
+ type: boolean
90
+ - kind: guidelines
91
+ for: agent
92
+ framing: how-to-use
93
+ items:
94
+ - level: must
95
+ statement: Set `as` on every Heading to `h1` through `h6`. `as` is required, and the level comes from the page outline. Use `size` for the visual size.
96
+ - level: must-not
97
+ statement: Don't pass a `level` prop to Heading. It has none. Use `as` for the level.
98
+ - level: must-not
99
+ statement: Don't pass `weight` or `muted` to Heading. It has neither. Use Text for other weights or muted text.
100
+ - level: must-not
101
+ statement: "Heading only accepts heading elements for `as`: `h1` through `h6`. Passing `as='p'`, `as='div'`, or any non-heading element causes a TypeScript error. For styled non-heading text, use `Text` with `size` and `weight`."
102
+ - kind: guidelines
103
+ for: all
104
+ title: Content
105
+ tags: [content]
106
+ items:
107
+ - refs:
108
+ - to: content-guidelines#sentence-case-all-system-set
109
+ rel: same-as
110
+ - level: should
111
+ statement: Keep headings to one sentence.
112
+ - level: should
113
+ statement: Headings should describe the content of the section they introduce.
114
+ - level: should-not
115
+ statement: Do not end headings with a period unless the heading is a question.
116
+
117
+ - kind: guidelines
118
+ for: all
119
+ title: Accessibility
120
+ tags: [accessibility]
121
+ items:
122
+ - level: should
123
+ statement: '**Zoom and reflow.** Headings must stay legible at 400% zoom / 320px viewport width (WCAG 1.4.10 AA). Long headings should wrap, not clip. When using `truncate`, verify the clipped text still makes sense. Spacing tokens use `rem` and scale with user font-size settings (WCAG 1.4.12 AA).'
124
+ alternatives:
125
+ - to: text
126
+ note: Body copy and UI text, not semantic headings
127
+ sourceFiles:
128
+ - platform: react
129
+ file: packages/ui/src/components/heading/Heading.tsx
130
+ imports:
131
+ - platform: react
132
+ code: import { Heading } from '@sanity/ui'
133
+ package: '@sanity/ui'
134
+ traits:
135
+ - traitType: variant
136
+ kind: enum
137
+ id: size
138
+ description: CSS font-size property.
139
+ values:
140
+ - id: '0'
141
+ description: Smallest. UI chrome headings — toolbars, sidebars, compact panels.
142
+ - id: '1'
143
+ description: Small. Content sub-section titles.
144
+ - id: '2'
145
+ description: Medium (default). Standard section headings.
146
+ - id: '3'
147
+ description: Large. Document titles in high-density layouts.
148
+ - id: '4'
149
+ description: Extra large. Document titles in moderate-density layouts.
150
+ - id: '5'
151
+ description: Largest size. Document titles in low-density layouts.
152
+ - traitType: variant
153
+ kind: enum
154
+ id: tone
155
+ description: Semantic text color.
156
+ values:
157
+ - id: neutral
158
+ description: Default. No semantic meaning.
159
+ - id: suggest
160
+ description: Suggestions or informational content. Pair with InfoOutlineIcon.
161
+ - id: positive
162
+ description: Success, published, healthy. Pair with CheckmarkIcon.
163
+ - id: caution
164
+ description: Needs attention. Pair with WarningOutlineIcon.
165
+ - id: critical
166
+ description: Error, failed, rejected. Pair with ErrorOutlineIcon.
167
+ - traitType: variant
168
+ kind: boolean
169
+ id: trim
170
+ description: Removes extra whitespace above and below the text box for precise alignment with icons or badges.
171
+ - traitType: variant
172
+ kind: enum
173
+ id: align
174
+ description: CSS text-align property.
175
+ values:
176
+ - id: left
177
+ description: Default. Titles, section headings, group headings.
178
+ - id: center
179
+ description: Rare. Empty-state titles.
180
+ - id: right
181
+ description: Rarely appropriate in UI.
182
+ $extensions:
183
+ com.sanity.ui:
184
+ implementationStatus:
185
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
186
+ implemented: true
187
+ migrationGuide:
188
+ context: 'Migration guide for this component, covering the codemod and the changes it cannot make. Held as an extension because it is temporary: migration tooling and porting agents read it, and it should be dropped when Sanity UI 3 support ends.'
189
+ codemod: |-
190
+ Heading now defaults to `<h2>` (v3 defaulted to `<div>`) — always set `as` explicitly. `textOverflow` is replaced by `truncate` — both `"ellipsis"` and `"clip"` map to `truncate={1}`. `accent` is removed — use `tone` instead. `trim` and margin props are new.
191
+
192
+ Run the codemod: `pnpx @sanity/ui-codemod latest:heading --paths <paths> --toPackage @sanity/ui`.
193
+ guidance: |-
194
+ Heading in the new system has a different approach to semantic levels and new typography props.
195
+
196
+ ### Key differences
197
+
198
+ - v5 components use CSS classes with a static stylesheet as opposed to `styled-components`.
199
+ - v3 Heading defaulted to rendering a `<div>`. In v5, `as` is required. Omitting it is a type error.
200
+ - `textOverflow` replaced by `truncate`. For single-line truncation, use `truncate={1}`. For multi-line, use `truncate={2}` or higher.
201
+ - `accent` removed. Use `tone` or a parent with a semantic tone.
202
+ - `trim` added to remove leading/trailing whitespace from the text box for precise alignment.
203
+ - Margin props added. Heading now accepts `margin`, `marginX`, `marginY`, and per-side margin props.
204
+
205
+ ### Detailed list of differences
206
+
207
+ | v3 prop | v5 prop | Notes |
208
+ | :---- | :---- | :---- |
209
+ | `accent` | — | Removed. No accent color prop in the new version. |
210
+ | `weight` | — | Removed. Heading is bold by default. Use `Text` for other weights. |
211
+ | `muted` | — | Removed. Use `Text` with `muted` for secondary text. |
212
+ | `textOverflow="ellipsis"` | `truncate={1}` | The codemod maps both `"ellipsis"` and `"clip"` to `truncate={1}`. |
213
+ | — | `trim` | New. Applies `text-box-trim` to remove whitespace above and below the text box. |
214
+ | — | `truncate` | New. Limit to N lines. Replaces `textOverflow` and adds multi-line clamping. |
215
+ | — | `margin*` | New. Heading accepts margin props directly (0–9, `'auto'`). |
216
+
217
+ ### Breaking changes
218
+
219
+ - `as` is required. v3 defaulted to `<div>`, and v5 has no default. A `<Heading>` without `as` fails to compile.
220
+ - `textOverflow` prop removed. `<Heading textOverflow="ellipsis">` does nothing. Use `<Heading truncate={1}>`.
221
+ - `accent` prop removed. `<Heading accent>` does nothing. Use `tone=”suggest”` or a parent element with a semantic tone for colored headings.
222
+ - `weight` and `muted` removed. Heading is bold by default. Use `Text` for other weights or muted text.
223
+ - `styled-components` no longer used. Custom styled-components extensions like `styled(Heading)` will not work.
224
+
225
+ ### Codemod
226
+
227
+ A codemod is available to make the changes above less painful. Run the command below with the path to the file or directory you want to migrate. Pass a space-delimited list for multiple paths.
228
+
229
+ ```
230
+ pnpx @sanity/ui-codemod latest:heading --paths <paths> --toPackage @sanity/ui
231
+ ```
232
+
233
+ Some components may need manual review. When a component cannot be migrated or has unclear changes, the codemod adds a “UI-POC-CODEMOD TODO” comment.
@@ -0,0 +1,60 @@
1
+ kind: component
2
+ id: hotkeys
3
+ name: Hotkeys
4
+ description: Presents multi-key keyboard shortcuts.
5
+ metadata:
6
+ tags: [keyboard, shortcut, hotkey, keycap, display, hotkeys, keyboard shortcut, modifier]
7
+ status:
8
+ status: experimental
9
+ note: Exported from @sanity/ui 5.0.0-alpha.16, marked @alpha in the source. Its API can change without notice.
10
+ sections:
11
+ - kind: guidelines
12
+ for: all
13
+ framing: when-to-use
14
+ title: When to use
15
+ items:
16
+ - level: should
17
+ statement: To show keyboard shortcuts next to menu items or toolbar actions.
18
+ - level: should
19
+ statement: For help dialogs or keyboard shortcut cheat sheets.
20
+ - level: should
21
+ statement: Tooltips that reveal the shortcut for an action.
22
+ - level: should-not
23
+ statement: Inline references to a single key within running text — use KBD instead.
24
+ alternatives:
25
+ - to: kbd
26
+ - kind: guidelines
27
+ for: all
28
+ framing: how-to-use
29
+ items:
30
+ - level: should
31
+ statement: 'Use platform-appropriate labels: Ctrl on Windows/Linux, ⌘ on Mac. Detect the platform at runtime.'
32
+ - level: should
33
+ statement: Keep shortcuts to 2–3 keys. Anything longer is difficult to press and read.
34
+ - level: should
35
+ statement: Pair the key caps with a visible action label so the shortcut has context.
36
+ - level: must-not
37
+ statement: Don't display more than 3 keys in a single Hotkeys instance.
38
+ - level: must-not
39
+ statement: Don't rely on the Hotkeys display as the only way to discover a feature.
40
+ - level: must-not
41
+ statement: Don't use Hotkeys inside body text — use KBD for inline key references.
42
+ - kind: guidelines
43
+ for: agent
44
+ framing: how-to-use
45
+ items:
46
+ - level: should
47
+ statement: Detect the platform at runtime and pass the correct platform-specific key labels.
48
+ - level: must-not
49
+ statement: 'Using Hotkeys as the sole mechanism to discover a feature. Instead: Shortcuts should supplement visible UI — never gate functionality.'
50
+ alternatives:
51
+ - to: kbd
52
+ refs:
53
+ - href: https://www.figma.com/design/NWmchNlsNdG66VBaCsTdSL/pjo-ui4-component-buildout?node-id=144-7
54
+ rel: design
55
+ role: Figma component
56
+ $extensions:
57
+ com.sanity.ui:
58
+ implementationStatus:
59
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
60
+ implemented: true
@@ -0,0 +1,220 @@
1
+ kind: component
2
+ id: icon-button
3
+ name: IconButton
4
+ description: Triggers an action using an icon as the primary communicator.
5
+ metadata:
6
+ tags: [action, button, icon, icon-only, interactive, toolbar, destructive, loading]
7
+ status:
8
+ status: beta
9
+ sections:
10
+ - kind: guidelines
11
+ for: all
12
+ framing: when-to-use
13
+ title: When to use
14
+ items:
15
+ - level: must
16
+ statement: For icon-only buttons
17
+ - level: should
18
+ statement: In toolbars where space is limited.
19
+ - level: should
20
+ statement: In button groups with many actions where labels would clutter the layout.
21
+ - level: should
22
+ statement: As action triggers in list rows — such as edit, delete, or more options.
23
+ - level: should-not
24
+ statement: When users may not know the icon. Use Button with iconStart and text instead.
25
+ alternatives:
26
+ - to: button
27
+ - level: must-not
28
+ statement: In dialogs or confirmation prompts. Use Button with a visible label.
29
+ alternatives:
30
+ - to: button
31
+ - kind: guidelines
32
+ for: all
33
+ framing: how-to-use
34
+ items:
35
+ - id: aria-label-required
36
+ level: must
37
+ statement: "Every IconButton needs an `aria-label`. It is the button's only accessible name. Describe the action, not the icon: 'Delete document', not 'Trash'."
38
+ example:
39
+ title: How to satisfy this
40
+ description: Pass aria-label directly on the IconButton element. Describe the action — use 'Delete document', not 'Trash'.
41
+ checks:
42
+ - href: eslint:sanity-ui/require-icon-button-aria-label
43
+ role: lint-rule
44
+ note: eslint rule
45
+ checkedBy: automated
46
+ refines:
47
+ - to: content-guidelines#name-the-action
48
+ - to: shared-foundations#icon-only-control-needs-name
49
+ - refs:
50
+ - to: shared-foundations#tone-signals-state
51
+ rel: same-as
52
+ - refs:
53
+ - to: shared-foundations#tone-paired-with-second-channel
54
+ rel: same-as
55
+ - id: tooltip-paired
56
+ level: should
57
+ statement: Pair each IconButton with a Tooltip so its label is visible on hover and keyboard focus.
58
+ example:
59
+ title: How to satisfy this
60
+ description: Wrap IconButton with Tooltip and set the tooltip content to match the aria-label.
61
+ checkedBy: manual
62
+ - id: no-tooltip-on-disabled
63
+ refs:
64
+ - to: tooltip#no-tooltip-on-disabled
65
+ rel: same-as
66
+ example:
67
+ title: How to satisfy this
68
+ description: Remove or skip rendering the Tooltip when the button is disabled. Add a nearby status message or info icon to explain why the action is blocked.
69
+ checkedBy: manual
70
+ refines:
71
+ - to: accessibility-guidelines#disabled-control-no-tooltip
72
+ - id: no-icon-button-in-dialogs
73
+ level: must-not
74
+ statement: Don't use IconButton in dialogs or decision prompts — use Button with a visible label instead.
75
+ example:
76
+ title: How to satisfy this
77
+ description: Use Button with text prop for confirm and cancel actions in dialogs.
78
+ checkedBy: manual
79
+ - kind: guidelines
80
+ for: agent
81
+ framing: how-to-use
82
+ items:
83
+ - level: must
84
+ statement: '`icon` and `aria-label` are both required. Omitting either causes a TypeScript error.'
85
+ - level: must
86
+ statement: "Use tone='critical' for destructive actions, with an icon that signals the action, like TrashIcon."
87
+ refines:
88
+ - to: shared-foundations#destructive-actions-use-critical-tone
89
+ - level: should
90
+ statement: IconButton defaults to level='primary', like Button. Set level='tertiary' on toolbar and list row actions. Leave `level` out only on the single most critical action in a group.
91
+ - level: should
92
+ statement: Pass `ref` straight to IconButton when you need the rendered element — to move focus to it, or to anchor a Popover to its trigger. It reaches the underlying element; there is no wrapper to add and no forwardRef to wait for.
93
+ - level: must-not
94
+ statement: IconButton does not accept Box layout props. Wrap in Box to control sizing or position.
95
+ - level: must-not
96
+ statement: 'Do not hand-write a native `<button>` to get a `ref` or an attribute the prop table does not list. Standard DOM attributes and event handlers — `ref`, `id`, `title`, `tabIndex`, `data-*`, `aria-*`, `onKeyDown` — pass through to the rendered element, so a stripped-down native button is never the way to reach one.'
97
+ checkedBy: assisted
98
+ - kind: guidelines
99
+ for: all
100
+ title: Accessibility
101
+ description: 'Target conformance: WCAG Level AA.'
102
+ tags: [accessibility]
103
+ items:
104
+ - refs:
105
+ - to: shared-foundations#aria-disabled-keeps-focus
106
+ rel: same-as
107
+ - refs:
108
+ - to: shared-foundations#aria-pressed-toggle
109
+ rel: same-as
110
+ - kind: section
111
+ for: agent
112
+ freeform:
113
+ - title: Required props
114
+ body: |-
115
+ Both `icon` and `aria-label` are required — omitting either causes a TypeScript error.
116
+
117
+ ```tsx
118
+ <IconButton icon={AddIcon} aria-label="Add item" />
119
+ ```
120
+
121
+ `aria-label` is the only accessible name. Screen readers read it aloud. Describe the action, not the icon: `aria-label="Delete document"`, not `aria-label="Trash"`.
122
+ - title: Tooltip pairing
123
+ body: |-
124
+ Always wrap IconButton in a Tooltip so the label is visible on hover and keyboard focus.
125
+
126
+ ```tsx
127
+ <Tooltip content="Delete document">
128
+ <IconButton icon={TrashIcon} aria-label="Delete document" tone="critical" />
129
+ </Tooltip>
130
+ ```
131
+
132
+ Don't place a Tooltip on a disabled or loading IconButton. See Tooltip for the rule.
133
+
134
+ uses:
135
+ - to: icons
136
+ note: IconButton requires an icon from @sanity/icons as its icon prop.
137
+ alternatives:
138
+ - to: button
139
+ refs:
140
+ - href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32594-1782
141
+ rel: design
142
+ role: Figma component (v5)
143
+ sourceFiles:
144
+ - platform: react
145
+ file: packages/ui/src/components/icon-button/IconButton.tsx
146
+ imports:
147
+ - platform: react
148
+ code: import { IconButton } from '@sanity/ui'
149
+ package: '@sanity/ui'
150
+ traits:
151
+ - traitType: variant
152
+ kind: enum
153
+ id: level
154
+ description: Controls the visual weight of the button. Use tertiary for most actions, secondary for important but non-primary actions, and primary sparingly for the single most critical action per section.
155
+ values:
156
+ - id: tertiary
157
+ description: No background, low visual weight. For rare or background actions such as close or dismiss.
158
+ - id: secondary
159
+ description: Outlined/bordered look. For common but not the most critical actions.
160
+ - id: primary
161
+ description: Solid background, full visual weight. The most critical action in a group.
162
+ - traitType: variant
163
+ kind: enum
164
+ id: tone
165
+ description: Semantic color of the button.
166
+ values:
167
+ - id: neutral
168
+ description: Neutral gray for general toolbar and list actions.
169
+ - id: critical
170
+ description: Red for destructive or unsafe actions. Always pair with an icon that signals a destructive action, like TrashIcon.
171
+ - traitType: variant
172
+ kind: enum
173
+ id: density
174
+ description: Composite prop setting padding and minimum hit area together.
175
+ values:
176
+ - id: regular
177
+ description: Padding 2, minimum size 25x25px. Default.
178
+ - id: loose
179
+ description: Padding 3, minimum size 33x33px. For spacious contexts.
180
+ - traitType: variant
181
+ kind: enum
182
+ id: type
183
+ description: The native HTML type attribute passes through to the underlying <button> element.
184
+ values:
185
+ - id: button
186
+ description: Standard button (default). For all actions outside of a form context.
187
+ - id: submit
188
+ description: Submits form data.
189
+ - id: reset
190
+ description: Resets form data.
191
+ - traitType: state
192
+ kind: boolean
193
+ id: loading
194
+ description: Button action is in progress. Button is also disabled while loading. Use for tasks over 200ms. For tasks over three seconds, show a confirmation message when the task completes.
195
+ - traitType: state
196
+ kind: boolean
197
+ id: enabled
198
+ description: Button's standard state, clickable.
199
+ - traitType: state
200
+ kind: boolean
201
+ id: hovered
202
+ description: Cursor is resting over the button.
203
+ - traitType: state
204
+ kind: boolean
205
+ id: pressed
206
+ description: Button is being pressed.
207
+ - traitType: state
208
+ kind: boolean
209
+ id: focused
210
+ description: Button has keyboard focus.
211
+ - traitType: state
212
+ kind: boolean
213
+ id: disabled
214
+ description: Interaction is blocked. Removed from tab order via HTML disabled. Only use when the action could be harmful. Icon-only buttons give no context when disabled — add a nearby status message or info icon to explain why the action is blocked.
215
+
216
+ $extensions:
217
+ com.sanity.ui:
218
+ implementationStatus:
219
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
220
+ implemented: true