@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,316 @@
|
|
|
1
|
+
schemaVersion: '0.23.1'
|
|
2
|
+
name: Sanity UI
|
|
3
|
+
entries:
|
|
4
|
+
- kind: token
|
|
5
|
+
id: body-0
|
|
6
|
+
name: body-0
|
|
7
|
+
description: Fine print in dense contexts.
|
|
8
|
+
metadata:
|
|
9
|
+
status:
|
|
10
|
+
status: stable
|
|
11
|
+
group: typography
|
|
12
|
+
tokenType: typography
|
|
13
|
+
source:
|
|
14
|
+
href: ./dtcg/json/typography.tokens.json#body-0
|
|
15
|
+
- kind: token
|
|
16
|
+
id: body-1
|
|
17
|
+
name: body-1
|
|
18
|
+
description: Compact body and secondary text.
|
|
19
|
+
metadata:
|
|
20
|
+
status:
|
|
21
|
+
status: stable
|
|
22
|
+
group: typography
|
|
23
|
+
tokenType: typography
|
|
24
|
+
source:
|
|
25
|
+
href: ./dtcg/json/typography.tokens.json#body-1
|
|
26
|
+
- kind: token
|
|
27
|
+
id: body-2
|
|
28
|
+
name: body-2
|
|
29
|
+
description: Default body copy.
|
|
30
|
+
metadata:
|
|
31
|
+
status:
|
|
32
|
+
status: stable
|
|
33
|
+
group: typography
|
|
34
|
+
tokenType: typography
|
|
35
|
+
source:
|
|
36
|
+
href: ./dtcg/json/typography.tokens.json#body-2
|
|
37
|
+
- kind: token
|
|
38
|
+
id: body-3
|
|
39
|
+
name: body-3
|
|
40
|
+
description: Display body — intros and lead paragraphs.
|
|
41
|
+
metadata:
|
|
42
|
+
status:
|
|
43
|
+
status: stable
|
|
44
|
+
group: typography
|
|
45
|
+
tokenType: typography
|
|
46
|
+
source:
|
|
47
|
+
href: ./dtcg/json/typography.tokens.json#body-3
|
|
48
|
+
- kind: token
|
|
49
|
+
id: body-4
|
|
50
|
+
name: body-4
|
|
51
|
+
description: Display body — hero and empty-state text.
|
|
52
|
+
metadata:
|
|
53
|
+
status:
|
|
54
|
+
status: stable
|
|
55
|
+
group: typography
|
|
56
|
+
tokenType: typography
|
|
57
|
+
source:
|
|
58
|
+
href: ./dtcg/json/typography.tokens.json#body-4
|
|
59
|
+
- kind: token
|
|
60
|
+
id: code-0
|
|
61
|
+
name: code-0
|
|
62
|
+
description: Fine inline code.
|
|
63
|
+
metadata:
|
|
64
|
+
status:
|
|
65
|
+
status: stable
|
|
66
|
+
group: typography
|
|
67
|
+
tokenType: typography
|
|
68
|
+
source:
|
|
69
|
+
href: ./dtcg/json/typography.tokens.json#code-0
|
|
70
|
+
- kind: token
|
|
71
|
+
id: code-1
|
|
72
|
+
name: code-1
|
|
73
|
+
description: Compact code and identifiers.
|
|
74
|
+
metadata:
|
|
75
|
+
status:
|
|
76
|
+
status: stable
|
|
77
|
+
group: typography
|
|
78
|
+
tokenType: typography
|
|
79
|
+
source:
|
|
80
|
+
href: ./dtcg/json/typography.tokens.json#code-1
|
|
81
|
+
- kind: token
|
|
82
|
+
id: code-2
|
|
83
|
+
name: code-2
|
|
84
|
+
description: Default code blocks and inline tokens.
|
|
85
|
+
metadata:
|
|
86
|
+
status:
|
|
87
|
+
status: stable
|
|
88
|
+
group: typography
|
|
89
|
+
tokenType: typography
|
|
90
|
+
source:
|
|
91
|
+
href: ./dtcg/json/typography.tokens.json#code-2
|
|
92
|
+
- kind: token
|
|
93
|
+
id: code-3
|
|
94
|
+
name: code-3
|
|
95
|
+
description: Display code.
|
|
96
|
+
metadata:
|
|
97
|
+
status:
|
|
98
|
+
status: stable
|
|
99
|
+
group: typography
|
|
100
|
+
tokenType: typography
|
|
101
|
+
source:
|
|
102
|
+
href: ./dtcg/json/typography.tokens.json#code-3
|
|
103
|
+
- kind: token
|
|
104
|
+
id: code-4
|
|
105
|
+
name: code-4
|
|
106
|
+
description: Display code.
|
|
107
|
+
metadata:
|
|
108
|
+
status:
|
|
109
|
+
status: stable
|
|
110
|
+
group: typography
|
|
111
|
+
tokenType: typography
|
|
112
|
+
source:
|
|
113
|
+
href: ./dtcg/json/typography.tokens.json#code-4
|
|
114
|
+
- kind: token
|
|
115
|
+
id: heading-0
|
|
116
|
+
name: heading-0
|
|
117
|
+
description: UI chrome — toolbars, sidebars, dense panels.
|
|
118
|
+
metadata:
|
|
119
|
+
status:
|
|
120
|
+
status: stable
|
|
121
|
+
group: typography
|
|
122
|
+
tokenType: typography
|
|
123
|
+
source:
|
|
124
|
+
href: ./dtcg/json/typography.tokens.json#heading-0
|
|
125
|
+
- kind: token
|
|
126
|
+
id: heading-1
|
|
127
|
+
name: heading-1
|
|
128
|
+
description: Sub-section titles.
|
|
129
|
+
metadata:
|
|
130
|
+
status:
|
|
131
|
+
status: stable
|
|
132
|
+
group: typography
|
|
133
|
+
tokenType: typography
|
|
134
|
+
source:
|
|
135
|
+
href: ./dtcg/json/typography.tokens.json#heading-1
|
|
136
|
+
- kind: token
|
|
137
|
+
id: heading-2
|
|
138
|
+
name: heading-2
|
|
139
|
+
description: Standard section headings. The default.
|
|
140
|
+
metadata:
|
|
141
|
+
status:
|
|
142
|
+
status: stable
|
|
143
|
+
group: typography
|
|
144
|
+
tokenType: typography
|
|
145
|
+
source:
|
|
146
|
+
href: ./dtcg/json/typography.tokens.json#heading-2
|
|
147
|
+
- kind: token
|
|
148
|
+
id: heading-3
|
|
149
|
+
name: heading-3
|
|
150
|
+
description: Document titles in high-density layouts.
|
|
151
|
+
metadata:
|
|
152
|
+
status:
|
|
153
|
+
status: stable
|
|
154
|
+
group: typography
|
|
155
|
+
tokenType: typography
|
|
156
|
+
source:
|
|
157
|
+
href: ./dtcg/json/typography.tokens.json#heading-3
|
|
158
|
+
- kind: token
|
|
159
|
+
id: heading-4
|
|
160
|
+
name: heading-4
|
|
161
|
+
description: Document titles in medium-density layouts.
|
|
162
|
+
metadata:
|
|
163
|
+
status:
|
|
164
|
+
status: stable
|
|
165
|
+
group: typography
|
|
166
|
+
tokenType: typography
|
|
167
|
+
source:
|
|
168
|
+
href: ./dtcg/json/typography.tokens.json#heading-4
|
|
169
|
+
- kind: token
|
|
170
|
+
id: heading-5
|
|
171
|
+
name: heading-5
|
|
172
|
+
description: Document titles in low-density layouts.
|
|
173
|
+
metadata:
|
|
174
|
+
status:
|
|
175
|
+
status: stable
|
|
176
|
+
group: typography
|
|
177
|
+
tokenType: typography
|
|
178
|
+
source:
|
|
179
|
+
href: ./dtcg/json/typography.tokens.json#heading-5
|
|
180
|
+
- kind: token
|
|
181
|
+
id: label-0
|
|
182
|
+
name: label-0
|
|
183
|
+
description: Fine print labels.
|
|
184
|
+
metadata:
|
|
185
|
+
status:
|
|
186
|
+
status: stable
|
|
187
|
+
group: typography
|
|
188
|
+
tokenType: typography
|
|
189
|
+
source:
|
|
190
|
+
href: ./dtcg/json/typography.tokens.json#label-0
|
|
191
|
+
- kind: token
|
|
192
|
+
id: label-1
|
|
193
|
+
name: label-1
|
|
194
|
+
description: Compact form and UI labels.
|
|
195
|
+
metadata:
|
|
196
|
+
status:
|
|
197
|
+
status: stable
|
|
198
|
+
group: typography
|
|
199
|
+
tokenType: typography
|
|
200
|
+
source:
|
|
201
|
+
href: ./dtcg/json/typography.tokens.json#label-1
|
|
202
|
+
- kind: token
|
|
203
|
+
id: label-2
|
|
204
|
+
name: label-2
|
|
205
|
+
description: Small labels.
|
|
206
|
+
metadata:
|
|
207
|
+
status:
|
|
208
|
+
status: stable
|
|
209
|
+
group: typography
|
|
210
|
+
tokenType: typography
|
|
211
|
+
source:
|
|
212
|
+
href: ./dtcg/json/typography.tokens.json#label-2
|
|
213
|
+
- kind: token
|
|
214
|
+
id: label-3
|
|
215
|
+
name: label-3
|
|
216
|
+
description: Standard labels.
|
|
217
|
+
metadata:
|
|
218
|
+
status:
|
|
219
|
+
status: stable
|
|
220
|
+
group: typography
|
|
221
|
+
tokenType: typography
|
|
222
|
+
source:
|
|
223
|
+
href: ./dtcg/json/typography.tokens.json#label-3
|
|
224
|
+
- kind: token
|
|
225
|
+
id: label-4
|
|
226
|
+
name: label-4
|
|
227
|
+
description: Larger labels.
|
|
228
|
+
metadata:
|
|
229
|
+
status:
|
|
230
|
+
status: stable
|
|
231
|
+
group: typography
|
|
232
|
+
tokenType: typography
|
|
233
|
+
source:
|
|
234
|
+
href: ./dtcg/json/typography.tokens.json#label-4
|
|
235
|
+
- kind: token
|
|
236
|
+
id: label-5
|
|
237
|
+
name: label-5
|
|
238
|
+
description: Largest labels.
|
|
239
|
+
metadata:
|
|
240
|
+
status:
|
|
241
|
+
status: stable
|
|
242
|
+
group: typography
|
|
243
|
+
tokenType: typography
|
|
244
|
+
source:
|
|
245
|
+
href: ./dtcg/json/typography.tokens.json#label-5
|
|
246
|
+
- kind: entry
|
|
247
|
+
id: typography
|
|
248
|
+
name: Typography styles
|
|
249
|
+
description: Composite text styles for body, code, heading, and label roles, each binding a family, size, weight, and line height.
|
|
250
|
+
metadata:
|
|
251
|
+
tags: [typography, type, text, heading, label, code, scale, line-height]
|
|
252
|
+
status:
|
|
253
|
+
status: stable
|
|
254
|
+
group: typography
|
|
255
|
+
sections:
|
|
256
|
+
- kind: guidelines
|
|
257
|
+
for: all
|
|
258
|
+
framing: how-to-use
|
|
259
|
+
items:
|
|
260
|
+
- refs:
|
|
261
|
+
- to: semantics#heading-level-from-outline
|
|
262
|
+
rel: same-as
|
|
263
|
+
- level: should
|
|
264
|
+
statement: Use the fewest roles a layout needs — three or four. Lean on weight and space before adding a size.
|
|
265
|
+
- level: should
|
|
266
|
+
statement: Constrain body measure to roughly 45–75 characters per line.
|
|
267
|
+
- level: should-not
|
|
268
|
+
statement: Don't use display steps (`body`/`code` `3`–`4`) for product chrome. They are for hero and empty-state text.
|
|
269
|
+
- kind: guidelines
|
|
270
|
+
for: agent
|
|
271
|
+
framing: how-to-use
|
|
272
|
+
items:
|
|
273
|
+
- level: must
|
|
274
|
+
statement: The `size` prop takes an integer step, not a px value. Weight comes from the `weight` prop, not the size token.
|
|
275
|
+
- kind: section
|
|
276
|
+
for: all
|
|
277
|
+
freeform:
|
|
278
|
+
- title: Overview
|
|
279
|
+
body: |-
|
|
280
|
+
Each typography token bundles a font family, size, weight, and line height into one style. The set covers four roles: `body`, `code`, `heading`, and `label`. Every token carries the regular weight; the rendered weight comes from the component's `weight` prop (see Font weights).
|
|
281
|
+
- title: Roles and components
|
|
282
|
+
body: |-
|
|
283
|
+
| Token role | Component | Family | Default size |
|
|
284
|
+
| --- | --- | --- | --- |
|
|
285
|
+
| `body` | Text | `sans` | `2` |
|
|
286
|
+
| `code` | Code | `mono` | `2` |
|
|
287
|
+
| `heading` | Heading | `sans` | `2` |
|
|
288
|
+
| `label` | Eyebrow | `sans` | — |
|
|
289
|
+
|
|
290
|
+
`heading` runs `0`–`5`, and Heading's `size` accepts all six steps. `body` and `code` run `0`–`4`. `label` runs `0`–`5`, and Eyebrow's `size` uses steps `0`–`4`. The `label` role belongs to Eyebrow.
|
|
291
|
+
- title: Sizes
|
|
292
|
+
body: |-
|
|
293
|
+
Each step is one token, named by role and step: `body-2`, `heading-4`, `label-1`. The size, line height and letter spacing of each live in `docs/tokens/dtcg/json/typography.tokens.json`. Read a role, such as `heading`, to see a whole ramp. Larger heading steps carry negative letter spacing.
|
|
294
|
+
|
|
295
|
+
| Role | Steps | Tokens |
|
|
296
|
+
| --- | --- | --- |
|
|
297
|
+
| `body` | `0`–`4` | `body-0` … `body-4` |
|
|
298
|
+
| `code` | `0`–`4` | `code-0` … `code-4` |
|
|
299
|
+
| `heading` | `0`–`5` | `heading-0` … `heading-5` |
|
|
300
|
+
| `label` | `0`–`5` | `label-0` … `label-5` |
|
|
301
|
+
|
|
302
|
+
Run large steps (`heading` `4`–`5`, `body`/`code` `3`–`4`) tighter where needed.
|
|
303
|
+
- title: Related
|
|
304
|
+
body: |-
|
|
305
|
+
- **Typography guidelines** — hierarchy table, measure (45–75 characters), alignment, and weight.
|
|
306
|
+
- **Font families** and **Font weights** — the family and weight a style binds.
|
|
307
|
+
- **Spacing** — the spacing scale and vertical rhythm.
|
|
308
|
+
- kind: section
|
|
309
|
+
for: agent
|
|
310
|
+
freeform:
|
|
311
|
+
- title: Intent
|
|
312
|
+
body: Choose a type style by role (Text, Code, Heading, Eyebrow) and step. Use the fewest roles a layout needs.
|
|
313
|
+
refs:
|
|
314
|
+
- href: ./dtcg/json/typography.tokens.json
|
|
315
|
+
rel: source
|
|
316
|
+
role: DTCG source
|
package/llms.txt
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Sanity UI 5
|
|
2
|
+
|
|
3
|
+
> Sanity UI 5 is a React component library. This file lists the documentation shipped in this package. Read the documents under `docs/` before you write code. Read the skills under `skills/` for the build workflow.
|
|
4
|
+
|
|
5
|
+
The schema is DSDS, the Design System Documentation Spec, version 0.23.1. `docs/index.dsds.yaml` names it in its `$schema` and `schemaVersion` fields.
|
|
6
|
+
Each document is a DSDS file, written as YAML. Its `guidelines` carry a level: `must`, `should`, `may`, `should-not`, or `must-not`. Its `$extensions` hold migration notes from v3.
|
|
7
|
+
|
|
8
|
+
## Start here
|
|
9
|
+
|
|
10
|
+
- [Installation](docs/overview/installation.dsds.yaml): Everything needed to set up a React project for Sanity UI 5 — install, project files, TypeScript configuration and the entry file. The one place setup is documented.
|
|
11
|
+
- [API essentials](docs/overview/api-essentials.dsds.yaml): Cross-cutting rules for writing Sanity UI 5. Covers prop value types, prop ownership, and import shapes.
|
|
12
|
+
- [Component reference](docs/overview/component-reference.dsds.yaml): The index of what to build with — every documented Sanity UI component, grouped by taxonomy category, with its status in Sanity UI 5 (stable, beta or unavailable).
|
|
13
|
+
- [Quick start](docs/overview/quick-start.dsds.yaml): A step-by-step tutorial for building a three-region admin interface with Sanity UI, covering layout, accessibility, and key component patterns.
|
|
14
|
+
- [Sanity Design System's design contribution model](docs/overview/designer-contribution-model.dsds.yaml): How designers propose and graduate a recipe into the core Sanity Design System through a three-step, low-process contribution model.
|
|
15
|
+
- [Developer contribution model](docs/overview/developer-contribution-model.dsds.yaml): How a developer moves a working recipe into a pull request against @sanity/ui, and what that PR must include: branch naming, PR description, code formatting, Storybook stories, prop documentation, tests, and docs.
|
|
16
|
+
- [Resources](docs/overview/resources.dsds.yaml): Links to Sanity UI's project tracking, code repositories, package registry, and Figma libraries.
|
|
17
|
+
|
|
18
|
+
## Components
|
|
19
|
+
|
|
20
|
+
- [AvatarCounter](docs/components/avatar-counter.dsds.yaml): A counter to display the number of people or agents in a group.
|
|
21
|
+
- [AvatarStack](docs/components/avatar-stack.dsds.yaml): A visual representation of multiple people and/or agents. When there are more children than maxLength, it shows the rest as a count.
|
|
22
|
+
- [Avatar](docs/components/avatar.dsds.yaml): A visual representation of a person or agent.
|
|
23
|
+
- [Badge](docs/components/badge.dsds.yaml): A label used to communicate status, category, count, or other metadata inline.
|
|
24
|
+
- [Box](docs/components/box.dsds.yaml): The lowest-level building block for containing UI elements. Provides spacing, borders, shadows, and semantic tone without adding flex or grid layout behavior.
|
|
25
|
+
- [Button](docs/components/button.dsds.yaml): Used to trigger an action — like submitting a form, starting a dialog, or running a command.
|
|
26
|
+
- [Card](docs/components/card.dsds.yaml): Groups related content into a single visual element.
|
|
27
|
+
- [Checkbox](docs/components/checkbox.dsds.yaml): Enables the selection of an item or option.
|
|
28
|
+
- [Code](docs/components/code.dsds.yaml): Used for inline code snippets and multi-line code blocks.
|
|
29
|
+
- [Container](docs/components/container.dsds.yaml): A wrapper to constrain content to a maximum width and horizontally center it.
|
|
30
|
+
- [Dialog](docs/components/dialog.dsds.yaml): 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.
|
|
31
|
+
- [Divider](docs/components/divider.dsds.yaml): Renders a horizontal rule to break up sections of content.
|
|
32
|
+
- [Eyebrow](docs/components/eyebrow.dsds.yaml): Displays a small amount of text that contextualizes or categorizes a subject.
|
|
33
|
+
- [Flex](docs/components/flex.dsds.yaml): The lowest-level building block for laying out UI elements along a single axis.
|
|
34
|
+
- [Grid](docs/components/grid.dsds.yaml): Renders a CSS grid layout container. Supports named props for all CSS grid properties with responsive arrays.
|
|
35
|
+
- [HStack](docs/components/h-stack.dsds.yaml): HStack provides an opinionated horizontal layout with uniform gaps for simple use cases.
|
|
36
|
+
- [Heading](docs/components/heading.dsds.yaml): Displays heading text to create logical hierarchy and page structure.
|
|
37
|
+
- [Hotkeys](docs/components/hotkeys.dsds.yaml): Presents multi-key keyboard shortcuts.
|
|
38
|
+
- [IconButton](docs/components/icon-button.dsds.yaml): Triggers an action using an icon as the primary communicator.
|
|
39
|
+
- [Icon](docs/components/icon.dsds.yaml): Renders a sizable and tonable SVG icon from @sanity/icons.
|
|
40
|
+
- [IndicatorStack](docs/components/indicator-stack.dsds.yaml): A horizontal container for Indicator dots.
|
|
41
|
+
- [Indicator](docs/components/indicator.dsds.yaml): A small colored dot that shows status at a glance.
|
|
42
|
+
- [Inline](docs/components/inline.dsds.yaml): Deprecated. Use HStack instead. Previously laid out children in a wrapping inline row. Maintained for backward compatibility only.
|
|
43
|
+
- [KBD](docs/components/kbd.dsds.yaml): Presents a single keyboard shortcut.
|
|
44
|
+
- [Link](docs/components/link.dsds.yaml): Acts as a navigational element to move across pages.
|
|
45
|
+
- [List.ButtonItem](docs/components/list-button-item.dsds.yaml): The interactive, selectable variant of List.Item.
|
|
46
|
+
- [List.ItemImage](docs/components/list-item-image.dsds.yaml): A thumbnail image slot inside a List.Item.
|
|
47
|
+
- [List.ItemText](docs/components/list-item-text.dsds.yaml): The text content slot inside a List.Item.
|
|
48
|
+
- [List.Item](docs/components/list-item.dsds.yaml): A single row inside a List.
|
|
49
|
+
- [List](docs/components/list.dsds.yaml): A compound component for displaying structured rows.
|
|
50
|
+
- [Popover](docs/components/popover.dsds.yaml): A floating layer to disclose secondary, contextually relevant content or actions.
|
|
51
|
+
- [PressArea](docs/components/press-area.dsds.yaml): PressArea wraps a non-interactive element (Card, Box, Avatar) into an interactive target.
|
|
52
|
+
- [Radio](docs/components/radio.dsds.yaml): Enables the selection from a small set of options (2–4).
|
|
53
|
+
- [Select](docs/components/select.dsds.yaml): Allows the user to choose one option from medium-size set (5-20) within a dropdown list.
|
|
54
|
+
- [SkipToContent](docs/components/skip-to-content.dsds.yaml): An accessibility helper that lets keyboard and screen-reader users skip past navigation to the main content.
|
|
55
|
+
- [Spinner](docs/components/spinner.dsds.yaml): Displays a loading/processing indicator.
|
|
56
|
+
- [Switch](docs/components/switch.dsds.yaml): A toggle control for binary on/off settings that take immediate effect.
|
|
57
|
+
- [Tabs.Tab](docs/components/tab.dsds.yaml): A button that selects one Tabs.Panel. Use it inside Tabs.List.
|
|
58
|
+
- [Tabs.List](docs/components/tabs-list.dsds.yaml): The row that holds the Tabs.Tab buttons. It renders with role="tablist", lays its tabs out in a row, and moves focus between them with the arrow keys.
|
|
59
|
+
- [Tabs.Panel](docs/components/tabs-panel.dsds.yaml): The content for one tab. It shows when its value matches the selected Tabs value, and stays hidden otherwise.
|
|
60
|
+
- [Tabs](docs/components/tabs.dsds.yaml): A family of components that switch between separate but related content sections. Tabs has three parts, each with its own entry: Tabs.List, Tabs.Tab and Tabs.Panel.
|
|
61
|
+
- [TextArea](docs/components/text-area.dsds.yaml): A multi-line text field for longer freeform text, like descriptions and comments.
|
|
62
|
+
- [TextInput](docs/components/text-input.dsds.yaml): Used to accept a single line of text like names, titles, zip codes.
|
|
63
|
+
- [Text](docs/components/text.dsds.yaml): Displays body paragraphs, captions, and metadata.
|
|
64
|
+
- [TooltipGroup](docs/components/tooltip-group.dsds.yaml): A container that lets the rest of a row's tooltips show at once after the first one has shown.
|
|
65
|
+
- [Tooltip](docs/components/tooltip.dsds.yaml): A floating text label that shows information when a user hovers or focuses an element.
|
|
66
|
+
- [VStack](docs/components/v-stack.dsds.yaml): Stacks children vertically with even spacing.
|
|
67
|
+
- [VisuallyHidden](docs/components/visually-hidden.dsds.yaml): Hides content from sighted users while keeping it in the accessibility tree.
|
|
68
|
+
|
|
69
|
+
## Patterns
|
|
70
|
+
|
|
71
|
+
- [Confirmation & action dialogs](docs/patterns/confirmation-dialogs.dsds.yaml): Sanity UI has one modal overlay (Dialog) and one floating layer (Popover), and no built-in lightweight inline confirm. This pattern shows how to choose between a full Dialog and a Popover-based inline confirm, and the rules every confirmation surface must follow regardless of which shape is used: an informed confirm button, and a guaranteed way to close.
|
|
72
|
+
- [Error messaging](docs/patterns/error-messaging.dsds.yaml): Guidelines for writing clear, actionable error messages that name the problem and direct users to the next step.
|
|
73
|
+
- [Forms](docs/patterns/forms.dsds.yaml): Shared guidance for form fields and their inputs (Checkbox, Radio, Switch, TextInput, TextArea, Select) and the copy inside and around them: labels, placeholders, helper text, errors, empty states, success confirmations, and buttons. Rules that hold for every form field live here once; each component page references them and adds only what is specific to that input.
|
|
74
|
+
- [Layout guidelines](docs/patterns/layouts.dsds.yaml): The Sanity UI application layout system: a Navigation sidebar, a Content area (with its own toolbar and display), and an Inspection sidebar, composed into five shell layouts. Covers layout structure, navigation patterns, action placement, sidebar show/hide behavior, responsiveness, and the accessibility rules that hold the whole thing together.
|
|
75
|
+
- [Loading states](docs/patterns/loading-states.dsds.yaml): Guidelines for handling the three distinct loading moments in Sanity UI: initial load, in-place refresh, and pending actions.
|
|
76
|
+
- [Messaging](docs/patterns/messaging.dsds.yaml): Rules and guidance for writing tooltips, confirm dialogs, and status messages in Sanity UI.
|
|
77
|
+
- [Sidebar navigation pattern](docs/patterns/navigation.dsds.yaml): Sanity UI has no built-in NavItem or SidebarLink component. This pattern shows the canonical way to build keyboard-accessible sidebar navigation by composing List + List.ButtonItem, instead of hand-building nav items from a native button or Box as="button". Use this pattern for persistent sidebar navigation, not for a popover menu.
|
|
78
|
+
- [Responsive](docs/patterns/responsive.dsds.yaml): A complete reference for building responsive Sanity UI layouts using spacing tokens, breakpoint arrays, reflow patterns, grid columns, sizing props, text overflow, and overflow portal rules.
|
|
79
|
+
|
|
80
|
+
## Foundations
|
|
81
|
+
|
|
82
|
+
- [Accessibility guidelines](docs/foundations/accessibility-guidelines.dsds.yaml): Rules, requirements and the review checklist for accessible color, content, iconography, motion, spacing, and typography in Sanity UI.
|
|
83
|
+
- [Color guidelines](docs/foundations/color-guidelines.dsds.yaml): Explains Sanity UI's color principles, token layers, semantic tone system, interaction states, and practical rules for applying color in interface design.
|
|
84
|
+
- [Content guidelines](docs/foundations/content-guidelines.dsds.yaml): Rules and principles governing UI copy, naming, labels, casing, internationalization, and truncation in Sanity UI.
|
|
85
|
+
- [Semantics](docs/foundations/semantics.dsds.yaml): The HTML a component renders, and what it owes assistive technology. Covers heading structure, landmark elements, and lists rendered through `as`.
|
|
86
|
+
- [Spacing guidelines](docs/foundations/spacing-guidelines.dsds.yaml): How to apply the spacing scale in Sanity UI layout components, and how space shows what belongs together.
|
|
87
|
+
- [Typography guidelines](docs/foundations/typography-guidelines.dsds.yaml): Rules and conventions for applying Sanity UI's type scale, components, hierarchy, and reading mechanics across product interfaces.
|
|
88
|
+
|
|
89
|
+
## Tokens
|
|
90
|
+
|
|
91
|
+
- [Sanity UI](docs/tokens/color.dsds.yaml):
|
|
92
|
+
- [Sanity UI](docs/tokens/container-widths.dsds.yaml):
|
|
93
|
+
- [Sanity UI](docs/tokens/content.dsds.yaml):
|
|
94
|
+
- [Sanity UI](docs/tokens/font-family.dsds.yaml):
|
|
95
|
+
- [Sanity UI](docs/tokens/font-weight.dsds.yaml):
|
|
96
|
+
- [Sanity UI](docs/tokens/radius.dsds.yaml):
|
|
97
|
+
- [Sanity UI](docs/tokens/semantic.dsds.yaml):
|
|
98
|
+
- [Sanity UI](docs/tokens/shadow.dsds.yaml):
|
|
99
|
+
- [Sanity UI](docs/tokens/space.dsds.yaml):
|
|
100
|
+
- [Sanity UI](docs/tokens/typography.dsds.yaml):
|
|
101
|
+
|
|
102
|
+
## Guides
|
|
103
|
+
|
|
104
|
+
- [Sanity UI 5 FAQ](docs/guides/faq.dsds.yaml): Anticipated questions about Sanity UI 5, with honest answers, covering migration timing, scope, stability, and where to get help.
|
|
105
|
+
|
|
106
|
+
## Skills
|
|
107
|
+
|
|
108
|
+
- [Sanity UI 5 skill](skills/sanity-ui-5/SKILL.md): the build workflow, the rules that prevent most failures, and the reference files for setup, props, components, forms, migration, and taste (tone, density, component choice, silent failures).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/ui",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.23",
|
|
4
4
|
"description": "Sanity UI Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -26,7 +26,10 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"bin",
|
|
28
28
|
"dist",
|
|
29
|
-
"src"
|
|
29
|
+
"src",
|
|
30
|
+
"docs",
|
|
31
|
+
"skills",
|
|
32
|
+
"llms.txt"
|
|
30
33
|
],
|
|
31
34
|
"type": "module",
|
|
32
35
|
"sideEffects": [
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: sanity-ui-5
|
|
3
|
+
description: Build, edit, and review React UI with Sanity UI 5 (`@sanity/ui@alpha`, the CSS-based v5 line, not the v3 or v4 styled-components line). Covers install and entry-file setup, which components exist, prop value types, how to read the package docs, accessibility, and v3-to-v5 migration. Use this skill when the user builds screens, forms, layouts, or components with Sanity UI. Also use it when they mention `@sanity/ui` v5 or "Sanity UI 5", ask about Box, Flex, Card, Button, or Tooltip props, hit a build or styling problem, or port v3 code. Trigger even if they never say "design system". It also covers taste: tone, density, component choice, and the silent failures to avoid. DO NOT use it for Sanity Studio schemas, GROQ, or content work, or for apps that stay on Sanity UI 3 or 4.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Sanity UI 5
|
|
7
|
+
|
|
8
|
+
This skill gets you from an empty project to UI that is correct. Correct means it type-checks, renders styled, and meets WCAG 2.2 AA. Correct is the floor. For tone, restraint, and component choice, read `references/taste.md`.
|
|
9
|
+
|
|
10
|
+
## Why this skill exists
|
|
11
|
+
|
|
12
|
+
Sanity UI 5 fails quietly. A missing import leaves the page unstyled with no error. A bare `npm install @sanity/ui` installs UI 4. A wrong prop name does nothing. Most work with this library goes wrong in those places. This skill puts them first.
|
|
13
|
+
|
|
14
|
+
Four facts shape everything below:
|
|
15
|
+
|
|
16
|
+
1. **Install the right package.** Use `@sanity/ui@alpha`, or the exact v5 version you were given. The bare package name resolves to the UI 4 line.
|
|
17
|
+
2. **Set up the entry file.** Import the polyfills and the stylesheet. Without them the page renders as plain HTML.
|
|
18
|
+
3. **The installed package beats the docs.** UI 5 is pre-1.0 and still changing. When a doc and the package disagree, trust the package. Check with `npx tsc --noEmit` and the export listing in `references/setup.md`.
|
|
19
|
+
4. **Check types after every change.** Most wrong props are type errors. The exception is props spread from a loosely typed object, which skip the check.
|
|
20
|
+
|
|
21
|
+
## Workflow
|
|
22
|
+
|
|
23
|
+
Follow these steps in order for any task that writes UI. Every fact you need is in the installed package. Read files from `node_modules/@sanity/ui/`. Do not look for other sources.
|
|
24
|
+
|
|
25
|
+
1. **Read the index.** Read `node_modules/@sanity/ui/llms.txt`. It lists every document in `docs/` and what each one covers.
|
|
26
|
+
2. **Check the project setup.** Run `npx sanity-ui doctor` in the project root. It checks the package, the stylesheet import, and `tsconfig.json`. Set up the files as `references/setup.md` shows.
|
|
27
|
+
3. **Pick components.** Read `docs/overview/component-reference.dsds.yaml` for each component's status. Confirm each export with the export listing in `references/setup.md`. See `references/components.md`.
|
|
28
|
+
4. **Read each component's rules.** Read `docs/components/<id>.dsds.yaml` for every component you will use. Read its guidelines in full. When a component has subcomponents, read each subcomponent's document too.
|
|
29
|
+
5. **Write the code.** Follow the rules in the next section. Find an icon by purpose by searching `docs/icons.dsds.yaml`.
|
|
30
|
+
6. **Verify.** Run `npx tsc --noEmit`. Confirm each export with the export listing. Open the page. Test it at 320px width, with the keyboard only, and in dark mode.
|
|
31
|
+
|
|
32
|
+
### Where the docs are
|
|
33
|
+
|
|
34
|
+
Everything is in the installed package:
|
|
35
|
+
|
|
36
|
+
- `node_modules/@sanity/ui/llms.txt` is the index.
|
|
37
|
+
- `node_modules/@sanity/ui/docs/` holds the documents. Each file is a DSDS document, written as YAML.
|
|
38
|
+
- `node_modules/@sanity/ui/skills/` holds these skills.
|
|
39
|
+
|
|
40
|
+
If a document and the installed package disagree, the package wins.
|
|
41
|
+
|
|
42
|
+
## Rules that prevent most failures
|
|
43
|
+
|
|
44
|
+
Each rule names the failure it prevents. Fuller tables are in the reference files.
|
|
45
|
+
|
|
46
|
+
### Setup
|
|
47
|
+
|
|
48
|
+
- Import `@sanity/ui/polyfills` on the line above `@sanity/ui/styles.css`, in the entry file. Tooltip and Dialog need the polyfills. Without them, tooltips never show in some browsers and Dialog backdrop clicks stop working in Safari.
|
|
49
|
+
- Write the stylesheet path as `@sanity/ui/styles.css`. The other forms fail at the dev server and print no useful error.
|
|
50
|
+
- Import the Sanity UI stylesheet before your own CSS.
|
|
51
|
+
- Use React 19.2 or later, and `"jsx": "react-jsx"` in `tsconfig.json`.
|
|
52
|
+
- Do not install `styled-components`, `@sanity-labs/ui-poc`, or `react-refractor`. v5 does not use the first. The second is an old internal name. The third installs on its own.
|
|
53
|
+
- Do not change `tsconfig.json` to fix a build. The cause is usually in the source.
|
|
54
|
+
|
|
55
|
+
### Props
|
|
56
|
+
|
|
57
|
+
- Spacing takes an integer step: `<Box padding={2}>`. Sizing takes a CSS string: `<Box width="300px">`. Do not mix the two forms. See `references/props-and-imports.md`.
|
|
58
|
+
- Pass tone as a key, not a color: `tone="critical"`. Tones are `neutral`, `positive`, `suggest`, `caution`, and `critical`.
|
|
59
|
+
- Use the CSS property names on Flex and Grid: `flexDirection`, `alignItems`, `justifyContent`, `flexWrap`, `gridTemplateColumns`. The v3 names do not exist.
|
|
60
|
+
- Use `icon`, not `symbol`, on `Icon`. Use `content`, not `text`, on `Tooltip`.
|
|
61
|
+
- Do not write a prop at its default value.
|
|
62
|
+
- Do not spread props from a `Record<string, unknown>`. A wrong name then does nothing and nothing reports it.
|
|
63
|
+
|
|
64
|
+
### Structure
|
|
65
|
+
|
|
66
|
+
- Card sizes through `density` (`compact`, `regular`, `loose`) and accepts no layout props. Put layout on a `Box` or `Flex` around it.
|
|
67
|
+
- `VStack` and `HStack` accept only `as` and `gap`. Use `Flex` when you need anything else.
|
|
68
|
+
- Use `Box` or `Flex` for toolbars, sidebars, and scroll wrappers. Do not use `Card` there.
|
|
69
|
+
- Put `Container` inside the scroll `Box`, not around it.
|
|
70
|
+
- Add `flexWrap="wrap"` to rows with two or more children, and `minWidth="0"` to flex children that hold text. This prevents overflow at 320px.
|
|
71
|
+
- Use `minHeight="100vh"` on the outer shell, not `height`.
|
|
72
|
+
- Render one `<main>`. Render shell regions as `nav`, `main`, and `aside`.
|
|
73
|
+
|
|
74
|
+
### Interaction
|
|
75
|
+
|
|
76
|
+
- Do not put `onClick` on `Box` or `Card`. Use `Button`, or wrap the surface in `PressArea`.
|
|
77
|
+
- A row that navigates is a link. Use `as="a"` and `href`.
|
|
78
|
+
- Do not render `button`, `dialog`, `select`, `details`, or `fieldset` through `as` on a layout primitive. Use the matching component.
|
|
79
|
+
- Do not restyle a component with `style` or `className`. If a prop is missing, pick the nearest value the component offers. Missing props are decisions.
|
|
80
|
+
|
|
81
|
+
### Imports
|
|
82
|
+
|
|
83
|
+
- Import each icon from its own path: `import {SearchIcon} from '@sanity/icons/Search'`. The root import passes `tsc` and then fails in the browser.
|
|
84
|
+
- Import `List` alone and use `List.Item`, `List.ItemText`, and `List.ButtonItem`.
|
|
85
|
+
- Do not import `ThemeProvider` or `studioTheme`. v5 has no theming API. Theming uses CSS custom properties.
|
|
86
|
+
- Do not import `Label`, `Menu`, `Toast`, `Skeleton`, `Autocomplete`, `SegmentedControl`, or `Image`. They are not exported yet.
|
|
87
|
+
|
|
88
|
+
### Forms and accessibility
|
|
89
|
+
|
|
90
|
+
- Checkbox, Radio, and Switch have no `label` prop. Name them with a label element linked by `id` and `htmlFor`, or with `aria-label` or `aria-labelledby`.
|
|
91
|
+
- Give every icon-only control an `aria-label` on the control itself. A tooltip does not name a control.
|
|
92
|
+
- Use `hasError` for error styling, and render the message yourself. Link it with `aria-describedby`.
|
|
93
|
+
- Never disable an input that has an error.
|
|
94
|
+
- A disabled control does not trigger a Tooltip. Wrap it in a `PressArea` if the tooltip must show.
|
|
95
|
+
- Never rely on tone alone. Pair it with words or an icon.
|
|
96
|
+
|
|
97
|
+
Read `references/forms-and-accessibility.md` before you build any form.
|
|
98
|
+
|
|
99
|
+
## A correct starting point
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
// src/main.tsx
|
|
103
|
+
import '@sanity/ui/polyfills'
|
|
104
|
+
import '@sanity/ui/styles.css'
|
|
105
|
+
import {createRoot} from 'react-dom/client'
|
|
106
|
+
import {App} from './App'
|
|
107
|
+
|
|
108
|
+
createRoot(document.getElementById('root')!).render(<App />)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// src/App.tsx
|
|
113
|
+
import {Box, Button, Card, Flex, Heading, Text, TextInput, VStack} from '@sanity/ui'
|
|
114
|
+
|
|
115
|
+
export function App() {
|
|
116
|
+
return (
|
|
117
|
+
<Box as="main" padding={4}>
|
|
118
|
+
<Card density="loose">
|
|
119
|
+
<VStack gap={4}>
|
|
120
|
+
<Heading as="h1">Account</Heading>
|
|
121
|
+
<VStack gap={2}>
|
|
122
|
+
<Text as="label" htmlFor="email" size={1} weight="medium">
|
|
123
|
+
Email address
|
|
124
|
+
</Text>
|
|
125
|
+
<TextInput id="email" type="email" />
|
|
126
|
+
</VStack>
|
|
127
|
+
<Flex gap={2} justifyContent="flex-end" flexWrap="wrap">
|
|
128
|
+
<Button text="Cancel" level="tertiary" />
|
|
129
|
+
<Button text="Save" level="primary" />
|
|
130
|
+
</Flex>
|
|
131
|
+
</VStack>
|
|
132
|
+
</Card>
|
|
133
|
+
</Box>
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The example sets the entry imports and names the input through a linked label. It sizes the Card with `density` and puts layout on `Flex` and `VStack`.
|
|
139
|
+
|
|
140
|
+
## Reference files
|
|
141
|
+
|
|
142
|
+
Read a file when the task touches its topic.
|
|
143
|
+
|
|
144
|
+
| File | Read it when |
|
|
145
|
+
| --------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
146
|
+
| `references/setup.md` | You create a project, fix a build or an unstyled page, or check versions |
|
|
147
|
+
| `references/props-and-imports.md` | You write props, size or space elements, or import icons |
|
|
148
|
+
| `references/components.md` | You choose a component, check status, or look for a pattern |
|
|
149
|
+
| `references/forms-and-accessibility.md` | You build a form, an error state, or any interactive UI |
|
|
150
|
+
| `references/migrating-from-v3.md` | You port v3 code or compare v3 and v5 |
|
|
151
|
+
| `references/taste.md` | You choose a tone, set density, pick between two components, or review UI for quality |
|
|
152
|
+
| `references/tone-and-color.md` | You choose a tone or set a color, and need the tone each component takes |
|
|
153
|
+
| `references/component-choice.md` | Two components both work and you need the one the system prefers |
|
|
154
|
+
| `references/silent-failures.md` | A layout breaks or a style goes missing with no error |
|
|
155
|
+
|
|
156
|
+
## Keeping this skill honest
|
|
157
|
+
|
|
158
|
+
The facts here were checked against `@sanity/ui` 5.0.0-alpha.20 and the documentation corpus. Both change. Run `npx sanity-ui doctor` and the export listing instead of trusting a component list from memory. If the docs and the installed package disagree, report the gap to the user.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Component choice — the when-to-use-which matrix
|
|
2
|
+
|
|
3
|
+
Picking the right component is taste. The wrong one still renders, and nothing flags the mistake. These are the calls examples cannot make for you.
|
|
4
|
+
|
|
5
|
+
## Layout primitives
|
|
6
|
+
|
|
7
|
+
| Need | Use | Not |
|
|
8
|
+
| ------------------------------------------------- | ------------------------------------- | ------------------------------------------------------- |
|
|
9
|
+
| A simple vertical or horizontal stack with a gap | `VStack` / `HStack` | `Flex` with hand-set direction |
|
|
10
|
+
| A flex child that grows, shrinks, or sets a basis | `Flex`, or a `Box` wrapping the stack | flex props on `VStack` / `HStack` (type error) |
|
|
11
|
+
| A toned surface with its own density | `Card` | `Box` with hand-set background |
|
|
12
|
+
| Layout or flex-child behavior around a surface | `Box` wrapping a `Card` | layout props on `Card` (type error) |
|
|
13
|
+
| A clickable element | `Button` | `Box as="button"` (inherits browser defaults, no reset) |
|
|
14
|
+
|
|
15
|
+
`VStack` and `HStack` expose only `as` and `gap`. That is the point — they are the simple case. Step up to `Flex` when you need more, do not force props onto the stack.
|
|
16
|
+
|
|
17
|
+
## Tables
|
|
18
|
+
|
|
19
|
+
| Need | Use |
|
|
20
|
+
| ---------------------------- | --------------------- |
|
|
21
|
+
| Read-only data display | `data-table` |
|
|
22
|
+
| Clickable or selectable rows | `sortable-data-table` |
|
|
23
|
+
|
|
24
|
+
`sortable-data-table` carries interaction wiring — `tabIndex`, `aria-selected`, `onKeyDown` — that is noise on a display-only table. Match the component to whether the row is interactive.
|
|
25
|
+
|
|
26
|
+
## Typography
|
|
27
|
+
|
|
28
|
+
| Need | Use |
|
|
29
|
+
| ---------------------------------- | ------------------------------------ |
|
|
30
|
+
| A heading at a set level | `Heading` with `as` set to the tag |
|
|
31
|
+
| A visual size apart from the level | `Heading` `size`, set alongside `as` |
|
|
32
|
+
|
|
33
|
+
A `Heading` with no `as` renders `<h2>` in every context and breaks the hierarchy. Set the tag with `as`; control the look with `size`.
|
|
34
|
+
|
|
35
|
+
## The general rule
|
|
36
|
+
|
|
37
|
+
When two components both render the result, the one carrying less machinery is the Sanity choice. Range comes from composing the primitives, not from reaching for the heavier component.
|