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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +10 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/docs/components/avatar-counter.dsds.yaml +78 -0
  6. package/docs/components/avatar-stack.dsds.yaml +96 -0
  7. package/docs/components/avatar.dsds.yaml +115 -0
  8. package/docs/components/badge.dsds.yaml +126 -0
  9. package/docs/components/box.dsds.yaml +223 -0
  10. package/docs/components/button.dsds.yaml +284 -0
  11. package/docs/components/card.dsds.yaml +317 -0
  12. package/docs/components/checkbox.dsds.yaml +204 -0
  13. package/docs/components/code.dsds.yaml +167 -0
  14. package/docs/components/container.dsds.yaml +189 -0
  15. package/docs/components/dialog.dsds.yaml +343 -0
  16. package/docs/components/divider.dsds.yaml +93 -0
  17. package/docs/components/eyebrow.dsds.yaml +217 -0
  18. package/docs/components/flex.dsds.yaml +237 -0
  19. package/docs/components/grid.dsds.yaml +217 -0
  20. package/docs/components/h-stack.dsds.yaml +127 -0
  21. package/docs/components/heading.dsds.yaml +233 -0
  22. package/docs/components/hotkeys.dsds.yaml +60 -0
  23. package/docs/components/icon-button.dsds.yaml +220 -0
  24. package/docs/components/icon.dsds.yaml +275 -0
  25. package/docs/components/indicator-stack.dsds.yaml +98 -0
  26. package/docs/components/indicator.dsds.yaml +108 -0
  27. package/docs/components/inline.dsds.yaml +127 -0
  28. package/docs/components/kbd.dsds.yaml +59 -0
  29. package/docs/components/link.dsds.yaml +108 -0
  30. package/docs/components/list-button-item.dsds.yaml +103 -0
  31. package/docs/components/list-item-image.dsds.yaml +82 -0
  32. package/docs/components/list-item-text.dsds.yaml +80 -0
  33. package/docs/components/list-item.dsds.yaml +148 -0
  34. package/docs/components/list.dsds.yaml +162 -0
  35. package/docs/components/popover.dsds.yaml +208 -0
  36. package/docs/components/press-area.dsds.yaml +279 -0
  37. package/docs/components/radio.dsds.yaml +198 -0
  38. package/docs/components/select.dsds.yaml +214 -0
  39. package/docs/components/skip-to-content.dsds.yaml +110 -0
  40. package/docs/components/spinner.dsds.yaml +119 -0
  41. package/docs/components/switch.dsds.yaml +202 -0
  42. package/docs/components/tab.dsds.yaml +54 -0
  43. package/docs/components/tabs-list.dsds.yaml +56 -0
  44. package/docs/components/tabs-panel.dsds.yaml +54 -0
  45. package/docs/components/tabs.dsds.yaml +104 -0
  46. package/docs/components/text-area.dsds.yaml +170 -0
  47. package/docs/components/text-input.dsds.yaml +189 -0
  48. package/docs/components/text.dsds.yaml +268 -0
  49. package/docs/components/tooltip-group.dsds.yaml +90 -0
  50. package/docs/components/tooltip.dsds.yaml +216 -0
  51. package/docs/components/v-stack.dsds.yaml +155 -0
  52. package/docs/components/visually-hidden.dsds.yaml +112 -0
  53. package/docs/evals/cases.yaml +1319 -0
  54. package/docs/examples/checkbox-2.tsx +57 -0
  55. package/docs/examples/confirmation-dialogs-1.tsx +27 -0
  56. package/docs/examples/confirmation-dialogs-2.tsx +55 -0
  57. package/docs/examples/confirmation-dialogs-3.tsx +28 -0
  58. package/docs/examples/confirmation-dialogs-4.tsx +38 -0
  59. package/docs/examples/popover-1.tsx +48 -0
  60. package/docs/examples/popover-2.tsx +53 -0
  61. package/docs/foundations/accessibility-guidelines.dsds.yaml +301 -0
  62. package/docs/foundations/color-guidelines.dsds.yaml +308 -0
  63. package/docs/foundations/content-guidelines.dsds.yaml +285 -0
  64. package/docs/foundations/semantics.dsds.yaml +125 -0
  65. package/docs/foundations/spacing-guidelines.dsds.yaml +226 -0
  66. package/docs/foundations/typography-guidelines.dsds.yaml +322 -0
  67. package/docs/icons.dsds.yaml +2513 -0
  68. package/docs/index.dsds.yaml +515 -0
  69. package/docs/overview/api-essentials.dsds.yaml +221 -0
  70. package/docs/overview/component-reference.dsds.yaml +215 -0
  71. package/docs/overview/designer-contribution-model.dsds.yaml +77 -0
  72. package/docs/overview/developer-contribution-model.dsds.yaml +362 -0
  73. package/docs/overview/installation.dsds.yaml +238 -0
  74. package/docs/overview/quick-start.dsds.yaml +317 -0
  75. package/docs/overview/resources.dsds.yaml +34 -0
  76. package/docs/patterns/confirmation-dialogs.dsds.yaml +140 -0
  77. package/docs/patterns/error-messaging.dsds.yaml +58 -0
  78. package/docs/patterns/forms.dsds.yaml +356 -0
  79. package/docs/patterns/layouts.dsds.yaml +403 -0
  80. package/docs/patterns/loading-states.dsds.yaml +41 -0
  81. package/docs/patterns/messaging.dsds.yaml +72 -0
  82. package/docs/patterns/navigation.dsds.yaml +153 -0
  83. package/docs/patterns/responsive.dsds.yaml +590 -0
  84. package/docs/tokens/color.dsds.yaml +1158 -0
  85. package/docs/tokens/container-widths.dsds.yaml +131 -0
  86. package/docs/tokens/content.dsds.yaml +258 -0
  87. package/docs/tokens/content.tokens.json +180 -0
  88. package/docs/tokens/dtcg/README.md +39 -0
  89. package/docs/tokens/dtcg/css/color.css +107 -0
  90. package/docs/tokens/dtcg/css/container.css +12 -0
  91. package/docs/tokens/dtcg/css/fontFamily.css +10 -0
  92. package/docs/tokens/dtcg/css/fontWeight.css +10 -0
  93. package/docs/tokens/dtcg/css/index.css +13 -0
  94. package/docs/tokens/dtcg/css/radius.css +14 -0
  95. package/docs/tokens/dtcg/css/semantic.css +42 -0
  96. package/docs/tokens/dtcg/css/shadow.css +22 -0
  97. package/docs/tokens/dtcg/css/space.css +16 -0
  98. package/docs/tokens/dtcg/css/typography.css +69 -0
  99. package/docs/tokens/dtcg/json/color.tokens.json +911 -0
  100. package/docs/tokens/dtcg/json/container.tokens.json +44 -0
  101. package/docs/tokens/dtcg/json/fontFamily.tokens.json +10 -0
  102. package/docs/tokens/dtcg/json/fontWeight.tokens.json +18 -0
  103. package/docs/tokens/dtcg/json/radius.tokens.json +58 -0
  104. package/docs/tokens/dtcg/json/semantic.tokens.json +372 -0
  105. package/docs/tokens/dtcg/json/shadow.tokens.json +599 -0
  106. package/docs/tokens/dtcg/json/space.tokens.json +72 -0
  107. package/docs/tokens/dtcg/json/typography.tokens.json +354 -0
  108. package/docs/tokens/font-family.dsds.yaml +79 -0
  109. package/docs/tokens/font-weight.dsds.yaml +103 -0
  110. package/docs/tokens/radius.dsds.yaml +153 -0
  111. package/docs/tokens/semantic.dsds.yaml +397 -0
  112. package/docs/tokens/shadow.dsds.yaml +125 -0
  113. package/docs/tokens/space.dsds.yaml +185 -0
  114. package/docs/tokens/typography.dsds.yaml +316 -0
  115. package/llms.txt +108 -0
  116. package/package.json +5 -2
  117. package/skills/sanity-ui-5/SKILL.md +158 -0
  118. package/skills/sanity-ui-5/references/component-choice.md +37 -0
  119. package/skills/sanity-ui-5/references/components.md +145 -0
  120. package/skills/sanity-ui-5/references/forms-and-accessibility.md +189 -0
  121. package/skills/sanity-ui-5/references/migrating-from-v3.md +250 -0
  122. package/skills/sanity-ui-5/references/props-and-imports.md +169 -0
  123. package/skills/sanity-ui-5/references/setup.md +177 -0
  124. package/skills/sanity-ui-5/references/silent-failures.md +33 -0
  125. package/skills/sanity-ui-5/references/taste.md +53 -0
  126. package/skills/sanity-ui-5/references/tone-and-color.md +55 -0
  127. package/src/version.ts +2 -2
