@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.
- package/README.md +10 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/components/avatar-counter.dsds.yaml +78 -0
- package/docs/components/avatar-stack.dsds.yaml +96 -0
- package/docs/components/avatar.dsds.yaml +115 -0
- package/docs/components/badge.dsds.yaml +126 -0
- package/docs/components/box.dsds.yaml +223 -0
- package/docs/components/button.dsds.yaml +284 -0
- package/docs/components/card.dsds.yaml +317 -0
- package/docs/components/checkbox.dsds.yaml +204 -0
- package/docs/components/code.dsds.yaml +167 -0
- package/docs/components/container.dsds.yaml +189 -0
- package/docs/components/dialog.dsds.yaml +343 -0
- package/docs/components/divider.dsds.yaml +93 -0
- package/docs/components/eyebrow.dsds.yaml +217 -0
- package/docs/components/flex.dsds.yaml +237 -0
- package/docs/components/grid.dsds.yaml +217 -0
- package/docs/components/h-stack.dsds.yaml +127 -0
- package/docs/components/heading.dsds.yaml +233 -0
- package/docs/components/hotkeys.dsds.yaml +60 -0
- package/docs/components/icon-button.dsds.yaml +220 -0
- package/docs/components/icon.dsds.yaml +275 -0
- package/docs/components/indicator-stack.dsds.yaml +98 -0
- package/docs/components/indicator.dsds.yaml +108 -0
- package/docs/components/inline.dsds.yaml +127 -0
- package/docs/components/kbd.dsds.yaml +59 -0
- package/docs/components/link.dsds.yaml +108 -0
- package/docs/components/list-button-item.dsds.yaml +103 -0
- package/docs/components/list-item-image.dsds.yaml +82 -0
- package/docs/components/list-item-text.dsds.yaml +80 -0
- package/docs/components/list-item.dsds.yaml +148 -0
- package/docs/components/list.dsds.yaml +162 -0
- package/docs/components/popover.dsds.yaml +208 -0
- package/docs/components/press-area.dsds.yaml +279 -0
- package/docs/components/radio.dsds.yaml +198 -0
- package/docs/components/select.dsds.yaml +214 -0
- package/docs/components/skip-to-content.dsds.yaml +110 -0
- package/docs/components/spinner.dsds.yaml +119 -0
- package/docs/components/switch.dsds.yaml +202 -0
- package/docs/components/tab.dsds.yaml +54 -0
- package/docs/components/tabs-list.dsds.yaml +56 -0
- package/docs/components/tabs-panel.dsds.yaml +54 -0
- package/docs/components/tabs.dsds.yaml +104 -0
- package/docs/components/text-area.dsds.yaml +170 -0
- package/docs/components/text-input.dsds.yaml +189 -0
- package/docs/components/text.dsds.yaml +268 -0
- package/docs/components/tooltip-group.dsds.yaml +90 -0
- package/docs/components/tooltip.dsds.yaml +216 -0
- package/docs/components/v-stack.dsds.yaml +155 -0
- package/docs/components/visually-hidden.dsds.yaml +112 -0
- package/docs/evals/cases.yaml +1319 -0
- package/docs/examples/checkbox-2.tsx +57 -0
- package/docs/examples/confirmation-dialogs-1.tsx +27 -0
- package/docs/examples/confirmation-dialogs-2.tsx +55 -0
- package/docs/examples/confirmation-dialogs-3.tsx +28 -0
- package/docs/examples/confirmation-dialogs-4.tsx +38 -0
- package/docs/examples/popover-1.tsx +48 -0
- package/docs/examples/popover-2.tsx +53 -0
- package/docs/foundations/accessibility-guidelines.dsds.yaml +301 -0
- package/docs/foundations/color-guidelines.dsds.yaml +308 -0
- package/docs/foundations/content-guidelines.dsds.yaml +285 -0
- package/docs/foundations/semantics.dsds.yaml +125 -0
- package/docs/foundations/spacing-guidelines.dsds.yaml +226 -0
- package/docs/foundations/typography-guidelines.dsds.yaml +322 -0
- package/docs/icons.dsds.yaml +2513 -0
- package/docs/index.dsds.yaml +515 -0
- package/docs/overview/api-essentials.dsds.yaml +221 -0
- package/docs/overview/component-reference.dsds.yaml +215 -0
- package/docs/overview/designer-contribution-model.dsds.yaml +77 -0
- package/docs/overview/developer-contribution-model.dsds.yaml +362 -0
- package/docs/overview/installation.dsds.yaml +238 -0
- package/docs/overview/quick-start.dsds.yaml +317 -0
- package/docs/overview/resources.dsds.yaml +34 -0
- package/docs/patterns/confirmation-dialogs.dsds.yaml +140 -0
- package/docs/patterns/error-messaging.dsds.yaml +58 -0
- package/docs/patterns/forms.dsds.yaml +356 -0
- package/docs/patterns/layouts.dsds.yaml +403 -0
- package/docs/patterns/loading-states.dsds.yaml +41 -0
- package/docs/patterns/messaging.dsds.yaml +72 -0
- package/docs/patterns/navigation.dsds.yaml +153 -0
- package/docs/patterns/responsive.dsds.yaml +590 -0
- package/docs/tokens/color.dsds.yaml +1158 -0
- package/docs/tokens/container-widths.dsds.yaml +131 -0
- package/docs/tokens/content.dsds.yaml +258 -0
- package/docs/tokens/content.tokens.json +180 -0
- package/docs/tokens/dtcg/README.md +39 -0
- package/docs/tokens/dtcg/css/color.css +107 -0
- package/docs/tokens/dtcg/css/container.css +12 -0
- package/docs/tokens/dtcg/css/fontFamily.css +10 -0
- package/docs/tokens/dtcg/css/fontWeight.css +10 -0
- package/docs/tokens/dtcg/css/index.css +13 -0
- package/docs/tokens/dtcg/css/radius.css +14 -0
- package/docs/tokens/dtcg/css/semantic.css +42 -0
- package/docs/tokens/dtcg/css/shadow.css +22 -0
- package/docs/tokens/dtcg/css/space.css +16 -0
- package/docs/tokens/dtcg/css/typography.css +69 -0
- package/docs/tokens/dtcg/json/color.tokens.json +911 -0
- package/docs/tokens/dtcg/json/container.tokens.json +44 -0
- package/docs/tokens/dtcg/json/fontFamily.tokens.json +10 -0
- package/docs/tokens/dtcg/json/fontWeight.tokens.json +18 -0
- package/docs/tokens/dtcg/json/radius.tokens.json +58 -0
- package/docs/tokens/dtcg/json/semantic.tokens.json +372 -0
- package/docs/tokens/dtcg/json/shadow.tokens.json +599 -0
- package/docs/tokens/dtcg/json/space.tokens.json +72 -0
- package/docs/tokens/dtcg/json/typography.tokens.json +354 -0
- package/docs/tokens/font-family.dsds.yaml +79 -0
- package/docs/tokens/font-weight.dsds.yaml +103 -0
- package/docs/tokens/radius.dsds.yaml +153 -0
- package/docs/tokens/semantic.dsds.yaml +397 -0
- package/docs/tokens/shadow.dsds.yaml +125 -0
- package/docs/tokens/space.dsds.yaml +185 -0
- package/docs/tokens/typography.dsds.yaml +316 -0
- package/llms.txt +108 -0
- package/package.json +5 -2
- package/skills/sanity-ui-5/SKILL.md +158 -0
- package/skills/sanity-ui-5/references/component-choice.md +37 -0
- package/skills/sanity-ui-5/references/components.md +145 -0
- package/skills/sanity-ui-5/references/forms-and-accessibility.md +189 -0
- package/skills/sanity-ui-5/references/migrating-from-v3.md +250 -0
- package/skills/sanity-ui-5/references/props-and-imports.md +169 -0
- package/skills/sanity-ui-5/references/setup.md +177 -0
- package/skills/sanity-ui-5/references/silent-failures.md +33 -0
- package/skills/sanity-ui-5/references/taste.md +53 -0
- package/skills/sanity-ui-5/references/tone-and-color.md +55 -0
- package/src/version.ts +2 -2
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: dialog
|
|
3
|
+
name: Dialog
|
|
4
|
+
description: Presents a gating task or decision that blocks other interaction until completed. Use it only in cases where a decision must be made to proceed.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [dialog, modal, overlay, confirmation, form, alert, popup, destructive, blocking]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
since: 5.0.0-alpha.7
|
|
10
|
+
note: Shipped as Modal in @sanity/ui@5.0.0-alpha.5 and renamed to Dialog in 5.0.0-alpha.7. There is no Modal alias. Still marked @beta — the API may change before it's stable.
|
|
11
|
+
aliases: [Modal]
|
|
12
|
+
sections:
|
|
13
|
+
- kind: guidelines
|
|
14
|
+
for: all
|
|
15
|
+
framing: when-to-use
|
|
16
|
+
title: When to use
|
|
17
|
+
items:
|
|
18
|
+
- level: must
|
|
19
|
+
statement: Give every Dialog an accessible name via a header (aria-labelledby) or aria-label.
|
|
20
|
+
tags: [accessibility]
|
|
21
|
+
- level: should
|
|
22
|
+
statement: To confirm a destructive action before it occurs (deleting a file, removing a user).
|
|
23
|
+
- level: should
|
|
24
|
+
statement: To request specific input needed for a critical task to complete.
|
|
25
|
+
- level: should
|
|
26
|
+
statement: To display an error that needs direct user input to proceed.
|
|
27
|
+
- level: should
|
|
28
|
+
statement: To display terms or legal agreements that require explicit consent.
|
|
29
|
+
- level: should-not
|
|
30
|
+
statement: To display a system update that doesn't need user input. Use Popover instead.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: popover
|
|
33
|
+
- level: should-not
|
|
34
|
+
statement: To display non-essential contextual information. Use Popover or Tooltip instead.
|
|
35
|
+
alternatives:
|
|
36
|
+
- to: popover
|
|
37
|
+
- to: tooltip
|
|
38
|
+
- level: should-not
|
|
39
|
+
statement: To highlight a new feature or brand moment. Use Popover instead.
|
|
40
|
+
alternatives:
|
|
41
|
+
- to: popover
|
|
42
|
+
- level: should-not
|
|
43
|
+
statement: As a way to disclose a non-essential feature or display secondary content. Navigate to a new screen or display in an end-aligned column instead.
|
|
44
|
+
- kind: guidelines
|
|
45
|
+
for: agent
|
|
46
|
+
framing: when-to-use
|
|
47
|
+
title: When to use
|
|
48
|
+
items:
|
|
49
|
+
- level: should-not
|
|
50
|
+
statement: Don't use Dialog for non-blocking status messages. Use Popover instead.
|
|
51
|
+
alternatives:
|
|
52
|
+
- to: popover
|
|
53
|
+
- level: should-not
|
|
54
|
+
statement: Don't use Dialog for brief hover labels. Use Tooltip instead.
|
|
55
|
+
alternatives:
|
|
56
|
+
- to: tooltip
|
|
57
|
+
- kind: guidelines
|
|
58
|
+
for: all
|
|
59
|
+
framing: how-to-use
|
|
60
|
+
items:
|
|
61
|
+
- level: must
|
|
62
|
+
statement: Dialog must be cancelable or dismissible. Users should not be trapped into agreeing or initiating an action.
|
|
63
|
+
tags: [interaction]
|
|
64
|
+
- id: destructive-dialog-title-names-target
|
|
65
|
+
level: must
|
|
66
|
+
statement: 'Destructive-action Dialogs must name the action and its target in the title — for example, "Delete [PAGE NAME]?", not a vague title like "Delete?". The consequence goes in the body, not the title: what will be lost and whether it can be recovered.'
|
|
67
|
+
checks:
|
|
68
|
+
- href: ../evals/cases.yaml
|
|
69
|
+
role: agent-test
|
|
70
|
+
checkedBy: assisted
|
|
71
|
+
tags: [content]
|
|
72
|
+
$extensions:
|
|
73
|
+
io.jev:
|
|
74
|
+
type: boolean
|
|
75
|
+
- level: must
|
|
76
|
+
statement: Dialog body text must present the full details of what will happen — for example, listing every item being deleted and whether the data is recoverable.
|
|
77
|
+
tags: [content]
|
|
78
|
+
- tags: [content]
|
|
79
|
+
refs:
|
|
80
|
+
- to: shared-foundations#destructive-actions-use-critical-tone
|
|
81
|
+
rel: same-as
|
|
82
|
+
- level: should
|
|
83
|
+
statement: >-
|
|
84
|
+
Set `topAnchor` when the Dialog's content can grow taller, so the Dialog does not shift as it grows. It takes a CSS length, the distance from the top of the viewport, such as `topAnchor="10vh"`. The Dialog docks at that distance, and its height is capped at the viewport height minus twice the distance.
|
|
85
|
+
- level: should
|
|
86
|
+
statement: Use Dialog only in cases where a decision must be made to proceed. If the user can carry on without answering, it is not a Dialog.
|
|
87
|
+
tags: [interaction]
|
|
88
|
+
- level: should
|
|
89
|
+
statement: Choose a size that matches the content. The default suits a confirmation; a form needs 1 or 2.
|
|
90
|
+
- level: should
|
|
91
|
+
statement: Treat each Dialog as a mini, self-contained surface. Include everything the user needs in the Dialog itself, repeating information from the surrounding page when needed for understanding.
|
|
92
|
+
tags: [content]
|
|
93
|
+
- level: must-not
|
|
94
|
+
statement: Never interrupt the user with upsells or marketing moments through a Dialog.
|
|
95
|
+
tags: [interaction]
|
|
96
|
+
- level: must-not
|
|
97
|
+
statement: Don't make Dialog a shortcut to presenting a new page.
|
|
98
|
+
tags: [interaction]
|
|
99
|
+
- kind: guidelines
|
|
100
|
+
for: agent
|
|
101
|
+
framing: how-to-use
|
|
102
|
+
items:
|
|
103
|
+
- level: must
|
|
104
|
+
statement: >-
|
|
105
|
+
Dialog needs the entry-file setup in the `installation` guide. Without it, backdrop-click dismissal does not work in Safari; Escape and the close button still do.
|
|
106
|
+
- level: must
|
|
107
|
+
statement: The component is called Dialog as of @sanity/ui@5.0.0-alpha.7. Modal, Modal.Content, Modal.Footer, and ModalProps no longer exist and there is no alias.
|
|
108
|
+
- level: must
|
|
109
|
+
statement: Dialog has two parts, Dialog.Content and Dialog.Footer. Look up their props in the Anatomy section of this entry before you write them.
|
|
110
|
+
- level: must
|
|
111
|
+
statement: onClose is required. It binds to the native close event and fires for every close cause.
|
|
112
|
+
- level: should
|
|
113
|
+
statement: Keep Dialog mounted and drive it with the open prop. Conditional mounting works but skips the open and close transitions.
|
|
114
|
+
- level: should
|
|
115
|
+
statement: For destructive confirmations, do not focus the destructive button on open — focus Cancel or the container. showModal() focuses the first focusable element, which is the close button by default.
|
|
116
|
+
- level: should
|
|
117
|
+
statement: Set a width by choosing a size value, or by composing a Container inside Dialog.Content. There is no width prop.
|
|
118
|
+
uses:
|
|
119
|
+
- to: container
|
|
120
|
+
- level: must-not
|
|
121
|
+
statement: Dialog has no `width` prop. Set the width with `size`, or compose a Container inside Dialog.Content.
|
|
122
|
+
- level: must-not
|
|
123
|
+
statement: Do not implement a focus trap, an Escape handler, or backdrop-click handling. The native dialog element provides all three.
|
|
124
|
+
- level: must-not
|
|
125
|
+
statement: 'Do not use Dialog for non-essential information, upsells, marketing or feature announcements. Use Popover or Tooltip for non-blocking content.'
|
|
126
|
+
- level: must-not
|
|
127
|
+
statement: 'Focusing the destructive action button when a destructive Dialog opens. Instead: Focus the Cancel button or the dialog container. An accidental Enter must not confirm the destructive action.'
|
|
128
|
+
- kind: guidelines
|
|
129
|
+
for: all
|
|
130
|
+
title: Content
|
|
131
|
+
tags: [content]
|
|
132
|
+
items:
|
|
133
|
+
- level: should
|
|
134
|
+
statement: Dialogs should be treated as a mini, self-contained surface. All necessary information should be included in the Dialog's content. Repeat information from the surrounding page when necessary.
|
|
135
|
+
- level: should
|
|
136
|
+
statement: Dialogs for destructive actions should name the action and its target in the title. For example, a dialog for deleting a document should be titled, "Delete \[PAGE NAME\]?". Do not use vague titles, such as "Delete?". Put the consequence in the body, not the title.
|
|
137
|
+
- level: should
|
|
138
|
+
statement: Dialog body text should present the full details for what action will take place. For example, listing out all what exactly will be deleted (if multiple items are being deleted), if/how the data is recoverable, etc.
|
|
139
|
+
- id: dialog-buttons-reinforce-the-action
|
|
140
|
+
level: should
|
|
141
|
+
statement: Dialog buttons should reinforce the action. The confirmation button for a dialog to delete 2 items should be labeled, "Delete 2 items". The cancel button should be labeled, "Do not delete". Do not use vague button labels, such as "Yes"/"No".
|
|
142
|
+
checks:
|
|
143
|
+
- href: ../evals/cases.yaml
|
|
144
|
+
role: agent-test
|
|
145
|
+
|
|
146
|
+
checkedBy: assisted
|
|
147
|
+
refines:
|
|
148
|
+
- to: content-guidelines#name-the-action
|
|
149
|
+
$extensions:
|
|
150
|
+
io.jev:
|
|
151
|
+
type: boolean
|
|
152
|
+
- kind: definitions
|
|
153
|
+
for: all
|
|
154
|
+
title: Anatomy
|
|
155
|
+
items:
|
|
156
|
+
- term: Dialog
|
|
157
|
+
definition: The native dialog element. Holds the header row, then whatever children you give it.
|
|
158
|
+
- term: Header row
|
|
159
|
+
definition: The heading text from the header prop, plus a close button. The close button is always rendered, with or without a header. `header` takes a string only, not an icon or other markup. Put anything richer at the top of Dialog.Content.
|
|
160
|
+
- term: Dialog.Content
|
|
161
|
+
definition: The scrollable body. Grows to fill the space between header and footer and scrolls on overflow. It has no props of its own; it takes the attributes of a `<div>`.
|
|
162
|
+
- term: Dialog.Footer
|
|
163
|
+
definition: The action row. Does not shrink, so it stays visible while the content scrolls. It has no props of its own; it takes the attributes of a `<div>`.
|
|
164
|
+
- kind: section
|
|
165
|
+
for: all
|
|
166
|
+
title: Basic example
|
|
167
|
+
freeform:
|
|
168
|
+
- title: Basic example
|
|
169
|
+
body: |
|
|
170
|
+
```tsx
|
|
171
|
+
import { Button, Dialog, Flex, Text } from '@sanity/ui'
|
|
172
|
+
import { useState } from 'react'
|
|
173
|
+
|
|
174
|
+
function PublishPageDialog({ page, onPublish }) {
|
|
175
|
+
const [open, setOpen] = useState(false)
|
|
176
|
+
|
|
177
|
+
function handlePublish() {
|
|
178
|
+
onPublish(page)
|
|
179
|
+
setOpen(false)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<>
|
|
184
|
+
<Button text="Publish page…" onClick={() => setOpen(true)} />
|
|
185
|
+
<Dialog
|
|
186
|
+
open={open}
|
|
187
|
+
onClose={() => setOpen(false)}
|
|
188
|
+
header={`Publish '${page.title}'?`}
|
|
189
|
+
>
|
|
190
|
+
<Dialog.Content>
|
|
191
|
+
<Text>
|
|
192
|
+
The page goes live on your site straight away. You can unpublish it later.
|
|
193
|
+
</Text>
|
|
194
|
+
</Dialog.Content>
|
|
195
|
+
<Dialog.Footer>
|
|
196
|
+
<Flex gap={3} justifyContent="flex-end">
|
|
197
|
+
<Button text="Keep editing" level="secondary" onClick={() => setOpen(false)} />
|
|
198
|
+
<Button text="Publish page" onClick={handlePublish} />
|
|
199
|
+
</Flex>
|
|
200
|
+
</Dialog.Footer>
|
|
201
|
+
</Dialog>
|
|
202
|
+
</>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
- kind: section
|
|
207
|
+
for: agent
|
|
208
|
+
freeform:
|
|
209
|
+
- title: How it works
|
|
210
|
+
body: |-
|
|
211
|
+
Dialog renders a native `<dialog>`. An effect calls `showModal()` when `open` becomes true and `close()` when it becomes false, and closes the dialog on unmount. Because it is opened as modal, the browser makes the rest of the document inert, renders it in the top layer, and traps focus — no focus-trap library is needed.
|
|
212
|
+
|
|
213
|
+
`onClose` is bound to the element's native `close` event, so it fires for every close cause: Escape, the close button, a backdrop click, or a programmatic `close()`.
|
|
214
|
+
|
|
215
|
+
`closedby="any"` is what makes a backdrop click dismiss the dialog. That attribute is not yet in Safari. v5 ships `dialog-closedby-polyfill` and applies it as part of the entry-file setup in the `installation` guide.
|
|
216
|
+
|
|
217
|
+
`size` maps to the shared container class, setting `max-width` only. The dialog's width is `calc(100dvw - 2rem)` and its height is capped at `calc(100dvh - 2rem)`.
|
|
218
|
+
- kind: section
|
|
219
|
+
for: all
|
|
220
|
+
freeform:
|
|
221
|
+
- title: Setup
|
|
222
|
+
body: |-
|
|
223
|
+
Dialog sets `closedby="any"` on the element so the browser dismisses it on a backdrop click. That attribute is not yet in Safari. v5 ships `dialog-closedby-polyfill` as a dependency and applies it through the entry-file setup in the `installation` guide, only where the attribute is missing. Without it, backdrop clicks will not dismiss the dialog in Safari; Escape and the close button still work.
|
|
224
|
+
alternatives:
|
|
225
|
+
- to: popover
|
|
226
|
+
note: Use for non-essential secondary content that should not block the page
|
|
227
|
+
- to: tooltip
|
|
228
|
+
note: Use for brief hover and focus labels
|
|
229
|
+
refs:
|
|
230
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32972-1053
|
|
231
|
+
rel: design
|
|
232
|
+
role: Figma component (v5)
|
|
233
|
+
- to: container
|
|
234
|
+
rel: relates-to
|
|
235
|
+
note: Compose inside `Dialog.Content` when you need a narrower measure than `size` gives you
|
|
236
|
+
sourceFiles:
|
|
237
|
+
- platform: react
|
|
238
|
+
file: packages/ui/src/components/dialog/Dialog.tsx
|
|
239
|
+
imports:
|
|
240
|
+
- platform: react
|
|
241
|
+
code: import { Dialog } from '@sanity/ui'
|
|
242
|
+
package: '@sanity/ui'
|
|
243
|
+
traits:
|
|
244
|
+
- traitType: state
|
|
245
|
+
kind: boolean
|
|
246
|
+
id: open
|
|
247
|
+
description: >-
|
|
248
|
+
Controls the dialog. True calls showModal() on the element; false calls
|
|
249
|
+
close(). Dialog stays mounted and is driven by this prop. Conditional
|
|
250
|
+
mounting works but skips the open and close transitions, so prefer the
|
|
251
|
+
prop.
|
|
252
|
+
- traitType: variant
|
|
253
|
+
kind: enum
|
|
254
|
+
id: size
|
|
255
|
+
description: >-
|
|
256
|
+
Maximum width of the dialog, drawn from the shared container scale. The
|
|
257
|
+
dialog's own width is calc(100dvw - 2rem), so it shrinks to fit narrow
|
|
258
|
+
viewports. Matches the surface to the content. A confirmation needs no
|
|
259
|
+
more than the default; a form needs room to breathe. Accepts a responsive
|
|
260
|
+
array.
|
|
261
|
+
values:
|
|
262
|
+
- id: '0'
|
|
263
|
+
description: >-
|
|
264
|
+
Width {container-0}. The default. Confirmations and short
|
|
265
|
+
destructive-action prompts.
|
|
266
|
+
- id: '1'
|
|
267
|
+
description: Width {container-1}. Short forms and content that needs a readable measure.
|
|
268
|
+
- id: '2'
|
|
269
|
+
description: Width {container-2}. Multi-column forms or content with a preview pane.
|
|
270
|
+
- id: '3'
|
|
271
|
+
description: Width {container-3}.
|
|
272
|
+
- id: '4'
|
|
273
|
+
description: Width {container-4}.
|
|
274
|
+
- id: '5'
|
|
275
|
+
description: Width {container-5}.
|
|
276
|
+
$extensions:
|
|
277
|
+
com.sanity.ui:
|
|
278
|
+
implementationStatus:
|
|
279
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
280
|
+
implemented: true
|
|
281
|
+
tracking: https://github.com/sanity-io/ui/pull/2720
|
|
282
|
+
migrationGuide:
|
|
283
|
+
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.'
|
|
284
|
+
guidance: |-
|
|
285
|
+
### Migrating from Sanity UI 3
|
|
286
|
+
|
|
287
|
+
Sanity UI 3 also had a Dialog, but it is not this component — it shares the name and almost nothing else. Automated migration via codemod isn't feasible; the two render in fundamentally different ways. Migrate manually, ideally assisted by an agentic workflow using this reference.
|
|
288
|
+
|
|
289
|
+
1. **Update the render signature**
|
|
290
|
+
|
|
291
|
+
The v3 Dialog renders using conditional mounting, a `footer` prop, and content passed directly to `children`:
|
|
292
|
+
|
|
293
|
+
```tsx
|
|
294
|
+
<Button onClick={() => setOpen(true)} text="Open dialog" />
|
|
295
|
+
{open && (
|
|
296
|
+
<Dialog footer={footerContent} {...dialogProps}>
|
|
297
|
+
{dialogContent}
|
|
298
|
+
</Dialog>
|
|
299
|
+
)}
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
The v5 Dialog renders using the `open` prop, with subcomponents for the content and the footer:
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
<Button onClick={() => setOpen(true)} text="Open dialog" />
|
|
306
|
+
<Dialog open={open} {...dialogProps}>
|
|
307
|
+
<Dialog.Content>{dialogContent}</Dialog.Content>
|
|
308
|
+
<Dialog.Footer>{footerContent}</Dialog.Footer>
|
|
309
|
+
</Dialog>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
2. **Reconcile every prop against the differences reference**
|
|
313
|
+
|
|
314
|
+
The two versions diverge on more than a dozen props — sizing, layering, refs, and lifecycle all changed. Check each prop your v3 usage passes against the differences below before shipping.
|
|
315
|
+
|
|
316
|
+
### v3 Dialog to v5 Dialog prop differences
|
|
317
|
+
|
|
318
|
+
| Prop | Change in v5 |
|
|
319
|
+
| :---- | :---- |
|
|
320
|
+
| `animate` | Removed. v5 always animates, unless the user prefers reduced motion. |
|
|
321
|
+
| `cardRadius` | Removed. v5's radius is fixed. |
|
|
322
|
+
| `cardShadow` | Removed. v5's shadow is fixed. |
|
|
323
|
+
| `children` | v3 puts children in a scrollable content Box. v5 puts children directly in the dialog element. |
|
|
324
|
+
| `className` | No behavior difference. v3 passes it through to the layer element; v5 merges it into the dialog element's className. |
|
|
325
|
+
| `contentRef` | Removed. v5 has no equivalent. |
|
|
326
|
+
| `footer` | Removed. v5 offers the Dialog.Footer subcomponent instead of a prop. |
|
|
327
|
+
| `header` | Narrowed. v3 accepts any React node; v5 accepts a string only. Both render the text in the header row. |
|
|
328
|
+
| `id` | No longer required. v3 needs id to build its aria-labelledby target; v5 generates that id internally with useId. Passing id doesn't affect this. |
|
|
329
|
+
| `onActivate` | Removed. Used for layer management in v3; v5 manages layering itself via the native dialog element. |
|
|
330
|
+
| `onClickOutside` | Removed. v5 sets closedby="any" on the dialog element. The browser then dismisses it on a backdrop click, firing onClose. Move any effect unrelated to closing into onClose instead. |
|
|
331
|
+
| `onClose` | Now required, and bound to the native close event instead of a custom handler. v3 calls it on Escape and the close button, and hides the close button when it's absent. v5 fires it for every close cause and passes the event object. |
|
|
332
|
+
| `open` | New. v3 has no open state — the developer mounts and unmounts it. v5 stays mounted; an effect calls showModal() or close() when open changes. |
|
|
333
|
+
| `padding` | Removed, along with paddingX, paddingY, paddingTop, paddingRight, paddingBottom, and paddingLeft. v5's padding is fixed — drop these props. |
|
|
334
|
+
| `portal` | Removed. v3 renders into a named portal; v5 renders in place, in the browser's top layer. |
|
|
335
|
+
| `position` | Removed. v5 uses the native top layer instead of a positioning prop. |
|
|
336
|
+
| `ref` | Not forwarded. v5 sets its own internal ref on the dialog element — drop this prop. |
|
|
337
|
+
| `scheme` | Removed. v5 has no equivalent. |
|
|
338
|
+
| `style` | No difference. Passed through on both. |
|
|
339
|
+
| `width` | Replaced by size. v5's size sets a max width from the shared container scale; the dialog's own width is calc(100dvw - 2rem). |
|
|
340
|
+
| `zOffset` | Removed. v5 uses the native top layer instead of a z-index prop. |
|
|
341
|
+
| `__unstable_autoFocus` | Removed. v5 relies on the native showModal() autofocus behavior. |
|
|
342
|
+
| `__unstable_hideCloseButton` | Removed. v5 always renders the close button. |
|
|
343
|
+
| `Other DOM props` | v3 extends div props. v5 extends native dialog element props, with open removed from the DOM props and redefined as a controlled prop. |
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: divider
|
|
3
|
+
name: Divider
|
|
4
|
+
description: Renders a horizontal rule to break up sections of content.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [divider, separator, rule, section, hr, break, group]
|
|
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 visually and semantically break up sections of content in a vertical layout.
|
|
17
|
+
- level: should
|
|
18
|
+
statement: Between groups of items in a list or menu where a clear boundary helps scanning.
|
|
19
|
+
- level: should
|
|
20
|
+
statement: To mark a thematic shift in content — for example, between a primary action group and a destructive action.
|
|
21
|
+
- level: should-not
|
|
22
|
+
statement: As a spacing tool. Use VStack gap prop for vertical spacing instead.
|
|
23
|
+
alternatives:
|
|
24
|
+
- to: v-stack
|
|
25
|
+
- level: should-not
|
|
26
|
+
statement: To add a border to the bottom of a container like a toolbar. Use borderBottom on Box instead.
|
|
27
|
+
alternatives:
|
|
28
|
+
- to: box
|
|
29
|
+
- level: should-not
|
|
30
|
+
statement: When the line is purely decorative. Use a CSS border on Box instead.
|
|
31
|
+
alternatives:
|
|
32
|
+
- to: box
|
|
33
|
+
- kind: guidelines
|
|
34
|
+
for: all
|
|
35
|
+
framing: how-to-use
|
|
36
|
+
items:
|
|
37
|
+
- level: should
|
|
38
|
+
statement: Place Divider between distinct content groups — it renders a semantic hr that screen readers announce as a thematic break.
|
|
39
|
+
- level: should
|
|
40
|
+
statement: Use Divider inside a VStack so spacing on either side is consistent.
|
|
41
|
+
- level: must-not
|
|
42
|
+
statement: "Don't use Divider at the top or bottom of a container (toolbars, nav headers) to create an edge border — use borderTop or borderBottom on Box instead."
|
|
43
|
+
- level: must-not
|
|
44
|
+
statement: Don't add multiple Dividers in a row — use VStack with a larger gap value instead.
|
|
45
|
+
- kind: guidelines
|
|
46
|
+
for: all
|
|
47
|
+
title: Content
|
|
48
|
+
description: Divider has no text content of its own. These guidelines cover the content around a Divider.
|
|
49
|
+
tags: [content]
|
|
50
|
+
items:
|
|
51
|
+
- level: should
|
|
52
|
+
statement: Place a Divider between groups of related content, not between every item. If each item needs spacing, use VStack `gap` instead.
|
|
53
|
+
- level: should
|
|
54
|
+
statement: A Divider signals that two sections are different. The content on each side should make that clear without relying on the line itself.
|
|
55
|
+
- level: should
|
|
56
|
+
statement: In long lists (nav, settings panels), use a heading or label above each group. This lets users find sections without reading every item. The Divider marks the boundary; the heading names it.
|
|
57
|
+
- level: should
|
|
58
|
+
statement: A label followed by a Divider followed by a field creates a false thematic break. Use VStack `gap={1}` to pair a label with its field.
|
|
59
|
+
|
|
60
|
+
- kind: guidelines
|
|
61
|
+
for: all
|
|
62
|
+
title: Accessibility
|
|
63
|
+
tags: [accessibility]
|
|
64
|
+
items:
|
|
65
|
+
- level: should
|
|
66
|
+
statement: Divider renders as `<hr>`, which carries the implicit ARIA role `separator`. Screen readers announce it as a thematic break. Use it only when the content on either side is distinct — not for visual spacing alone.
|
|
67
|
+
- id: divider-focusable-keyboard-interaction-add
|
|
68
|
+
level: should
|
|
69
|
+
statement: Divider is not focusable and has no keyboard interaction. Do not add `onClick` or other event handlers to it.
|
|
70
|
+
- level: should
|
|
71
|
+
statement: Unlike `<section>` or `<nav>`, `<hr>` does not create an ARIA landmark. Screen reader users who navigate by landmarks will not stop at a Divider. Use it for in-flow separation only, not as a navigation aid.
|
|
72
|
+
- level: must-not
|
|
73
|
+
statement: Do not override the `<hr>` role with `role="presentation"` or `aria-hidden="true"` unless the line is decorative. If it is decorative, use a CSS border or Box with `borderBottom` instead of Divider.
|
|
74
|
+
|
|
75
|
+
alternatives:
|
|
76
|
+
- to: box
|
|
77
|
+
refs:
|
|
78
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=31003-2
|
|
79
|
+
rel: design
|
|
80
|
+
role: Figma component (v5)
|
|
81
|
+
sourceFiles:
|
|
82
|
+
- platform: react
|
|
83
|
+
file: packages/ui/src/components/divider/Divider.tsx
|
|
84
|
+
imports:
|
|
85
|
+
- platform: react
|
|
86
|
+
code: import { Divider } from '@sanity/ui'
|
|
87
|
+
package: '@sanity/ui'
|
|
88
|
+
|
|
89
|
+
$extensions:
|
|
90
|
+
com.sanity.ui:
|
|
91
|
+
implementationStatus:
|
|
92
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
93
|
+
implemented: true
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: eyebrow
|
|
3
|
+
name: Eyebrow
|
|
4
|
+
description: Displays a small amount of text that contextualizes or categorizes a subject.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [typography, eyebrow, label, category, kicker, uppercase, 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: "A short category name or content type placed directly above a Heading (for example, 'Case study', 'New feature', 'Guide')."
|
|
17
|
+
- level: should
|
|
18
|
+
statement: Context for a group of titles in a list, so readers can tell what each title leads to.
|
|
19
|
+
- level: should-not
|
|
20
|
+
statement: To label a TextInput, Select or other input. Use a label element linked with htmlFor instead.
|
|
21
|
+
- level: should-not
|
|
22
|
+
statement: For body copy, descriptions, metadata, or long strings. Use Text instead.
|
|
23
|
+
alternatives:
|
|
24
|
+
- to: text
|
|
25
|
+
- level: should-not
|
|
26
|
+
statement: As a heading element, or to title a group of navigation links. Use Heading instead.
|
|
27
|
+
alternatives:
|
|
28
|
+
- to: heading
|
|
29
|
+
- id: status-state-published-draft-beta
|
|
30
|
+
level: should-not
|
|
31
|
+
statement: For a status or state (Published, Draft, Beta). Use Badge instead — Eyebrow carries no state semantics.
|
|
32
|
+
alternatives:
|
|
33
|
+
- to: badge
|
|
34
|
+
- kind: guidelines
|
|
35
|
+
for: all
|
|
36
|
+
framing: how-to-use
|
|
37
|
+
items:
|
|
38
|
+
- id: eyebrow-no-manual-uppercase
|
|
39
|
+
level: must
|
|
40
|
+
statement: Pass eyebrow text as written, with no text-transform override and no all-caps string literal — the component applies the uppercase treatment and letter-spacing itself.
|
|
41
|
+
example:
|
|
42
|
+
title: How to satisfy this
|
|
43
|
+
description: Read the source string and confirm it is not typed in all caps. Confirm no style or className sets text-transform on the Eyebrow.
|
|
44
|
+
checkedBy: manual
|
|
45
|
+
- id: eyebrow-paired-with-heading
|
|
46
|
+
level: should
|
|
47
|
+
statement: Place each Eyebrow directly above the Heading it categorizes, inside a shared stack with a small gap (gap={1} or gap={2} in a VStack).
|
|
48
|
+
example:
|
|
49
|
+
title: How to satisfy this
|
|
50
|
+
description: Confirm the Eyebrow and its Heading share a VStack parent with a small gap. Confirm the Eyebrow is not used on its own without an adjacent Heading.
|
|
51
|
+
checkedBy: manual
|
|
52
|
+
- level: should
|
|
53
|
+
statement: Keep Eyebrow text to one to three words, with no trailing punctuation.
|
|
54
|
+
- level: must-not
|
|
55
|
+
statement: 'Using Eyebrow as the label in a form field. Instead: Use a label element linked to the input with htmlFor.'
|
|
56
|
+
alternatives:
|
|
57
|
+
- to: text
|
|
58
|
+
note: Set as='label' and link it with htmlFor.
|
|
59
|
+
- kind: guidelines
|
|
60
|
+
for: agent
|
|
61
|
+
framing: how-to-use
|
|
62
|
+
items:
|
|
63
|
+
- level: must
|
|
64
|
+
statement: weight and tone take a single value. Only size, align, truncate, and the margin props accept responsive arrays.
|
|
65
|
+
- level: must-not
|
|
66
|
+
statement: Do not use Eyebrow without an adjacent Heading — its purpose is to introduce one.
|
|
67
|
+
- kind: guidelines
|
|
68
|
+
for: all
|
|
69
|
+
title: Content
|
|
70
|
+
tags: [content]
|
|
71
|
+
items:
|
|
72
|
+
- refs:
|
|
73
|
+
- to: content-guidelines#sentence-case-all-system-set
|
|
74
|
+
rel: same-as
|
|
75
|
+
- level: should
|
|
76
|
+
statement: Keep to a single word or short phrase. "Case study," not "This is a case study about our redesign process."
|
|
77
|
+
|
|
78
|
+
- kind: guidelines
|
|
79
|
+
for: all
|
|
80
|
+
title: Accessibility
|
|
81
|
+
tags: [accessibility]
|
|
82
|
+
items:
|
|
83
|
+
- level: must
|
|
84
|
+
statement: Eyebrow text must maintain 4.5:1 contrast against the background for standard text and 3:1 for large text (WCAG 1.4.3 AA). Check contrast again with `muted` set, since it lowers the color level.
|
|
85
|
+
- level: should
|
|
86
|
+
statement: Eyebrow defaults to `<span>`, an inline, non-semantic element. Use `as="p"` if the eyebrow needs to read as its own block-level text node.
|
|
87
|
+
- level: should
|
|
88
|
+
statement: An eyebrow is visually distinct but carries no heading semantics of its own — it does not create a new heading level or landmark. Don't rely on it to convey document structure; the Heading it precedes still needs the correct `as` level.
|
|
89
|
+
- id: eyebrow-tone-needs-second-channel
|
|
90
|
+
level: must-not
|
|
91
|
+
statement: Do not use `tone` alone to convey a category's meaning — pair it with an icon or make sure the same meaning is stated in the adjacent heading or body text.
|
|
92
|
+
|
|
93
|
+
refines:
|
|
94
|
+
- to: shared-foundations#tone-paired-with-second-channel
|
|
95
|
+
alternatives:
|
|
96
|
+
- to: text
|
|
97
|
+
note: Body copy, descriptions, and metadata
|
|
98
|
+
- to: badge
|
|
99
|
+
note: Inline status labels with semantic tone
|
|
100
|
+
- to: heading
|
|
101
|
+
note: The semantic heading Eyebrow introduces
|
|
102
|
+
sourceFiles:
|
|
103
|
+
- platform: react
|
|
104
|
+
file: packages/ui/src/components/eyebrow/Eyebrow.tsx
|
|
105
|
+
imports:
|
|
106
|
+
- platform: react
|
|
107
|
+
code: import { Eyebrow } from '@sanity/ui'
|
|
108
|
+
package: '@sanity/ui'
|
|
109
|
+
traits:
|
|
110
|
+
- traitType: variant
|
|
111
|
+
kind: enum
|
|
112
|
+
id: size
|
|
113
|
+
description: Font size drawn from the label type tokens.
|
|
114
|
+
values:
|
|
115
|
+
- id: '0'
|
|
116
|
+
description: Smallest. Dense list contexts where each item has its own eyebrow.
|
|
117
|
+
- id: '1'
|
|
118
|
+
description: Small. Compact card headers.
|
|
119
|
+
- id: '2'
|
|
120
|
+
description: Standard (default). Above a section or page heading.
|
|
121
|
+
- id: '3'
|
|
122
|
+
description: Large. Above a prominent, large-size Heading.
|
|
123
|
+
- id: '4'
|
|
124
|
+
description: Extra large. Rare — hero sections with a large Heading below.
|
|
125
|
+
- traitType: variant
|
|
126
|
+
kind: enum
|
|
127
|
+
id: weight
|
|
128
|
+
description: Font weight.
|
|
129
|
+
values:
|
|
130
|
+
- id: regular
|
|
131
|
+
description: Rare. A deliberately quieter eyebrow next to a heavy heading.
|
|
132
|
+
- id: medium
|
|
133
|
+
description: A softer alternative to the default.
|
|
134
|
+
- id: semibold
|
|
135
|
+
description: Standard weight (default). Reads as a label at a glance.
|
|
136
|
+
- id: bold
|
|
137
|
+
description: Rare. Extra emphasis when the eyebrow must compete with its heading.
|
|
138
|
+
- traitType: variant
|
|
139
|
+
kind: enum
|
|
140
|
+
id: tone
|
|
141
|
+
description: Semantic text color.
|
|
142
|
+
values:
|
|
143
|
+
- id: neutral
|
|
144
|
+
description: Default. No semantic meaning.
|
|
145
|
+
- id: suggest
|
|
146
|
+
description: Suggested or recommended content.
|
|
147
|
+
- id: positive
|
|
148
|
+
description: Healthy, successful, or completed content.
|
|
149
|
+
- id: caution
|
|
150
|
+
description: Content that needs attention.
|
|
151
|
+
- id: critical
|
|
152
|
+
description: Deprecated, failing, or blocking content.
|
|
153
|
+
- traitType: variant
|
|
154
|
+
kind: boolean
|
|
155
|
+
id: muted
|
|
156
|
+
description: Reduces visual prominence. Applies the muted variant of the current tone when tone is also set.
|
|
157
|
+
- traitType: variant
|
|
158
|
+
kind: boolean
|
|
159
|
+
id: trim
|
|
160
|
+
description: Removes extra whitespace above and below the text box for precise alignment with an adjacent Heading.
|
|
161
|
+
$extensions:
|
|
162
|
+
com.sanity.ui:
|
|
163
|
+
implementationStatus:
|
|
164
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
165
|
+
implemented: true
|
|
166
|
+
migrationGuide:
|
|
167
|
+
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.'
|
|
168
|
+
codemod: |-
|
|
169
|
+
Eyebrow replaces v3's small, uppercase text component used above headings. Form field labels are a different role: use a label element linked with htmlFor, not Eyebrow.
|
|
170
|
+
|
|
171
|
+
`accent` is remapped to `tone="suggest"`. `textOverflow` is replaced by `truncate` — both `"ellipsis"` and `"clip"` map to `truncate={1}`. `flex`, `width`, and `maxWidth` are removed; the codemod converts them to an inline `style` object. The codemod also adds `as="div"` and `trim` so migrated markup keeps v3's block-level behavior and vertical spacing.
|
|
172
|
+
|
|
173
|
+
Run the codemod: `pnpx @sanity/ui-codemod latest:label --paths <paths> --toPackage @sanity/ui`.
|
|
174
|
+
guidance: |-
|
|
175
|
+
Eyebrow replaces v3's small, uppercase, all-caps text component used above headings and section titles. Form field labels are a different role: use a label element linked with htmlFor, not Eyebrow.
|
|
176
|
+
|
|
177
|
+
### Key differences
|
|
178
|
+
|
|
179
|
+
- v5 components use CSS classes with a static stylesheet instead of `styled-components`.
|
|
180
|
+
- The v3 component rendered a `<div>` by default. `Eyebrow` renders `<span>`. The codemod adds `as="div"` explicitly. This keeps migrated instances' original layout behavior.
|
|
181
|
+
- `accent` replaced by `tone`. v3's `accent` was a boolean; `tone` takes a full semantic value. The codemod maps `accent` to `tone="suggest"`.
|
|
182
|
+
- `textOverflow="ellipsis"` replaced by `truncate={1}`. v3's `textOverflow` only supported single-line truncation; `truncate` also accepts values above `1` for multi-line clamping.
|
|
183
|
+
- `flex`, `width`, and `maxWidth` removed. The v3 component accepted these as scale-based layout props. `Eyebrow` accepts none of them — wrap it in `Box` for layout control instead.
|
|
184
|
+
- `trim` added. The codemod sets `trim={true}` on every migrated instance to preserve v3's vertical spacing.
|
|
185
|
+
- Margin props added. `Eyebrow` now accepts `margin`, `marginX`, `marginY`, and per-side margin props.
|
|
186
|
+
|
|
187
|
+
### Detailed list of differences
|
|
188
|
+
|
|
189
|
+
| v3 prop | v5 prop (`Eyebrow`) | Notes |
|
|
190
|
+
| :---- | :---- | :---- |
|
|
191
|
+
| `accent={true}` | `tone="suggest"` | Renamed and remapped. `accent` was boolean; `tone` takes a semantic value. |
|
|
192
|
+
| `textOverflow="ellipsis"` | `truncate={1}` | Renamed and remapped. `textOverflow="clip"` also maps to `truncate={1}`. |
|
|
193
|
+
| `flex` | — | Removed. Wrap in `Box` and set `flex`/`flexGrow` there. |
|
|
194
|
+
| `width` | — | Removed. Wrap in `Box` and set `width` there. |
|
|
195
|
+
| `maxWidth` | — | Removed. Wrap in `Box` and set `maxWidth` there. |
|
|
196
|
+
| — (default `as="div"`) | `as="div"` | The codemod sets this explicitly, since `Eyebrow` defaults to `"span"`. |
|
|
197
|
+
| — | `trim` | The codemod sets `trim={true}` to match v3's vertical spacing. |
|
|
198
|
+
| — | `margin*` | New. `Eyebrow` accepts margin props directly. |
|
|
199
|
+
| `align`, `muted`, `size`, `weight` | Same | Carry over unchanged. |
|
|
200
|
+
|
|
201
|
+
### Breaking changes
|
|
202
|
+
|
|
203
|
+
- `accent` prop removed. The v3 component's accent has no `Eyebrow` boolean equivalent — use `tone="suggest"`.
|
|
204
|
+
- `textOverflow` prop removed. The v3 `textOverflow="ellipsis"` does nothing on `Eyebrow`. Use `<Eyebrow truncate={1}>`.
|
|
205
|
+
- `flex`, `width`, and `maxWidth` props removed. `Eyebrow` accepts no layout props — move them to a wrapping `Box`.
|
|
206
|
+
- `styled-components` no longer used. Custom styled-components extensions of the v3 component will not work on `Eyebrow`.
|
|
207
|
+
- The default rendered element changes from `<div>` to `<span>` unless `as="div"` is set explicitly.
|
|
208
|
+
|
|
209
|
+
### Codemod
|
|
210
|
+
|
|
211
|
+
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.
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
pnpx @sanity/ui-codemod latest:label --paths <paths> --toPackage @sanity/ui
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The codemod renames the element to `Eyebrow`, remaps `accent` and `textOverflow`, and converts `flex`/`width`/`maxWidth` to an inline `style` object. It also adds `as="div"` and `trim={true}` to every migrated instance. This keeps existing layouts at their original spacing and block-level behavior. If a component instance cannot be migrated automatically or needs manual review, the codemod inserts a comment prefixed with "UI-POC-CODEMOD TODO."
|