@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,268 @@
1
+ kind: component
2
+ id: text
3
+ name: Text
4
+ description: Displays body paragraphs, captions, and metadata.
5
+ metadata:
6
+ tags: [typography, text, body, caption, label, copy, paragraph, metadata, font]
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: Body copy, descriptions, captions, and metadata — any text that is not a heading.
17
+ - level: should-not
18
+ statement: Don't use Text to label a section in a Menu or above headings. Use Eyebrow instead.
19
+ alternatives:
20
+ - to: eyebrow
21
+ - level: should-not
22
+ statement: Don't use Text without as='label' to name a TextInput, Select or other input. Set as='label' and link it with htmlFor.
23
+ - level: should-not
24
+ statement: Don't use Text to denote a keyboard shortcut. Use KBD instead.
25
+ alternatives:
26
+ - to: kbd
27
+ - level: should-not
28
+ statement: Don't use Text for inline or block code samples. Use Code instead.
29
+ alternatives:
30
+ - to: code
31
+ - level: must-not
32
+ statement: Don't use Text for structural headings. Use Heading instead.
33
+ alternatives:
34
+ - to: heading
35
+ - kind: guidelines
36
+ for: all
37
+ framing: how-to-use
38
+ items:
39
+ - refs:
40
+ - to: shared-foundations#tone-signals-state
41
+ rel: same-as
42
+ - id: text-body-start-aligned
43
+ level: should
44
+ statement: "Start-align body copy and descriptive Text instances by default. Sanity's typographic system prefers start alignment unless a specific layout (for example, a centered hero) justifies a different one."
45
+ example:
46
+ title: Start-aligned body copy
47
+ description: "`<Text>Body copy runs start-aligned by default — no `align` needed.</Text>`. To verify, check the element's computed `text-align`; it should resolve to the start edge, not `center`."
48
+ checkedBy: manual
49
+ - id: text-secondary-uses-muted
50
+ level: should
51
+ statement: Apply muted to secondary or helper text (timestamps, captions, metadata, helper messages) so it renders visually less prominent than the primary text nearby.
52
+ example:
53
+ title: Secondary text carries muted
54
+ description: '`<Text size={1} muted>Edited 2 hours ago</Text>` beside `<Text>Document title</Text>`. To verify, confirm the `muted` prop is present on the secondary Text and that it renders at lower contrast than the primary text next to it.'
55
+ checkedBy: manual
56
+ - id: text-single-line-uses-truncate
57
+ level: should
58
+ statement: Set truncate={1} when a Text instance is intentionally limited to one visible line — an ellipsis appears once the content overflows.
59
+ example:
60
+ title: Single-line truncation
61
+ description: '`<Text truncate={1}>{title}</Text>`. To verify, narrow the container until the string overflows and confirm one line with a trailing ellipsis, carrying the `sui-text-overflow` class. Values above 1 clamp with `-webkit-line-clamp` instead.'
62
+ checkedBy: manual
63
+ - id: text-no-center-aligned-paragraphs
64
+ level: must-not
65
+ statement: Don't center-align long blocks of paragraph text — this disrupts reading flow. Multi-line paragraph Text instances (three or more lines at the default viewport) should stay start-aligned.
66
+ example:
67
+ title: The prohibited form — a centred multi-line paragraph
68
+ description: '`<Text align="center">` wrapping three or more lines of body copy. To verify, render at the default viewport width and count the visible lines; three or more must be start-aligned. Centring is acceptable only where the block stays within two lines at every supported width.'
69
+ checkedBy: manual
70
+ - id: text-tone-paired-with-icon-or-badge
71
+ level: must-not
72
+ statement: 'Don''t give Text a non-neutral tone (suggest, positive, caution, critical) unless it leads with the state, as in "**Error:** Upload failed.", or sits beside a matching icon in the same UI region.'
73
+ example:
74
+ title: The prohibited form — tone with no second channel
75
+ description: '`<Text tone="critical">Upload failed</Text>` with no icon beside it. The words describe what happened but do not name the state, so the colour does the work. To verify, view the region in grayscale and confirm the status still reads without colour. Fix it with a paired icon (InfoOutlineIcon, CheckmarkIcon, WarningOutlineIcon, ErrorOutlineIcon), or lead with the state: "**Error:** Upload failed."'
76
+ checkedBy: manual
77
+ refines:
78
+ - to: shared-foundations#tone-paired-with-second-channel
79
+ - id: text-no-emojis
80
+ level: must-not
81
+ statement: Never intersperse emojis with text, under any circumstances — not inline mid-sentence, not as a bullet substitute, not as a leading or trailing accent. An emoji inside a Text run is announced by its CLDR name in the middle of the sentence, disrupts line-height and vertical rhythm, and renders differently on every platform. When a visual symbol is required, use Icon beside the Text.
82
+ checks:
83
+ - href: ../evals/cases.yaml
84
+ role: agent-test
85
+ checkedBy: assisted
86
+ refines:
87
+ - to: shared-foundations#no-emojis
88
+ $extensions:
89
+ io.jev:
90
+ type: boolean
91
+ - kind: guidelines
92
+ for: agent
93
+ framing: how-to-use
94
+ items:
95
+ - level: must-not
96
+ statement: Don't use inline font-size or color styles on Text. Use the size, weight, and tone props instead.
97
+ - kind: guidelines
98
+ for: all
99
+ title: Content
100
+ tags: [content]
101
+ items:
102
+ - refs:
103
+ - to: content-guidelines#sentence-case-all-system-set
104
+ rel: same-as
105
+ - level: should
106
+ statement: Frame instructions as clear steps, not passive descriptions.
107
+ - refs:
108
+ - to: content-guidelines#plain-language
109
+ rel: same-as
110
+ - kind: guidelines
111
+ for: all
112
+ title: Accessibility
113
+ tags: [accessibility]
114
+ items:
115
+ - level: must
116
+ statement: Text must maintain 4.5:1 contrast against the background for standard text and 3:1 for large text (WCAG 1.4.3 AA). Take care with `muted` on non-white backgrounds.
117
+ - level: must
118
+ statement: Text must remain legible at 200% browser zoom. Avoid fixed pixel units in overrides.
119
+ - level: should
120
+ statement: Text defaults to `<span>`. Use `as="p"` when the text should serve as a paragraph. Use `as="li"` inside lists.
121
+ - kind: section
122
+ for: all
123
+ freeform:
124
+ - title: Semantics
125
+ body: |-
126
+ `as` sets the HTML element Text renders. It defaults to `span` and accepts any
127
+ element type, so the element is yours to choose and yours to get right — Text
128
+ applies no semantics of its own beyond the tag you name.
129
+
130
+ - Use `as="p"` for a paragraph, and `as="li"` inside a list.
131
+ - Use `as="abbr"` for abbreviations and acronyms. Avoid shortening terms — internal terms and jargon above all.
132
+ - Use `as="dfn"` for terms a reader may not know on first read. Link to a dedicated page when a short definition doesn't work.
133
+ alternatives:
134
+ - to: heading
135
+ note: Semantic page headings that define content hierarchy
136
+ - to: code
137
+ - to: kbd
138
+ refs:
139
+ - to: badge
140
+ rel: relates-to
141
+ note: Inline status labels with semantic tone
142
+ sourceFiles:
143
+ - platform: react
144
+ file: packages/ui/src/components/text/Text.tsx
145
+ imports:
146
+ - platform: react
147
+ code: import { Text } from '@sanity/ui'
148
+ package: '@sanity/ui'
149
+ traits:
150
+ - traitType: variant
151
+ kind: enum
152
+ id: truncate
153
+ description: 'Limits the text to a set number of lines and adds an ellipsis once it overflows. Takes a positive integer and accepts a responsive array (`truncate={[1, 1, 2]}`). Fill every slot up to the last one you set: `undefined` in a slot turns truncation off at that breakpoint. Unset means no truncation. Use it for metadata and support labels only — never for body text or a preview of it.'
154
+ values:
155
+ - id: '1'
156
+ description: 'One line. Clipped with `text-overflow: ellipsis` and `white-space: nowrap`, applied through the `sui-text-overflow` class.'
157
+ - id: '2-or-more'
158
+ description: Clamped to that many lines with `-webkit-line-clamp`. Any integer above 1 works; the value passes straight through.
159
+ - traitType: variant
160
+ kind: enum
161
+ id: size
162
+ description: Visual font size from the body text scale.
163
+ values:
164
+ - id: '0'
165
+ description: Smallest. Fine print, legal text, high-density layouts.
166
+ - id: '1'
167
+ description: Small. UI labels, menu items, toast messages, empty states.
168
+ - id: '2'
169
+ description: Medium (default). Content editing text, calls to action.
170
+ - id: '3'
171
+ description: Large. Rarely needed. Used for increased visual hierarchy/emphasis.
172
+ - id: '4'
173
+ description: Extra large. Rarely needed. Used for high visual hierarchy/emphasis or decorative purposes.
174
+ - traitType: variant
175
+ kind: enum
176
+ id: tone
177
+ description: Semantic text color.
178
+ values:
179
+ - id: neutral
180
+ description: Default. No semantic meaning.
181
+ - id: suggest
182
+ description: Suggestions or informational content. Pair with InfoOutlineIcon.
183
+ - id: positive
184
+ description: Success, published, healthy. Pair with CheckmarkIcon.
185
+ - id: caution
186
+ description: Needs attention. Pair with WarningOutlineIcon.
187
+ - id: critical
188
+ description: Error, failed, rejected. Pair with ErrorOutlineIcon.
189
+ - traitType: variant
190
+ kind: boolean
191
+ id: muted
192
+ description: Reduces visual prominence for secondary or helper text like timestamps and captions.
193
+ - traitType: variant
194
+ kind: boolean
195
+ id: trim
196
+ description: Removes extra whitespace above and below the text box for precise alignment with icons or badges.
197
+ - traitType: variant
198
+ kind: enum
199
+ id: align
200
+ description: CSS text-align property.
201
+ values:
202
+ - id: left
203
+ description: Default. Body copy, UI labels, and most other cases.
204
+ - id: center
205
+ description: Rare. Empty-state copy, labels inside centered UI elements.
206
+ - id: right
207
+ description: Numeric data in table cells, or right-to-left body copy.
208
+ - traitType: variant
209
+ kind: enum
210
+ id: weight
211
+ description: CSS font-weight property.
212
+ values:
213
+ - id: regular
214
+ description: Default. General body text above size 0.
215
+ - id: medium
216
+ description: Visual separation from body copy; improves legibility at small sizes.
217
+ - id: semibold
218
+ description: Emphasis within body copy, or labels in custom interactive components.
219
+ - id: bold
220
+ description: Strong emphasis at size 0, to aid legibility at the smallest size.
221
+ $extensions:
222
+ com.sanity.ui:
223
+ implementationStatus:
224
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
225
+ implemented: true
226
+ migrationGuide:
227
+ 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.'
228
+ codemod: |-
229
+ `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. The codemod also adds `as="div"` and `trim` so migrated markup keeps its v3 rendering.
230
+
231
+ Run the codemod: `pnpx @sanity/ui-codemod latest:text --paths <paths> --toPackage @sanity/ui`.
232
+ guidance: |-
233
+ Text in the new system has new typography props. **Text no longer removes top/bottom text spacing by default. Use `trim` to match Sanity UI 3's vertical trimming style.**
234
+
235
+ ### Key differences
236
+
237
+ - v5 components use CSS classes with a static stylesheet instead of `styled-components`.
238
+ - v3 Text rendered a `<div>` by default. The new Text renders `<span>`. Use `as="p"` when Text is long-form or block-level content.
239
+ - `textOverflow` replaced by `truncate`. Use `truncate={1}` for single-line truncation.
240
+ - `accent` removed. Use `tone` or a parent with a semantic tone for colored text.
241
+ - `trim` added. Removes extra whitespace above and below the text box when needed.
242
+ - Margin props added. Text now accepts `margin`, `marginX`, `marginY`, and per-side margin props.
243
+
244
+ ### Detailed list of differences
245
+
246
+ | v3 prop | v5 prop | Notes |
247
+ | :---- | :---- | :---- |
248
+ | `accent` | — | Removed. No accent color prop. |
249
+ | `textOverflow="ellipsis"` | `truncate={1}` | The codemod maps both `"ellipsis"` and `"clip"` to `truncate={1}`. |
250
+ | — | `trim` | New. Applies `text-box-trim` for precise vertical alignment. |
251
+ | — | `truncate` | New. Limit to N visible lines. Adds multi-line clamping. |
252
+ | — | `margin*` | New. Text accepts margin props directly. |
253
+
254
+ ### Breaking changes
255
+
256
+ - `textOverflow` prop removed. `<Text textOverflow="ellipsis">` will fire a TypeScript error. Use `<Text truncate={1}>`.
257
+ - `accent` prop removed. `<Text accent>` does nothing. Use Card `tone` or a parent element with a semantic tone.
258
+ - `styled-components` is no longer used. Custom styled-components extensions like `styled(Text)` will not work.
259
+
260
+ ### Codemod
261
+
262
+ A codemod is available to ease the changes above. Run the command below with the path to the file or folder you want to migrate. Use spaces to pass more than one path.
263
+
264
+ ```
265
+ pnpx @sanity/ui-codemod latest:text --paths <paths> --toPackage @sanity/ui
266
+ ```
267
+
268
+ If a component instance cannot be migrated or needs manual review, the codemod inserts a comment prefixed with “UI-POC-CODEMOD TODO”.
@@ -0,0 +1,90 @@
1
+ kind: component
2
+ id: tooltip-group
3
+ name: TooltipGroup
4
+ description: A container that lets the rest of a row's tooltips show at once after the first one has shown.
5
+ metadata:
6
+ tags: [tooltip, group, toolbar, action-bar]
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: should
16
+ statement: A toolbar or action bar where each button has a tooltip.
17
+ - level: should
18
+ statement: A row of icon-only controls that a user scans across.
19
+ - level: should-not
20
+ statement: A single button with one tooltip. TooltipGroup adds no value for a single trigger.
21
+ alternatives:
22
+ - to: tooltip
23
+ - level: should-not
24
+ statement: Controls spread across the page. The grouped behaviour only applies inside the group element.
25
+ - kind: guidelines
26
+ for: all
27
+ framing: how-to-use
28
+ items:
29
+ - level: should
30
+ statement: Wrap only tooltips that are logically grouped — a toolbar, an action bar, or a row of icon buttons.
31
+ - level: must-not
32
+ statement: Do not use TooltipGroup for a single trigger. It adds no value and creates unnecessary markup.
33
+ - kind: guidelines
34
+ for: agent
35
+ framing: how-to-use
36
+ items:
37
+ - level: must
38
+ statement: The group wrapper has no ARIA role. Individual Tooltip components still wire aria-describedby on their triggers.
39
+ - level: should
40
+ statement: Use TooltipGroup when multiple adjacent triggers each have a Tooltip — a toolbar, action bar, or icon row.
41
+ - kind: section
42
+ for: agent
43
+ freeform:
44
+ - title: How it works
45
+ body: |-
46
+ Without a group, each tooltip in a toolbar opens on its own, so the user sees a pause at every button they scan across.
47
+
48
+ Once one tooltip in the group is visible, the rest show at once.
49
+
50
+ When the mouse leaves the group or focus moves outside it, the group resets.
51
+
52
+ ```tsx
53
+ import { TooltipGroup, Tooltip, IconButton } from '@sanity/ui'
54
+ import { TrashIcon } from '@sanity/icons/Trash'
55
+ import { EditIcon } from '@sanity/icons/Edit'
56
+ import { CopyIcon } from '@sanity/icons/Copy'
57
+
58
+ <TooltipGroup>
59
+ <Tooltip content="Delete">
60
+ <IconButton icon={TrashIcon} aria-label="Delete" level="tertiary" />
61
+ </Tooltip>
62
+ <Tooltip content="Edit">
63
+ <IconButton icon={EditIcon} aria-label="Edit" level="tertiary" />
64
+ </Tooltip>
65
+ <Tooltip content="Duplicate">
66
+ <IconButton icon={CopyIcon} aria-label="Duplicate" level="tertiary" />
67
+ </Tooltip>
68
+ </TooltipGroup>
69
+ ```
70
+
71
+ Once one tooltip in the group is visible, the rest show at once.
72
+
73
+ When the mouse leaves the group or focus moves outside it, the group resets.
74
+
75
+ refs:
76
+ - to: tooltip
77
+ rel: relates-to
78
+ note: The floating label that TooltipGroup coordinates
79
+ sourceFiles:
80
+ - platform: react
81
+ file: packages/ui/src/components/tooltip-group/TooltipGroup.tsx
82
+ imports:
83
+ - platform: react
84
+ code: import { TooltipGroup } from '@sanity/ui'
85
+ package: '@sanity/ui'
86
+ $extensions:
87
+ com.sanity.ui:
88
+ implementationStatus:
89
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
90
+ implemented: true
@@ -0,0 +1,216 @@
1
+ kind: component
2
+ id: tooltip
3
+ name: Tooltip
4
+ description: A floating text label that shows information when a user hovers or focuses an element.
5
+ metadata:
6
+ tags: [tooltip, label, hover, focus, supplementary, help, hint, description]
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: should
16
+ statement: To explain the function of an icon-only button.
17
+ - level: should
18
+ statement: To provide supplementary information that enhances understanding but isn't critical for the task.
19
+ - level: should-not
20
+ statement: The information is necessary for the user to complete a task. Use inline text or banners instead.
21
+ - level: should-not
22
+ statement: To contain interactive elements such as buttons. Use Popover instead.
23
+ alternatives:
24
+ - to: popover
25
+ - level: should-not
26
+ statement: When you are restating text that is already visible on the screen.
27
+ - refs:
28
+ - to: tooltip#no-tooltip-on-disabled
29
+ rel: same-as
30
+ - id: tooltip-only-on-interactive-elements
31
+ level: must-not
32
+ statement: Never use Tooltip on a non-interactive element — text, a Badge, an Indicator, an Avatar, a bare Icon, or a Box or Card. Its trigger must be a button, a link, or a PressArea. Either put the information in visible text or wrap the non-interactive element in a PressArea.
33
+ - kind: guidelines
34
+ for: all
35
+ framing: how-to-use
36
+ items:
37
+ - level: must
38
+ statement: For an icon-only trigger, give the trigger its own aria-label and make it focusable (use IconButton or Button, not a bare Icon). Tooltip's content sets aria-describedby — a description, not the trigger's accessible name; a bare Icon is aria-hidden by default and cannot receive focus.
39
+ tags: [accessibility]
40
+ - level: should
41
+ statement: Limit text to a maximum of 50 characters where possible.
42
+ - level: should
43
+ statement: "Start with a verb if describing an action (for example, 'Edit profile' rather than 'Profile editor')."
44
+ - level: should
45
+ statement: Omit the Tooltip entirely when the label text is already visible next to the trigger.
46
+ - level: should
47
+ statement: "Wrap a toolbar of tooltipped triggers in TooltipGroup so the row's tooltips behave as one group."
48
+ uses:
49
+ - to: tooltip-group
50
+ - level: must-not
51
+ statement: Don't put interactive content like links or buttons inside a Tooltip — use Popover instead.
52
+ alternatives:
53
+ - to: popover
54
+ - id: no-tooltip-on-disabled
55
+ level: must-not
56
+ statement: A disabled or loading control does not trigger a Tooltip, because keyboard users cannot reach it. If the Tooltip must show on a disabled element, wrap that element in a PressArea and put the Tooltip on the PressArea.
57
+ refines:
58
+ - to: accessibility-guidelines#disabled-control-no-tooltip
59
+ - kind: guidelines
60
+ for: agent
61
+ framing: how-to-use
62
+ items:
63
+ - level: must
64
+ statement: Tooltip needs the entry-file setup in the `installation` guide. It is built on the Interest Invokers API, which is not yet in every browser, and without that setup tooltips do not show where it is missing.
65
+ - level: must
66
+ statement: Tooltip must appear on both hover and keyboard focus — not hover-only.
67
+ tags: [accessibility]
68
+ - level: must
69
+ statement: Tooltip wraps a single child element. It clones that child to inject aria-describedby — you do not need to wire it manually.
70
+ - level: must
71
+ statement: The child of Tooltip must be a single React element (not a string, fragment, or array).
72
+ - level: must
73
+ statement: The child must render an element that accepts interestfor — in practice a button or an anchor with href. Button and IconButton both work; a Box, Text, or bare Icon does not.
74
+ - level: must
75
+ statement: The label prop is called content. There is no text prop. Do not use `title` instead — it compiles, but it renders the browser's own tooltip, not this one.
76
+ - level: must
77
+ statement: There is no disabled prop. To suppress a tooltip conditionally, render the trigger with or without the Tooltip wrapper.
78
+ - level: should
79
+ statement: Set portal only when an ancestor clips or misplaces the label.
80
+ - level: may
81
+ statement: Set the same anchorName on a Tooltip and a Popover to attach both to one trigger, with the Tooltip nested inside the Popover.
82
+ - refs:
83
+ - to: tooltip#no-tooltip-on-disabled
84
+ rel: same-as
85
+ - level: must-not
86
+ statement: 'Using Tooltip for critical task information. Instead: Show necessary information inline — users should not be required to hover to find it.'
87
+ - kind: section
88
+ for: agent
89
+ freeform:
90
+ - title: How it works
91
+ body: |-
92
+ Tooltip renders its label as a popover hint and clones its child to attach `aria-describedby` and the `interestfor` attribute that shows it. Hover and focus handling comes from the Interest Invokers API rather than from React event handlers.
93
+
94
+ Clicking the trigger hides the label and suppresses it until the pointer leaves the trigger or focus moves away. This keeps a tooltip from covering whatever the click opened — a Popover on the same button, for example.
95
+
96
+ Positioning is CSS, not JavaScript. `placement` maps to a class that uses CSS anchor positioning, and viewport flipping comes from `position-try-fallbacks`.
97
+ - kind: section
98
+ for: all
99
+ freeform:
100
+ - title: Setup
101
+ body: |-
102
+ Tooltip is built on the Interest Invokers API (the `interestfor` attribute), which is not yet available in every browser. The entry-file setup in the `installation` guide loads a polyfill, only where the browser lacks native support. Without it, tooltips will not show in those browsers.
103
+
104
+ alternatives:
105
+ - to: popover
106
+ note: Use when the floating content is interactive or contains more than a short label. Share a trigger with a Tooltip via `anchorName`
107
+ refs:
108
+ - href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=33882-565
109
+ rel: design
110
+ role: Figma component (v5)
111
+ - to: tooltip-group
112
+ rel: relates-to
113
+ note: Wrap a toolbar of tooltips so they behave as one group.
114
+ - to: button
115
+ rel: relates-to
116
+ note: The most common trigger for a Tooltip
117
+ - to: icon-button
118
+ rel: relates-to
119
+ note: The most common trigger for a Tooltip
120
+ - to: indicator
121
+ rel: relates-to
122
+ note: Use a Tooltip for an indicator's meaning only when no adjacent text label is present. Wrap the Indicator in a PressArea so the Tooltip has a trigger.
123
+ sourceFiles:
124
+ - platform: react
125
+ file: packages/ui/src/components/tooltip/Tooltip.tsx
126
+ imports:
127
+ - platform: react
128
+ code: import { Tooltip } from '@sanity/ui'
129
+ package: '@sanity/ui'
130
+ traits:
131
+ - traitType: variant
132
+ kind: enum
133
+ id: placement
134
+ description: >-
135
+ Position of the floating label relative to its trigger. Keeps the label in
136
+ the viewport and clear of whatever sits next to the trigger. Each value
137
+ declares a fallback on the opposite side, so the browser flips the label
138
+ rather than letting it overflow.
139
+ values:
140
+ - id: top
141
+ description: Above the trigger, centered.
142
+ - id: top-start
143
+ description: Above, aligned to the start edge.
144
+ - id: top-end
145
+ description: Above, aligned to the end edge.
146
+ - id: right
147
+ description: >-
148
+ Right of the trigger, centered. For narrow sidebars where vertical
149
+ space is limited.
150
+ - id: right-start
151
+ description: Right, aligned to the start edge.
152
+ - id: right-end
153
+ description: Right, aligned to the end edge.
154
+ - id: bottom
155
+ description: >-
156
+ Below the trigger, centered. The default. The safe default for a
157
+ toolbar or an inline control.
158
+ - id: bottom-start
159
+ description: Below, aligned to the start edge.
160
+ - id: bottom-end
161
+ description: Below, aligned to the end edge.
162
+ - id: left
163
+ description: >-
164
+ Left of the trigger, centered. For narrow sidebars where vertical
165
+ space is limited.
166
+ - id: left-start
167
+ description: Left, aligned to the start edge.
168
+ - id: left-end
169
+ description: Left, aligned to the end edge.
170
+ - traitType: variant
171
+ kind: boolean
172
+ id: portal
173
+ description: >-
174
+ Renders the floating label into document.body through a React portal
175
+ instead of inline. Rarely needed — the label already sits in the browser's
176
+ top layer, so overflow ancestors do not clip it. Reach for it when an
177
+ ancestor with transform, filter, or contain creates a containing block
178
+ that breaks anchor positioning. Portalled content does not render during
179
+ server-side rendering.
180
+ $extensions:
181
+ com.sanity.ui:
182
+ implementationStatus:
183
+ context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
184
+ implemented: true
185
+ migrationGuide:
186
+ 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.'
187
+ guidance: |-
188
+ The v3 Tooltip was positioned by Floating UI, rendered through a portal, and configured with a large set of props. The v5 Tooltip is built on Interest Invokers, the Popover API, and CSS anchor positioning, so most of that configuration is now handled by the browser.
189
+
190
+ ### **Key differences**
191
+
192
+ - **`content` keeps its name.** The prop that holds the label is `content` in both versions.
193
+ - **Positioning is CSS, not JavaScript.** Floating UI is gone. `placement` maps to a CSS class, and viewport flipping uses `position-try-fallbacks`.
194
+ - **No `disabled` prop.** Conditionally render the trigger with or without the Tooltip wrapper instead.
195
+ - **`TooltipDelayGroupProvider` is replaced by `TooltipGroup`**, which is a rendered element rather than a context provider.
196
+ - **Card styling props are gone.** v3 rendered a `TooltipCard` and accepted `radius`, `shadow`, `padding`, and `scheme`. v5 applies a fixed surface style.
197
+ - **No arrow.** The `arrow` prop is removed.
198
+ - **The polyfills entry point is now required.** See Setup.
199
+
200
+ ### **Detailed list of differences**
201
+
202
+ | v3 prop | v5 prop | Notes |
203
+ | :---- | :---- | :---- |
204
+ | `content` | `content` | Same purpose |
205
+ | `children` | `children` | Now required, and must render a `<button>` or `<a href>` |
206
+ | `placement` | `placement` | Same values, same default (`'bottom'`) |
207
+ | `portal` | `portal` | Now `boolean` only; v3 also accepted a portal name string |
208
+ | `disabled` | — | Removed. Conditionally render the Tooltip wrapper instead. |
209
+ | `arrow` | — | Removed |
210
+ | `animate` | — | Removed. The show and hide transition is always applied. |
211
+ | `fallbackPlacements`, `allowedAutoPlacements` | — | Removed. CSS `position-try-fallbacks` flips the tooltip automatically. |
212
+ | `boundaryElement` | — | Removed. The viewport is the boundary. |
213
+ | `radius`, `shadow`, `padding`, `scheme` | — | Removed. The tooltip surface has a fixed style. |
214
+ | `zOffset`, `onActivate` | — | Removed. The browser's top layer handles stacking. |
215
+ | — | `anchorName` | New. Share one trigger between a Tooltip and a Popover. |
216
+ | `TooltipDelayGroupProvider` | `TooltipGroup` | Now a rendered element, not a context provider |