@@ -0,0 +1,362 @@
1
+ kind: sanity.guide
2
+ id: developer-contribution-model
3
+ name: Developer contribution model
4
+ description: '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.'
5
+ metadata:
6
+ tags:
7
+ - contribution
8
+ - developer
9
+ - pull request
10
+ - recipe
11
+ - triage
12
+ - branch naming
13
+ - storybook
14
+ - typedocs
15
+ - testing
16
+ - documentation
17
+ - checklist
18
+ - '@sanity/ui'
19
+ status:
20
+ status: stable
21
+ sections:
22
+ - kind: guidelines
23
+ for: agent
24
+ framing: how-to-use
25
+ items:
26
+ - level: must
27
+ statement: Name branches `<type>/<short-description>` using type feat, fix, docs, or refactor, 3-5 words, lowercase, hyphen-separated, with no ticket numbers.
28
+ - level: must
29
+ statement: Include What, Why, and How to review sections in every PR description. New components additionally need an API surface table and an Open questions section.
30
+ - level: must
31
+ statement: Write components as .tsx with explicit prop types exported alongside the component, one component per file, a named Props type (not inline types), React.forwardRef for anything rendering a DOM element, and named exports only — never a default export.
32
+ - level: must
33
+ statement: Include a Storybook story for every new component and every major change to an existing one, covering all tone/mode/state variants, both light and dark scheme, a composition example, and edge cases (long text, empty state, max children, disabled).
34
+ - level: must
35
+ statement: Give every public prop a TSDoc comment describing behavior, not accepted values. Do not enumerate inherited props, use @type, quote simple prop names, use @optional, or note defaults in description text — use @defaultValue only when the default is not undefined.
36
+ - level: must
37
+ statement: Cover a PR with tests across five categories before requesting review — accessibility, performance, visual regression, functional unit tests, and AI fluency — or explicitly mark a category N/A with a reason.
38
+ - level: must
39
+ statement: For new components, create a doc file with a complete props table and at least one working code example; usage guidelines, best practices, accessibility, and content sections are encouraged but not required.
40
+ - level: must-not
41
+ statement: Do not hardcode colors, spacing, font sizes, shadows, or border radii. Use design tokens through component props (padding, tone, radius, gap) or CSS custom properties.
42
+ - kind: steps
43
+ for: all
44
+ ordered: true
45
+ title: The three-step contribution model
46
+ items:
47
+ - title: 'Step 1: Build a recipe'
48
+ description: |-
49
+ A recipe is a working composition of existing Sanity UI components. It solves a real feature need. It lives in your project — not in `@sanity/ui` itself.
50
+
51
+ Build the recipe with existing primitives (Card, VStack, Flex, Button, etc.). The more you use what the system already provides, the more accessibility, theming, and dark mode support come for free.
52
+
53
+ You can stop here. The recipe works in your project. No PR needed. No review needed. You ship your feature and move on.
54
+ - title: 'Step 2: Propose a contribution'
55
+ description: |-
56
+ If the recipe solves a problem other teams would face, propose graduating it into `@sanity/ui`. Ideally, three or more existing use cases would benefit from this recipe.
57
+
58
+ Bring it to a triage sync. Share what kind of contribution this is (new component, changing an existing component, bug fix, etc.). Show the working code. Walk through the API — what props does it accept, what does it render, how does it compose with other primitives.
59
+
60
+ The design system team and the contributor decide together whether it belongs in the core library. If it doesn't graduate, you still have a working recipe.
61
+ - title: 'Step 3: Open a pull request'
62
+ description: |-
63
+ If the team agrees the recipe should become a core component, the contributor opens a PR against the `@sanity/ui` repo. The design system team collaborates on the PR — this is a partnership, not a gate.
64
+
65
+ The rest of this guide describes how to format that PR.
66
+ - kind: steps
67
+ for: all
68
+ ordered: false
69
+ title: PR checklist
70
+ items:
71
+ - title: Branch follows `<type>/<description>` naming
72
+ - title: PR description has What / Why / How to review sections
73
+ - title: TypeScript types are exported for all public props
74
+ - title: Component forwards refs
75
+ - title: Named exports only (no default export)
76
+ - title: No hardcoded colors, spacing, font sizes, or shadows — uses design tokens only
77
+ - title: Story file created or updated (`ComponentName.stories.tsx`)
78
+ - title: Stories cover all visual variants (tones, modes, states)
79
+ - title: Light and dark scheme shown
80
+ - title: Interactive controls wired to props
81
+ - title: Story linked in PR description under "How to review"
82
+ - title: Every public prop has a TSDoc comment
83
+ - title: Docstrings describe behavior, not accepted values (types handle that)
84
+ - title: No @type, @optional, or quoted simple prop names
85
+ - title: '@defaultValue used only when default is not undefined'
86
+ - title: Defaults are not noted in description text
87
+ - title: Inherited props are not re-documented
88
+ - title: 'Accessibility: axe-core scan passes, keyboard works, screen reader names correct'
89
+ - title: 'Performance: renders within benchmark threshold (or N/A)'
90
+ - title: 'Visual regression: snapshots captured for all states/schemes (or N/A)'
91
+ - title: 'Functional: unit tests cover props, interactions, and edge cases'
92
+ - title: 'AI fluency: LLM can build a working example from the docs (or N/A)'
93
+ - title: Component doc file created or updated
94
+ - title: Props table is complete
95
+ - title: At least one code example included
96
+ - kind: section
97
+ for: all
98
+ freeform:
99
+ - title: Overview
100
+ body: 'This model mirrors the designer contribution model. Same philosophy: low-process, high-trust, always walk away with something usable. The difference is that the workflow goes through code — branches, pull requests, and tests.'
101
+ - kind: section
102
+ for: all
103
+ freeform:
104
+ - title: Branch naming
105
+ body: |-
106
+ Use the format:
107
+
108
+ ```
109
+ <type>/<short-description>
110
+ ```
111
+
112
+ | Type | When to use | Example |
113
+ | --- | --- | --- |
114
+ | `feat` | New component or new prop on an existing component | `feat/combobox` |
115
+ | `fix` | Bug fix | `fix/button-focus-ring-dark-mode` |
116
+ | `docs` | Documentation only | `docs/card-selected-pattern` |
117
+ | `refactor` | Internal change with no API impact | `refactor/flex-css-modules` |
118
+
119
+ Keep the branch name to 3–5 words, lowercase, hyphen-separated. No ticket numbers in branch names — put those in the PR description.
120
+ - title: PR description
121
+ body: |-
122
+ Every PR needs three sections. Copy this template:
123
+
124
+ ```markdown
125
+ ## What
126
+
127
+ One or two sentences describing what the PR adds or changes. Name the component
128
+ and the user-facing behavior.
129
+
130
+ ## Why
131
+
132
+ Link to the triage decision, the issue, or the feedback that motivated this
133
+ change. If this graduated from a recipe, link to the original component or pattern.
134
+
135
+ ## How to review
136
+
137
+ Steps to see the change in action. Could be:
138
+ - A Storybook story to open
139
+ - A test command to run
140
+ - A before/after screenshot
141
+ ```
142
+
143
+ For new components, also add:
144
+
145
+ ```markdown
146
+ ## API surface
147
+
148
+ | Prop | Type | Default | Description |
149
+ | --- | --- | --- | --- |
150
+ | (list every public prop) | | | |
151
+
152
+ ## Open questions
153
+
154
+ - (anything the contributor is unsure about and wants feedback on)
155
+ ```
156
+ - title: Code formatting
157
+ body: |-
158
+ Follow the conventions already in `@sanity/ui`. The short version:
159
+
160
+ - **TypeScript.** All components are `.tsx`. All props have explicit types. Export the props type alongside the component (`export type ComboboxProps = { ... }`).
161
+ - **One component per file.** The file name matches the component name: `Combobox.tsx` exports `Combobox`.
162
+ - **Props interface, not inline types.** Define a named `Props` or `ComponentNameProps` type. Do not inline complex types in the function signature.
163
+ - **Forward refs.** Every component that renders a DOM element must use `React.forwardRef`. Tooltip, Popover, and other overlay components depend on this.
164
+ - **No default exports.** Use named exports only.
165
+ - **CSS.** Follow the existing styling approach in the repo (CSS modules or styled-components — match what's in place, do not introduce a new approach).
166
+ - **Design tokens, not hardcoded values.** Do not hardcode colors, spacing, font sizes, shadows, or border radii. Use the theme's design tokens through component props (`padding`, `tone`, `radius`, `gap`). Hardcoded values break dark mode, ignore tone contexts, and diverge from the spacing scale.
167
+ - title: Storybook story
168
+ body: |-
169
+ Each new component and each major change to an existing component must include a Storybook story. The story is the review artifact — designers and developers on the design system team use it to evaluate the component before approving the PR.
170
+
171
+ **What to include**
172
+
173
+ - **One story per visual variant.** Show each combination of `tone`, `mode`, and `state` the component supports.
174
+ - **Interactive controls.** Use Storybook args/controls to let reviewers toggle props without editing code.
175
+ - **Light and dark scheme.** Include at least one story that renders the component in both `scheme="light"` and `scheme="dark"`.
176
+ - **Composition example.** Show the component used in context — inside a Card, alongside other primitives, in a realistic layout.
177
+ - **Edge cases.** Long text, empty state, maximum children, disabled state.
178
+
179
+ **File location**
180
+
181
+ Place the story file next to the component:
182
+
183
+ ```
184
+ src/
185
+ components/
186
+ Combobox/
187
+ Combobox.tsx
188
+ Combobox.test.tsx
189
+ Combobox.stories.tsx ← story file
190
+ ```
191
+
192
+ The story is the primary artifact for design review. Link to it in the PR description under "How to review."
193
+ - title: Prop documentation (TypeDocs)
194
+ body: |-
195
+ Every public prop must have a TSDoc comment in the props type definition. These comments power IDE tooltips, generated API docs, and AI context.
196
+
197
+ **Rules**
198
+
199
+ - **Describe what the prop does, not what values it accepts.** The TypeScript type already declares the accepted values. Do not repeat them in the docstring.
200
+ - **Do not enumerate inherited props.** If the component extends `BoxProps` or `HTMLAttributes`, the inherited props are visible through the type. Only document props that the component adds or overrides.
201
+ - **Do not use `@type`.** TypeScript declares the type. The tag is redundant.
202
+ - **Do not quote simple prop names.** Props like `padding`, `tone`, and `selected` do not need quotes. Only quote names that contain special characters (for example, `aria-label`).
203
+ - **Do not use `@optional`.** The `?` in the type definition marks a prop as optional. The tag adds no information.
204
+ - **Use `@defaultValue` only when the default is not `undefined`.** If a prop defaults to `undefined` (the most common case), omit the tag. If the component applies a specific default (for example, `"div"`, `3`, `true`), document it with `@defaultValue`.
205
+ - **Do not note defaults in any other way.** Do not write "Defaults to X" in the description text. Use `@defaultValue` or nothing.
206
+
207
+ **Example — correct**
208
+
209
+ ```tsx
210
+ export interface ComboboxProps {
211
+ /**
212
+ * Text shown when no option is selected.
213
+ */
214
+ placeholder?: string
215
+
216
+ /**
217
+ * Disables the input and removes it from the tab order.
218
+ * @defaultValue false
219
+ */
220
+ disabled?: boolean
221
+
222
+ /**
223
+ * HTML element to render.
224
+ * @defaultValue "div"
225
+ */
226
+ as?: React.ElementType
227
+
228
+ /**
229
+ * Called when the selected value changes.
230
+ */
231
+ onChange?: (value: string) => void
232
+
233
+ /**
234
+ * Semantic background color.
235
+ */
236
+ tone?: 'default' | 'positive' | 'caution' | 'critical'
237
+ }
238
+ ```
239
+
240
+ **Example — incorrect**
241
+
242
+ ```tsx
243
+ // ✗ Enumerates values in the docstring
244
+ /**
245
+ * Semantic background color.
246
+ * Accepted values: "default", "positive", "caution", "critical".
247
+ */
248
+ tone?: 'default' | 'positive' | 'caution' | 'critical'
249
+
250
+ // ✗ Uses @type (redundant with TypeScript)
251
+ /**
252
+ * @type {string}
253
+ */
254
+ placeholder?: string
255
+
256
+ // ✗ Uses @optional (redundant with ?)
257
+ /**
258
+ * @optional
259
+ */
260
+ disabled?: boolean
261
+
262
+ // ✗ Quotes a simple prop name
263
+ /**
264
+ * The "tone" prop sets the color.
265
+ */
266
+ tone?: Tone
267
+
268
+ // ✗ Uses @defaultValue for undefined
269
+ /**
270
+ * @defaultValue undefined
271
+ */
272
+ onChange?: (value: string) => void
273
+
274
+ // ✗ Notes default in description text instead of @defaultValue
275
+ /**
276
+ * HTML element to render. Defaults to "div".
277
+ */
278
+ as?: React.ElementType
279
+ ```
280
+ - title: Testing
281
+ body: |-
282
+ A PR is not ready for review until it has test coverage across five categories. Not all categories apply to every PR — but the contributor must confirm which apply and mark the rest as N/A.
283
+
284
+ **Accessibility tests**
285
+
286
+ Sanity UI components must meet WCAG 2.2 AA criteria at minimum. Sanity UI has built-in accessibility testing that acts as a baseline for accessibility compliance. A contributed component must pass all tests before it's officially submitted.
287
+
288
+ Refer to "Component authoring accessibility standards" for specific information related to shipping accessible Sanity UI components.
289
+
290
+ **Performance tests**
291
+
292
+ Measure rendering cost for components that appear in lists or render many children.
293
+
294
+ - Render time for a list of 100 instances should stay under the existing benchmark threshold.
295
+ - No layout thrashing (forced reflows) during mount or state changes.
296
+
297
+ **Visual regression tests**
298
+
299
+ Sanity UI has built-in tests for visual regressing. A contribution cannot cause any visual regressions with existing components.
300
+
301
+ **Functional unit tests**
302
+
303
+ Cover the component's behavior with unit tests.
304
+
305
+ - Every prop that changes rendered output has at least one test.
306
+ - Every user interaction (click, keypress, focus) has a test.
307
+ - Edge cases: empty state, overflow content, maximum prop values.
308
+
309
+ Use the test framework already in the repo. Match the patterns in existing test files.
310
+
311
+ **AI fluency tests**
312
+
313
+ Verify that an LLM can use the component from its documentation alone.
314
+
315
+ - Provide the component's doc page (props table, usage guidelines, examples) as context to an LLM.
316
+ - Ask it to build a working example using the component.
317
+ - The generated code must render without errors and pass the accessibility test suite.
318
+
319
+ This measures whether the documentation and API are clear enough for both humans and AI agents to use correctly.
320
+ - title: Documentation required
321
+ body: |-
322
+ Every PR that adds or changes a public API must include documentation updates. Don't merge without them.
323
+
324
+ **For new components**
325
+
326
+ Create a new `.md` file in the component documentation directory. It must include:
327
+
328
+ | Section | What to write | Required |
329
+ | --- | --- | --- |
330
+ | **Props table** | Every public prop with type, accepted values, default, and description | Yes |
331
+ | **Code examples** | At least one working example showing the primary use case | Yes |
332
+ | **Usage guidelines** | When to use, when not to use, which component to use instead | No |
333
+ | **Best practices** | Do / Don't list with rationale | No |
334
+ | **Accessibility** | Keyboard interaction, ARIA attributes, accessible name source, contrast notes | No |
335
+ | **Content** | Casing, label length, tone pairing, translation considerations | No |
336
+
337
+ Use `button.md`, `card.md`, or `dialog.md` as a reference for the expected structure and depth.
338
+
339
+ **For changes to existing components**
340
+
341
+ Update the component's doc file to reflect the change. If you add a new prop, add it to the props table and write a usage example. If you change behavior, update the affected sections.
342
+
343
+ **Writing standards**
344
+
345
+ - Follow the casing rule in Content guidelines (`content-guidelines#sentence-case-all-system-set`).
346
+ - Do not simplify technical terms (WCAG, aria-label, screen readers, etc.).
347
+ - title: What happens after the PR is merged
348
+ body: |-
349
+ The design system team handles:
350
+
351
+ - Publishing the next release of `@sanity/ui`.
352
+ - Updating the public documentation site.
353
+ - Announcing the new component or change to consuming teams.
354
+
355
+ The design system team credits the contributor in the changelog.
356
+ - title: Keep it simple
357
+ body: This model works because the team is small enough that everyone knows each other. If a step feels unclear, ask in the triage sync. If a test category doesn't apply, mark it N/A and explain why. The goal is to ship good components — not to fill out forms.
358
+ - kind: section
359
+ for: agent
360
+ freeform:
361
+ - title: Intent
362
+ body: 'Use this guide when opening a pull request against @sanity/ui: it defines branch naming, the PR description template, code and TSDoc conventions, Storybook requirements, the five test categories, and the documentation that must ship with the PR.'
@@ -0,0 +1,238 @@
1
+ kind: sanity.guide
2
+ id: installation
3
+ name: Installation
4
+ description: 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.
5
+ metadata:
6
+ tags:
7
+ - installation
8
+ - install
9
+ - setup
10
+ - getting-started
11
+ - react
12
+ - styles.css
13
+ - peer dependency
14
+ - overrides
15
+ - react-refractor
16
+ - ERESOLVE
17
+ - legacy-peer-deps
18
+ - tsconfig
19
+ - doctor
20
+ - package.json
21
+ - vite
22
+ - typescript
23
+ - polyfills
24
+ status:
25
+ status: stable
26
+ sections:
27
+ - kind: guidelines
28
+ for: all
29
+ framing: how-to-use
30
+ items:
31
+ - level: must
32
+ statement: The `styles.css` import is required. Without it, all components render as plain, unstyled HTML. No error is thrown.
33
+ - level: must
34
+ statement: Import `@sanity/ui/polyfills` on the line above the stylesheet. Tooltip and Dialog both need it. Both fail silently without it. Tooltips never appear in browsers that lack the Interest Invokers API. A Dialog backdrop click stops dismissing in Safari, where Escape and the close button still work.
35
+ - level: must
36
+ statement: Import the Sanity UI stylesheet before your own global CSS. Sanity UI puts only its global reset in a cascade layer, `sui.global`, so any of your CSS overrides the reset. Its component styles are not layered, so when your CSS and a component rule have the same specificity, the later import wins.
37
+ - level: must
38
+ statement: 'Use `PressArea` to make a non-interactive element interactive. `Box` and `Card` don''t accept `onClick`. To make a whole card, list row, or media tile clickable, wrap it in `PressArea` — `<PressArea onClick={...}><Card>…</Card></PressArea>` — which renders a real `<button>` (or an `<a>` with `as="a"`). Put padding and visual styling on the child `Card`/`Box`, not on `PressArea`. `PressArea` is interactive-only: don''t use it as a backdrop or layout wrapper, and never pass `as="div"` (use a styled `Box` for non-interactive surfaces).'
39
+ - refs:
40
+ - to: shared-foundations#install-alpha-not-ui-poc
41
+ rel: same-as
42
+ - level: must-not
43
+ statement: The exact specifier is `@sanity/ui/styles.css` — not `@sanity/ui/dist/styles.css` (wrong subpath) and not `@sanity/ui/styles` (missing the extension). Both wrong forms fail at the Vite dev-server level, not in the browser. The page never renders and no console error explains why.
44
+ - kind: guidelines
45
+ for: agent
46
+ framing: how-to-use
47
+ items:
48
+ - level: must
49
+ statement: '@sanity/ui v5 requires React 19.2 or later. Installing it in a project with React 18 will fail with ERESOLVE unless you add npm overrides or use --legacy-peer-deps.'
50
+ - level: must
51
+ statement: 'Install @sanity/ui with the `alpha` dist-tag, or with the exact v5 version you were given. If a task, a team or a lockfile names an exact version, use it as given. Never install a bare `@sanity/ui`: its `latest` tag is the pre-v5 line, and it resolves to the wrong major with no error.'
52
+ - level: must
53
+ statement: Install @sanity/icons without a dist-tag, or with the exact version you were given. Unlike @sanity/ui, its v5 line (5.2.1 and later) is already the package's `latest` tag.
54
+ - level: should
55
+ statement: Run `npx @sanity/ui@alpha doctor` before manually inspecting an entry file for a missing styles.css import or a tsconfig.json gap — it checks both (and package/icons install state, React/Node versions) in one pass.
56
+ - level: should
57
+ statement: 'For React 18 projects, add overrides to package.json before running install: { "overrides": { "react": "^19.2", "react-dom": "^19.2" } }. Use --legacy-peer-deps as a fallback if overrides are not an option.'
58
+ - level: should
59
+ statement: '@sanity/icons is a regular dependency of @sanity/ui v5, not a peer dependency — it installs on its own. Add it to your own package.json only because your app code imports icons directly, not because v5 needs you to.'
60
+ - level: should-not
61
+ statement: Do not add react-refractor to package.json. It is a regular dependency of @sanity/ui v5, not a peer dependency, and installs on its own.
62
+ - kind: guidelines
63
+ for: agent
64
+ framing: how-to-use
65
+ title: Project files
66
+ items:
67
+ - level: must
68
+ statement: "Add `@types/react` and `@types/react-dom` to `devDependencies`. Without them, every file reports `TS7016: Could not find a declaration file for module 'react'`. The error cascades, and components such as Switch, Radio and Card then look broken when nothing is wrong with them."
69
+ - level: must
70
+ statement: Add `@vitejs/plugin-react` to `devDependencies` in a Vite project. Without it the install and the type check both pass, and the dev server then fails to start with `ERR_MODULE_NOT_FOUND`.
71
+ - level: must-not
72
+ statement: Do not add `styled-components`. Version 5 does not use it.
73
+ - kind: guidelines
74
+ for: agent
75
+ framing: how-to-use
76
+ title: TypeScript configuration
77
+ items:
78
+ - level: must
79
+ statement: Write the `tsconfig.json` below as the project's first file, as written. It is the config Sanity UI's CLI writes for a new project (`npx @sanity/ui@alpha init`).
80
+ - level: must
81
+ statement: 'Keep `"jsx": "react-jsx"` in `compilerOptions`. Leaving it out causes the most common build failure in this library, `TS17004: Cannot use JSX unless the ''--jsx'' flag is provided`, on every component.'
82
+ - level: must
83
+ statement: 'Use TypeScript 5 or later, with `"moduleResolution": "bundler"`. Sanity UI''s types are reached through its `exports` map, which `"node"` and `"classic"` do not read.'
84
+ - level: should
85
+ statement: Keep `"app"` in `include`, even with no `app` folder. The CLI writes it so the same config fits projects that keep their sources in `app/`. A missing folder is not an error while `src` has files.
86
+ - level: must-not
87
+ statement: 'Do not add `compilerOptions` keys beyond the ones shown. An invented or misspelled key fails the build with `TS5023: Unknown compiler option`.'
88
+ - level: must-not
89
+ statement: Do not run a bare `tsc`. The config sets no `noEmit`, so it writes `.js` files beside your sources, and Vite loads those instead of the `.tsx` files. Type-check with `tsc --noEmit`, as the `build` script below does.
90
+ - level: must-not
91
+ statement: Do not change `tsconfig.json` while fixing a build. The cause of a build failure is almost always in the source under `src/`. Editing the config turns one error into an error on every file.
92
+ - kind: steps
93
+ for: all
94
+ ordered: true
95
+ title: Automatic setup (recommended)
96
+ items:
97
+ - title: Run the setup CLI
98
+ description: |-
99
+ ```sh
100
+ npx @sanity/ui@alpha init
101
+ ``` Detects your framework (Next.js, Remix, React Router, Vite, Astro, or plain React) and package manager, checks React and Node versions, installs `@sanity/ui@5` and `@sanity/icons` at matching versions, adds `import '@sanity/ui/styles.css'` to the detected entry file, reconciles `tsconfig.json` (creates it if missing, or adds only the missing required options), and writes `sanity-ui.json`. Prints the plan and asks for confirmation before writing anything.
102
+ `@sanity/ui`'s `latest` npm tag still points at the pre-v5 line — v5 only publishes under the `alpha` tag. Always pin `@sanity/ui@alpha`. A bare `@sanity/ui` install resolves to the wrong major. `init` is for new apps only. If it finds a pre-v5 `@sanity/ui` dependency, it stops with exit code 1.
103
+ - title: Flags
104
+ description: '`--dry` prints the plan and exits without changing anything. `--yes` / `-y` accepts every prompt with its default — use this for CI or when running through an agent. `--cwd <dir>` runs against a directory other than the current one. Without a TTY, `init` applies the plan and reports it. `--yes` only silences the confirmation prompt in an interactive terminal.'
105
+ - title: Verify an existing setup
106
+ description: |-
107
+ ```sh
108
+ npx @sanity/ui@alpha doctor
109
+ ``` Re-runs the same checks `init` verifies at the end of its run and prints a one-line fix for anything that fails: package and `@sanity/icons` installed, stylesheet resolves and is imported, `tsconfig.json` has the required options, React and Node versions. Read-only — it never writes anything. Run it first whenever a component renders unstyled or a build fails for no obvious reason.
110
+ If it finds `@sanity/ui` at a pre-v5 version, it prints a warning and exits with code 0 without running any checks.
111
+ - kind: steps
112
+ for: all
113
+ ordered: true
114
+ title: Install
115
+ items:
116
+ - title: Check your React version
117
+ description: '`@sanity/ui` requires React 19.2 or later. If your project has an older React version, `npm install` will fail with a peer dependency error.'
118
+ - title: 'New project: install React 19.2 first'
119
+ description: |-
120
+ Start with React 19.2:
121
+ ```shell npm install react@^19.2 react-dom@^19.2 ``` Then add Sanity UI (pin the `alpha` tag — `@sanity/ui`'s `latest` npm tag is the pre-v5 line):
122
+ ```shell npm install @sanity/ui@alpha ```
123
+ `@sanity/ui` depends on `@sanity/icons` and `react-refractor` directly — both install on their own. Add `@sanity/icons` to your own `package.json` if your app code imports icons directly. That keeps it from being a hidden transitive dependency:
124
+ ```shell npm install @sanity/icons ```
125
+ Sanity UI 5 has no `styled-components` dependency and no theme provider. Skip both.
126
+ - title: 'Existing project with React 18: add npm overrides'
127
+ description: |-
128
+ Add `overrides` to your `package.json` before running install:
129
+
130
+ ```json
131
+ "overrides": {
132
+ "react": "^19.2",
133
+ "react-dom": "^19.2"
134
+ }
135
+ ```
136
+
137
+ Then install:
138
+
139
+ ```shell
140
+ npm install react@^19.2 react-dom@^19.2 @sanity/ui@alpha @sanity/icons
141
+ ```
142
+
143
+ If you can't add overrides, use `--legacy-peer-deps`:
144
+
145
+ ```shell
146
+ npm install @sanity/ui@alpha @sanity/icons --legacy-peer-deps
147
+ ```
148
+ - kind: steps
149
+ for: all
150
+ ordered: true
151
+ title: Set up the entry point
152
+ items:
153
+ - title: Import the polyfills and the stylesheet
154
+ description: |-
155
+ Sanity UI 5 has no `ThemeProvider`. Import the polyfills and the stylesheet once, in the entry file.
156
+
157
+ ```js
158
+ import { createRoot } from 'react-dom/client'
159
+ import '@sanity/ui/polyfills' // Tooltip and Dialog need this; both fail silently without it
160
+ import '@sanity/ui/styles.css'
161
+ import App from './App'
162
+
163
+ createRoot(document.getElementById('root')!).render(<App />)
164
+ ```
165
+ - kind: section
166
+ for: all
167
+ freeform:
168
+ - title: Project files to start from
169
+ body: |-
170
+ For a new Vite project, start from these files. Where you were given exact versions, write those in place of `alpha` and `^5.2.1`.
171
+
172
+ **`package.json`**
173
+
174
+ ```json
175
+ {
176
+ "name": "my-app",
177
+ "private": true,
178
+ "version": "0.0.1",
179
+ "type": "module",
180
+ "scripts": {
181
+ "dev": "vite",
182
+ "build": "tsc --noEmit && vite build"
183
+ },
184
+ "dependencies": {
185
+ "react": "^19.2",
186
+ "react-dom": "^19.2",
187
+ "@sanity/ui": "alpha",
188
+ "@sanity/icons": "^5.2.1"
189
+ },
190
+ "devDependencies": {
191
+ "typescript": "^5",
192
+ "vite": "^6",
193
+ "@vitejs/plugin-react": "^4",
194
+ "@types/react": "^19",
195
+ "@types/react-dom": "^19"
196
+ }
197
+ }
198
+ ```
199
+
200
+ **`vite.config.ts`**
201
+
202
+ ```ts
203
+ import { defineConfig } from 'vite'
204
+ import react from '@vitejs/plugin-react'
205
+
206
+ export default defineConfig({
207
+ plugins: [react()],
208
+ })
209
+ ```
210
+
211
+ **`tsconfig.json`**:
212
+
213
+ ```json
214
+ {
215
+ "compilerOptions": {
216
+ "target": "ES2022",
217
+ "lib": ["DOM", "DOM.Iterable", "ES2022"],
218
+ "module": "esnext",
219
+ "moduleResolution": "bundler",
220
+ "jsx": "react-jsx",
221
+ "strict": true,
222
+ "esModuleInterop": true,
223
+ "skipLibCheck": true,
224
+ "resolveJsonModule": true,
225
+ "isolatedModules": true,
226
+ "moduleDetection": "force"
227
+ },
228
+ "include": ["src", "app"]
229
+ }
230
+ ```
231
+ - kind: section
232
+ for: all
233
+ freeform:
234
+ - title: Package version note
235
+ body: |-
236
+ These docs track the current `@sanity/ui` v5 alpha line. The package is pre-1.0 and still changing. The docs may describe components or props that your installed copy does not yet export. To list what your copy ships:
237
+ ```shell node -e "console.log(Object.keys(require('@sanity/ui')))" ```
238
+ When a doc and your installed package disagree, the package wins. Treat the docs as forward-looking.