@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,169 @@
|
|
|
1
|
+
# Props and imports
|
|
2
|
+
|
|
3
|
+
Read this file when you write props, space or size elements, or import icons.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- Value types: spacing, sizing, and scales
|
|
8
|
+
- Which component accepts which prop
|
|
9
|
+
- Prop names that people get wrong
|
|
10
|
+
- Responsive arrays
|
|
11
|
+
- Color and tokens
|
|
12
|
+
- Imports
|
|
13
|
+
- Things to leave alone
|
|
14
|
+
|
|
15
|
+
## Value types: spacing, sizing, and scales
|
|
16
|
+
|
|
17
|
+
Spacing and sizing take different value types. Both are correct on the same element:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
<Box padding={2} width="300px" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Kind | Props | Value | Example |
|
|
24
|
+
| -------------- | ------------------------------------------------------------------- | -------------------------------- | ------------------- |
|
|
25
|
+
| Spacing | `padding`, `margin`, `gap`, `rowGap`, `columnGap` | Integer step, 0 to 9 | `padding={3}` |
|
|
26
|
+
| Position | `top`, `right`, `bottom`, `left`, `inset` | Integer step 0 to 9, or `"auto"` | `top={0}` |
|
|
27
|
+
| Sizing | `width`, `height`, `minWidth`, `maxWidth`, `minHeight`, `maxHeight` | CSS string, including `"0"` | `width="140px"` |
|
|
28
|
+
| Flex values | `flexGrow`, `flexShrink` | Number | `flexGrow={1}` |
|
|
29
|
+
| Flex basis | `flexBasis` | CSS string | `flexBasis="260px"` |
|
|
30
|
+
| Radius | `radius` | Step 0 to 6, or `"full"` | `radius={2}` |
|
|
31
|
+
| Shadow | `shadow` | Step 0 to 5 | `shadow={1}` |
|
|
32
|
+
| Type size | `size` on Text (0 to 4), Heading (0 to 5), Code, Eyebrow | Step | `size={1}` |
|
|
33
|
+
| Icon size | `size` on Icon (0 to 4) | Step | `size={2}` |
|
|
34
|
+
| Container size | `size` on Container (0 to 5) | Step | `size={3}` |
|
|
35
|
+
| Tone | `tone` | Key | `tone="critical"` |
|
|
36
|
+
|
|
37
|
+
Things that fail:
|
|
38
|
+
|
|
39
|
+
- `padding="2"` is a type error. A string is not a step.
|
|
40
|
+
- `padding` does not take pixels. The scale is not linear. `top={4}` is step 4, not four pixels.
|
|
41
|
+
- `width={140}` is a type error. Write `width="140px"`.
|
|
42
|
+
- `flexGrow={true}` is a type error. Pass a number.
|
|
43
|
+
- `<Text size={20}>` is a type error. Size is a step.
|
|
44
|
+
- A hex color or any CSS color in `tone` is a type error.
|
|
45
|
+
|
|
46
|
+
The flexbox shrink idiom mixes both types. Write `<Flex flexGrow={1} minHeight="0">`. `flexGrow` is a number and `minHeight` is a string.
|
|
47
|
+
|
|
48
|
+
Choose `shadow` by the surface's role:
|
|
49
|
+
|
|
50
|
+
| Step | Use for |
|
|
51
|
+
| ---- | -------------------------------------- |
|
|
52
|
+
| 0 | A flat surface |
|
|
53
|
+
| 1 | A resting card |
|
|
54
|
+
| 2 | A hovered card or small raised element |
|
|
55
|
+
| 3 | A popover, dropdown, or menu |
|
|
56
|
+
| 4 | A modal or overlay |
|
|
57
|
+
| 5 | A top-layer surface |
|
|
58
|
+
|
|
59
|
+
Never write a `box-shadow` in `style`.
|
|
60
|
+
|
|
61
|
+
Read `docs/tokens/dtcg/json/` for the real values behind each step. Pass `space`, `radius`, `shadow`, `typography`, `font-family`, `font-weight`, `container`, `semantic`, or a color name such as `blue`.
|
|
62
|
+
|
|
63
|
+
## Which component accepts which prop
|
|
64
|
+
|
|
65
|
+
| Component | Accepts | Does not accept |
|
|
66
|
+
| --------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
67
|
+
| Box, Container, Flex, Grid | `padding`, `margin`, sizing, position, `border`, `overflow`, `tone`, `shadow`, `radius` | Text styles |
|
|
68
|
+
| Box | The props above | `flexDirection`, `alignItems`, `justifyContent`, `flexWrap` (these belong to Flex) |
|
|
69
|
+
| Card | `density`, `tone`, `as` | `padding`, `gap`, `radius`, `flexGrow`, `minWidth`, `overflow`, `onClick` |
|
|
70
|
+
| VStack, HStack | `as`, `gap` | Everything else |
|
|
71
|
+
| Text | `size`, `weight`, `tone`, `muted`, `truncate`, `trim`, margin props | Other layout props |
|
|
72
|
+
| Heading | `as` (required), `size`, `tone`, `truncate`, `trim`, margin props | `weight`, `muted`, other layout props |
|
|
73
|
+
| Button, IconButton | Their own props, plus native button attributes | `padding`, `margin`, `width`, `height`, `flexGrow`, `alignSelf` |
|
|
74
|
+
| Icon | `icon`, `size`, `tone`, `aria-label` | Layout props |
|
|
75
|
+
| TextInput, TextArea, Select | `density`, `hasError`, native attributes | `fontSize`, `padding`, `radius`, `space`, `customValidity`, icons or slots on TextInput |
|
|
76
|
+
| Checkbox, Radio, Switch | Native input attributes (Checkbox and Switch also take `hasError`) | `label`, margin props |
|
|
77
|
+
|
|
78
|
+
When a component rejects a prop, wrap it in a `Box` or `Flex` and put the prop there.
|
|
79
|
+
|
|
80
|
+
Do not wrap a component in a `Box` only to add spacing the component withholds. That repeats the override one level out. Pick the nearest value the component offers.
|
|
81
|
+
|
|
82
|
+
Key props by component, as of alpha.20:
|
|
83
|
+
|
|
84
|
+
- **Button:** `text`, `level` (`primary`, `secondary`, `tertiary`), `tone` (`neutral`, `critical`), `iconStart`, `iconEnd`, `loading`, `density` (`regular`, `loose`), `fullWidth`, `as`.
|
|
85
|
+
- **IconButton:** `icon` and `aria-label`, both required, plus `level`, `tone`, `loading`, `density`.
|
|
86
|
+
- **Badge:** `text`, `iconStart`, `tone`.
|
|
87
|
+
- **Dialog:** `open`, `onClose`, `header`, `size`.
|
|
88
|
+
- **Tooltip:** `content`, `placement`, `portal`, and one child.
|
|
89
|
+
- **Tabs:** `value` and `onValueChange` on `Tabs`. `value` on each `Tabs.Tab` and `Tabs.Panel`.
|
|
90
|
+
- **Link:** `href`, `openInNewTab`, `underlined`.
|
|
91
|
+
- **Avatar:** `name` (required), `src`, `size` (0 to 2), `color`.
|
|
92
|
+
- **List.ButtonItem:** `selected`, `as`, `density`, `start`, `end`.
|
|
93
|
+
|
|
94
|
+
Read `docs/components/<id>.dsds.yaml` for the full list and the rules for each.
|
|
95
|
+
|
|
96
|
+
## Prop names that people get wrong
|
|
97
|
+
|
|
98
|
+
| Component | Wrong | Right |
|
|
99
|
+
| --------------------------- | --------------------------------------------- | -------------------------------------------------------------------------------- |
|
|
100
|
+
| Flex | `direction`, `align`, `justify`, `wrap` | `flexDirection`, `alignItems`, `justifyContent`, `flexWrap` |
|
|
101
|
+
| Grid | `columns`, `rows`, `autoRows`, `gapX`, `gapY` | `gridTemplateColumns`, `gridTemplateRows`, `gridAutoRows`, `columnGap`, `rowGap` |
|
|
102
|
+
| Icon | `symbol`, `as={SomeIcon}` | `icon={SomeIcon}` |
|
|
103
|
+
| Tooltip | `text`, `trigger` | `content`, with the trigger as the child |
|
|
104
|
+
| Container | `width={3}` | `size={3}` |
|
|
105
|
+
| IconButton | `label`, `size` | `aria-label` (it has no `size`) |
|
|
106
|
+
| SkipToContent | `hash` | `href="#main-content"` and `label` |
|
|
107
|
+
| Button | `tone="primary"`, `"positive"`, `"caution"` | `level="primary"`, and `tone` of `neutral` or `critical` only |
|
|
108
|
+
| Stack (v3) | `space` | `VStack` with `gap` |
|
|
109
|
+
| Heading | `as="p"` or `as="div"` | `as` of `h1` to `h6` only |
|
|
110
|
+
| Select, TextInput, TextArea | `customValidity`, `fontSize`, `padding` | `hasError`, `density` |
|
|
111
|
+
|
|
112
|
+
Set `as` on every Heading. Without it, Heading renders an `<h2>`, whatever the context.
|
|
113
|
+
|
|
114
|
+
Do not write a prop at its default value. `<Card density="regular">` renders the same as `<Card>`.
|
|
115
|
+
|
|
116
|
+
Avoid spreading props from a loosely typed object:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
const p: Record<string, unknown> = {direction: 'row'}
|
|
120
|
+
<Flex {...p} /> // skips type checking; the wrong name does nothing
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
If a new prop has no visible effect, look for a spread like this first.
|
|
124
|
+
|
|
125
|
+
## Responsive arrays
|
|
126
|
+
|
|
127
|
+
A responsive array has up to six slots, one per breakpoint: `[base, 360px, 600px, 900px, 1200px, 1800px]`. Each value applies from that `min-width` up. Slots past the sixth are ignored.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<Flex flexDirection={['column', undefined, 'row']} gap={[2, undefined, 3]} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
An `undefined` slot behaves in one of two ways:
|
|
134
|
+
|
|
135
|
+
- For step and keyword props, such as `padding` and `flexDirection`, it keeps the previous breakpoint's value.
|
|
136
|
+
- For CSS string and number props, such as `width`, `flexBasis`, and `gridTemplateColumns`, it resets the value. Write every slot up to the last one you set.
|
|
137
|
+
|
|
138
|
+
## Color and tokens
|
|
139
|
+
|
|
140
|
+
- Use `tone` for meaning. Do not pass colors.
|
|
141
|
+
- In custom markup that no component covers, use the semantic custom properties. They follow light and dark mode on their own:
|
|
142
|
+
- `var(--background-low)` for a surface
|
|
143
|
+
- `var(--foreground-high)` and `var(--foreground-low)` for text
|
|
144
|
+
- `var(--separator-low)` for a border
|
|
145
|
+
- The names `--card-border-color`, `--card-bg-color`, and `--card-fg-color` do not exist. A declaration that uses them does nothing.
|
|
146
|
+
- Do not override a component's own color, spacing, or radius through custom properties. They let custom markup match the system. They do not restyle its components.
|
|
147
|
+
- Light and dark colors resolve through the CSS `light-dark()` function.
|
|
148
|
+
|
|
149
|
+
## Imports
|
|
150
|
+
|
|
151
|
+
```tsx
|
|
152
|
+
import {Box, Button, Card, Flex, List, Text} from '@sanity/ui'
|
|
153
|
+
import {SearchIcon} from '@sanity/icons/Search'
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- Import each icon from its own path. The path drops the `Icon` suffix: `@sanity/icons/Search`.
|
|
157
|
+
- Do not import an icon from `@sanity/icons`. The root ships a type-only stub. The import passes `tsc` and fails in the browser.
|
|
158
|
+
- To choose an icon, search `docs/icons.dsds.yaml` by purpose. It lists every icon with its import path and other names.
|
|
159
|
+
- Import `List` alone and use `List.Item`, `List.ItemText`, `List.ItemImage`, and `List.ButtonItem`. `ListItem` is not an export.
|
|
160
|
+
- Tabs works the same way: `Tabs`, `Tabs.List`, `Tabs.Tab`, `Tabs.Panel`.
|
|
161
|
+
- v5 has no `ThemeProvider`, no `studioTheme`, and no runtime scheme toggle. Importing them is a type error.
|
|
162
|
+
|
|
163
|
+
## Things to leave alone
|
|
164
|
+
|
|
165
|
+
- Do not restyle a design system component with `style={{…}}` or `className`. Inline styles skip the token system, break in dark mode, and drift from other instances.
|
|
166
|
+
- Use `style` only for a value with no prop path. Examples are a transform, a gradient, an aspect ratio, or a custom property. On a native element with no Sanity UI equivalent, such as `<table>` or `<fieldset>`, `style` is correct.
|
|
167
|
+
- Do not use `as` to turn a layout primitive into a `button`, `dialog`, `select`, `details`, `summary`, or `fieldset`. They do not meet the keyboard, focus, and ARIA needs of those elements.
|
|
168
|
+
- Do not use inline text styles. Box, Container, Flex, and Grid set no font size, weight, or color. Use Text or Heading.
|
|
169
|
+
- Reach for the component before the native element: `Text` for `p` and `span`, `Heading` for `h1` to `h6`, `Button` for `button`, `Link` for `a`, `List` for `ul`, and `Divider` for `hr`.
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Setting up Sanity UI 5
|
|
2
|
+
|
|
3
|
+
Read this file when you create a project, fix an unstyled page, fix a build error, or check versions.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- Requirements
|
|
8
|
+
- Fast path: the setup CLI
|
|
9
|
+
- Install by hand
|
|
10
|
+
- The entry file
|
|
11
|
+
- Project files
|
|
12
|
+
- Check what your copy exports
|
|
13
|
+
- Common failures
|
|
14
|
+
|
|
15
|
+
## Requirements
|
|
16
|
+
|
|
17
|
+
| Need | Value |
|
|
18
|
+
| ------------------- | ----------------------------------------------------------- |
|
|
19
|
+
| React and React DOM | `^19.2` |
|
|
20
|
+
| Node | `>=20.19 <22` or `>=22.12` (22.0 to 22.11 is not supported) |
|
|
21
|
+
| TypeScript | 5 or later, with `"moduleResolution": "bundler"` |
|
|
22
|
+
| `@sanity/icons` | 5.2.1 or later |
|
|
23
|
+
|
|
24
|
+
`@sanity/icons` and `react-refractor` install on their own as dependencies of `@sanity/ui`. Add `@sanity/icons` to your own `package.json` only when your code imports icons.
|
|
25
|
+
|
|
26
|
+
## Fast path: the setup CLI
|
|
27
|
+
|
|
28
|
+
The package ships a setup CLI. It writes the dependencies, the stylesheet import, and `tsconfig.json`.
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx sanity-ui doctor # check the project and list fixes
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Flags: `--dry` (print the plan only), `--yes` or `-y` (accept every default), `--cwd <dir>` (run in another folder).
|
|
35
|
+
|
|
36
|
+
Run `doctor` before you inspect an entry file by hand. It checks the stylesheet import, `tsconfig.json`, the install state of the packages, and the React and Node versions in one pass.
|
|
37
|
+
|
|
38
|
+
## Install by hand
|
|
39
|
+
|
|
40
|
+
Install the v5 line with the `alpha` tag, or with the exact version you were given.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
npm install @sanity/ui@alpha @sanity/icons
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Never install the bare name `@sanity/ui`. Its `latest` tag points to the UI 4 line, and it resolves to the wrong major with no error.
|
|
47
|
+
|
|
48
|
+
For a React 18 project, add overrides to `package.json` before you install:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{"overrides": {"react": "^19.2", "react-dom": "^19.2"}}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Use `--legacy-peer-deps` only when overrides are not an option. A bare install in a React 18 project fails with `ERESOLVE`.
|
|
55
|
+
|
|
56
|
+
Add these to `devDependencies`: `typescript`, `@types/react`, `@types/react-dom`, and in a Vite project `@vitejs/plugin-react`.
|
|
57
|
+
|
|
58
|
+
## The entry file
|
|
59
|
+
|
|
60
|
+
Put both imports in the app's entry file, the polyfills first.
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import '@sanity/ui/polyfills'
|
|
64
|
+
import '@sanity/ui/styles.css'
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Each line has a job:
|
|
68
|
+
|
|
69
|
+
- **The stylesheet is required.** Without it every component renders as plain HTML, and nothing reports an error.
|
|
70
|
+
- **The polyfills are required for Tooltip and Dialog.** Tooltips never show in browsers without the Interest Invokers API. A Dialog backdrop click stops closing the dialog in Safari. Escape and the close button still work.
|
|
71
|
+
- **The stylesheet goes before your own CSS.** Sanity UI puts only its global reset in a cascade layer, `sui.global`. Your CSS overrides the reset. Component styles are not layered. At equal specificity, the stylesheet imported later wins.
|
|
72
|
+
|
|
73
|
+
Write the path as `@sanity/ui/styles.css`. The forms `@sanity/ui/dist/styles.css` and `@sanity/ui/styles` fail at the dev server. The page never renders and no console error explains why.
|
|
74
|
+
|
|
75
|
+
Set `lang="en"` on the `<html>` element in `index.html`.
|
|
76
|
+
|
|
77
|
+
v5 needs no provider. There is no `ThemeProvider`.
|
|
78
|
+
|
|
79
|
+
## Project files
|
|
80
|
+
|
|
81
|
+
For a new Vite project, start from these files.
|
|
82
|
+
|
|
83
|
+
`package.json`
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"name": "my-app",
|
|
88
|
+
"private": true,
|
|
89
|
+
"version": "0.0.1",
|
|
90
|
+
"type": "module",
|
|
91
|
+
"scripts": {
|
|
92
|
+
"dev": "vite",
|
|
93
|
+
"build": "tsc --noEmit && vite build"
|
|
94
|
+
},
|
|
95
|
+
"dependencies": {
|
|
96
|
+
"react": "^19.2",
|
|
97
|
+
"react-dom": "^19.2",
|
|
98
|
+
"@sanity/ui": "alpha",
|
|
99
|
+
"@sanity/icons": "^5.2.1"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"typescript": "^5",
|
|
103
|
+
"vite": "^6",
|
|
104
|
+
"@vitejs/plugin-react": "^4",
|
|
105
|
+
"@types/react": "^19",
|
|
106
|
+
"@types/react-dom": "^19"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
`vite.config.ts`
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import {defineConfig} from 'vite'
|
|
115
|
+
import react from '@vitejs/plugin-react'
|
|
116
|
+
|
|
117
|
+
export default defineConfig({
|
|
118
|
+
plugins: [react()],
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`tsconfig.json`: write it first, as written. It is the file the CLI writes.
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"compilerOptions": {
|
|
127
|
+
"target": "ES2022",
|
|
128
|
+
"lib": ["DOM", "DOM.Iterable", "ES2022"],
|
|
129
|
+
"module": "esnext",
|
|
130
|
+
"moduleResolution": "bundler",
|
|
131
|
+
"jsx": "react-jsx",
|
|
132
|
+
"strict": true,
|
|
133
|
+
"esModuleInterop": true,
|
|
134
|
+
"skipLibCheck": true,
|
|
135
|
+
"resolveJsonModule": true,
|
|
136
|
+
"isolatedModules": true,
|
|
137
|
+
"moduleDetection": "force"
|
|
138
|
+
},
|
|
139
|
+
"include": ["src", "app"]
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Rules for this file:
|
|
144
|
+
|
|
145
|
+
- Keep `"jsx": "react-jsx"`. Without it, every component fails with `TS17004`.
|
|
146
|
+
- Keep `"app"` in `include`, even with no `app` folder. A missing folder is not an error while `src` has files.
|
|
147
|
+
- Add no other `compilerOptions` keys. An unknown key fails the build with `TS5023`.
|
|
148
|
+
- Do not change the file to fix a build. The cause is usually in `src/`.
|
|
149
|
+
- Do not run a bare `tsc`. The config has no `noEmit`. It writes `.js` files beside your sources, and Vite loads those. Type-check with `tsc --noEmit`.
|
|
150
|
+
|
|
151
|
+
Other toolchains, such as Next.js or Remix, keep their own `tsconfig.json`. The two imports still go in the app's entry file.
|
|
152
|
+
|
|
153
|
+
## Check what your copy exports
|
|
154
|
+
|
|
155
|
+
The docs can describe components your installed copy does not export yet. List the real exports:
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
node -e "console.log(Object.keys(require('@sanity/ui')))"
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
To check an export, run `node -e "console.log(Object.keys(require('@sanity/ui')))"` in the project. The list is the installed package's export list. If a doc and the package disagree, the package wins.
|
|
162
|
+
|
|
163
|
+
## Common failures
|
|
164
|
+
|
|
165
|
+
| Symptom | Cause | Fix |
|
|
166
|
+
| ---------------------------------------------- | ------------------------------ | -------------------------------------------------- |
|
|
167
|
+
| Page renders as plain HTML, no error | Missing `styles.css` import | Add both entry imports |
|
|
168
|
+
| Dev server fails and the page never renders | Wrong stylesheet path | Use `@sanity/ui/styles.css` |
|
|
169
|
+
| Tooltip never appears | Missing polyfills import | Import `@sanity/ui/polyfills` above the stylesheet |
|
|
170
|
+
| `TS17004` on every component | Missing `"jsx": "react-jsx"` | Restore the `tsconfig.json` above |
|
|
171
|
+
| `TS7016` for `react` | Missing `@types/react` | Add `@types/react` and `@types/react-dom` |
|
|
172
|
+
| `TS5023: Unknown compiler option` | Invented `compilerOptions` key | Remove it |
|
|
173
|
+
| `ERR_MODULE_NOT_FOUND` on `dev` | Missing `@vitejs/plugin-react` | Add it to `devDependencies` |
|
|
174
|
+
| `ERESOLVE` on install | React 18 project | Add overrides, or `--legacy-peer-deps` |
|
|
175
|
+
| `.js` files appear beside `.tsx` files | Bare `tsc` | Delete them, then run `tsc --noEmit` |
|
|
176
|
+
| Icon import passes `tsc`, fails in the browser | Import from the package root | Import from `@sanity/icons/<Name>` |
|
|
177
|
+
| Component imports fail as unavailable | Component is not exported yet | See `components.md` |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Silent failures — the catalog
|
|
2
|
+
|
|
3
|
+
This file is the catalog. These patterns fail with no error, warning, or type feedback. When a layout breaks or a style goes missing with zero console output, check here first. Wrong props on Sanity UI 5 components are mostly type errors. Run `tsc --noEmit` before you read this list.
|
|
4
|
+
|
|
5
|
+
| # | Trigger | Symptom | Fix |
|
|
6
|
+
| --- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| 1 | No `as` on `Heading` in v3 code, where the default was `<div>` | In v5 this is a type error. Ported code that skips `as` fails `tsc` | Set `as` to the level. Use `size` for the visual size. |
|
|
8
|
+
| 2 | v3 props on v5 components, such as `direction` on Flex or `space` on Stack | v5 reports most of these as type errors. Props that reach the DOM can be ignored | Migrate each prop. See `migrating-from-v3.md` |
|
|
9
|
+
| 3 | No `import '@sanity/ui/styles.css'` in `main.tsx` | Every component renders as unstyled HTML | Add the import to `main.tsx` |
|
|
10
|
+
| 4 | A `var(--tone-*)` variable, such as `--tone-surface`, which no version defines | The value resolves to nothing; background or border is invisible | Use `var(--background-low)`, `var(--separator-low)`, or `var(--foreground-high)`. They work everywhere and follow the nearest tone |
|
|
11
|
+
| 5 | A single-quoted string with an apostrophe | A Vite build error that is easy to miss | Use a template literal or double quotes |
|
|
12
|
+
| 6 | A tone value the component does not accept, such as `default` on Text or `positive` on Button | A type error in v5 | See `tone-and-color.md` for the values each component takes |
|
|
13
|
+
|
|
14
|
+
## Caught by the type checker
|
|
15
|
+
|
|
16
|
+
These are not silent in Sanity UI 5. `tsc --noEmit` reports a type error for each one.
|
|
17
|
+
|
|
18
|
+
- Layout props on `Card`, such as `flexGrow`, `minWidth`, `overflow`, or `padding`. Wrap the Card in `Box` or `Flex`: `<Box flexGrow={1}><Card /></Box>`.
|
|
19
|
+
- `flexGrow`, `flexShrink`, or `flexBasis` on `VStack` or `HStack`. Use `<Flex flexDirection="column" gap={3}>`, or wrap the stack in `<Box flexGrow={1}>`.
|
|
20
|
+
- A `Heading` with no `as`. Set `as` to `h1` through `h6`.
|
|
21
|
+
- A tone the component does not take, such as `tone="default"` on Text or `tone="positive"` on Button.
|
|
22
|
+
|
|
23
|
+
If your project does not run the type checker, run it. Without it, these look like silent failures.
|
|
24
|
+
|
|
25
|
+
## The diagnostic habit
|
|
26
|
+
|
|
27
|
+
When something looks wrong and there is no error:
|
|
28
|
+
|
|
29
|
+
- Did you run `tsc --noEmit`? It catches layout props on `Card` and flex props on `VStack` and `HStack`.
|
|
30
|
+
- Is `Heading` missing an `as`? Add it.
|
|
31
|
+
- Are layout primitives imported from the v3 line? Switch to v5.
|
|
32
|
+
- Is `styles.css` imported in `main.tsx`? Add it.
|
|
33
|
+
- Is a `var(--tone-*)` variable in the code? No version defines it. Use `var(--background-low)` or a similar semantic variable.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Taste: judgment for Sanity UI 5
|
|
2
|
+
|
|
3
|
+
Read this file when you choose a tone, set density or spacing, pick between two components that both work, or review UI for quality. The docs say what is correct. This file says what is good.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- The Sanity stance
|
|
8
|
+
- Tone and color
|
|
9
|
+
- Spacing and density
|
|
10
|
+
- Component choice
|
|
11
|
+
- Build with the grain
|
|
12
|
+
- When the docs and this file disagree
|
|
13
|
+
|
|
14
|
+
## The Sanity stance
|
|
15
|
+
|
|
16
|
+
- **Restraint is the discipline.** There is one good way to do a thing, not five. When two patterns both work, the simpler one is the Sanity one. Range comes from composing primitives, not from reaching for more components.
|
|
17
|
+
- **The base is a white wall.** A near-monochrome base makes one bold move count. Ration the accent. A toned or colored element should mean something. If everything is colored, nothing reads.
|
|
18
|
+
- **The system fails quietly in a few places.** A missing stylesheet import leaves the page unstyled. A prop spread from a loosely typed object skips type checking. Most other wrong props are type errors in v5, so `tsc --noEmit` catches them. Knowing what each primitive accepts is the discipline. `silent-failures.md` lists the rest.
|
|
19
|
+
- **Primitives do one job.** `Box` handles spacing, border, tone, and radius. It does not handle flex or clicks. `VStack` and `HStack` expose only `as` and `gap`. When you need more, step up to `Flex` or compose. Do not force a prop onto a primitive that ignores it.
|
|
20
|
+
|
|
21
|
+
Generic output is the usual failure here, not breakage. The output is correct and consistent, but it looks like everything else. Aim past that.
|
|
22
|
+
|
|
23
|
+
## Tone and color
|
|
24
|
+
|
|
25
|
+
Use a tone for its meaning, not for a raw color. The five semantic tones are `neutral`, `positive`, `suggest`, `caution`, and `critical`.
|
|
26
|
+
|
|
27
|
+
- **`suggest` is the AI-hint tone.** Use it when the UI marks something the agent produced or proposed.
|
|
28
|
+
- **Tone values differ by component.** Card, Box, Flex, Grid, and Container also take `default`. Button takes only `neutral` and `critical`. A wrong tone is a type error. The full table is in `tone-and-color.md`.
|
|
29
|
+
- **Ration the accent.** Default to neutral surfaces. Spend color where it carries weight.
|
|
30
|
+
|
|
31
|
+
## Spacing and density
|
|
32
|
+
|
|
33
|
+
- **The spacing scale is integers 0 to 9.** Spacing props (`padding`, `margin`, `gap`) take an integer step. Sizing props (`width`, `maxWidth`) take a CSS string. Mixing the two is a type error.
|
|
34
|
+
- **Density over padding on Card.** Card spacing comes from `density` (`compact`, `regular`, `loose`). Pick density by how much information the surface holds, not by nudging pixels. `padding` on a Card is a type error.
|
|
35
|
+
|
|
36
|
+
## Component choice
|
|
37
|
+
|
|
38
|
+
Picking the right component is taste. The wrong one still renders, and nothing flags it. `component-choice.md` has the full matrix. The main calls:
|
|
39
|
+
|
|
40
|
+
- **`data-table` or `sortable-data-table`.** Read-only display uses `data-table`. Clickable or selectable rows use `sortable-data-table`.
|
|
41
|
+
- **`VStack` or `HStack` or `Flex`.** A simple stack with a gap uses `VStack` or `HStack`. A flex child that grows or shrinks uses `Flex`, or a `Box` around the stack.
|
|
42
|
+
- **`Box` or `Card`.** Card is a toned surface with its own density. Layout props belong on a `Box` wrapping the Card, never on the Card.
|
|
43
|
+
- **`Button`, never `Box as="button"`.** `Box as="button"` keeps browser defaults with no prop to reset them.
|
|
44
|
+
|
|
45
|
+
## Build with the grain
|
|
46
|
+
|
|
47
|
+
- **Props over inline styles.** Every visual attribute with a prop uses the prop. Inline styles skip the spacing scale, break dark mode, and ignore responsive arrays. Use `style` only for values with no prop, such as `gridTemplateAreas` or `clipPath`, and on native elements like a raw `<table>`.
|
|
48
|
+
- **Set `as` on every Heading.** A Heading with no `as` breaks the document outline. Set `as` for the level. Use `size` for the visual size.
|
|
49
|
+
- **Build accessibility in.** Every input gets a label. Never nest clickable elements. A Card with `onClick` must not contain a Button. These rules apply on the first build, not at review.
|
|
50
|
+
|
|
51
|
+
## When the docs and this file disagree
|
|
52
|
+
|
|
53
|
+
The installed package's `docs/` folder is the source of what exists: the components, the props, and the rules. This file is the judgment for using them well. If a value here and a document disagree, the installed package wins. The judgment in this file still holds.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Tone and color: full reference
|
|
2
|
+
|
|
3
|
+
Read this file when you choose a tone or set a color. The values below were checked against `@sanity/ui` 5.0.0-alpha.22.
|
|
4
|
+
|
|
5
|
+
## The five semantic tones
|
|
6
|
+
|
|
7
|
+
Each tone carries a meaning. Use the meaning, not a raw color.
|
|
8
|
+
|
|
9
|
+
| Intent | Tone |
|
|
10
|
+
| -------------------------- | ---------- |
|
|
11
|
+
| Neutral surface or default | `neutral` |
|
|
12
|
+
| Success | `positive` |
|
|
13
|
+
| Suggestion or AI hint | `suggest` |
|
|
14
|
+
| Warning | `caution` |
|
|
15
|
+
| Error or destructive | `critical` |
|
|
16
|
+
|
|
17
|
+
`suggest` is the tone for content the agent produced or proposed. Reach for it when the UI marks an AI hint.
|
|
18
|
+
|
|
19
|
+
## Which component takes which tone
|
|
20
|
+
|
|
21
|
+
Tone values are not the same across components. A tone the component does not take is a type error in v5.
|
|
22
|
+
|
|
23
|
+
| Components | Tones accepted |
|
|
24
|
+
| ---------------------------------------------- | ------------------------------------------------------------------ |
|
|
25
|
+
| Card, Box, Flex, Grid, Container | `default`, `neutral`, `positive`, `suggest`, `caution`, `critical` |
|
|
26
|
+
| Text, Heading, Icon, Eyebrow, Badge, Indicator | `neutral`, `positive`, `suggest`, `caution`, `critical` |
|
|
27
|
+
| Button | `neutral`, `critical` |
|
|
28
|
+
|
|
29
|
+
`default` on the layout surfaces paints the page backdrop. Use `neutral` for a plain surface.
|
|
30
|
+
|
|
31
|
+
v3 used `default` for neutral on `Button` and `Badge`. Replace it with `neutral` when you port code. The tone names are the same across the other components.
|
|
32
|
+
|
|
33
|
+
## Watch the seams
|
|
34
|
+
|
|
35
|
+
- `tone="default"` on `Text`, `Heading`, `Icon`, `Badge`, or `Eyebrow` is a type error. Use `neutral`.
|
|
36
|
+
- `tone="positive"`, `"caution"`, or `"suggest"` on `Button` is a type error. Button takes `neutral` and `critical` only.
|
|
37
|
+
- A toned Badge, Text, or Heading should lead with the state in its words, or carry an icon. A tone alone is not enough.
|
|
38
|
+
|
|
39
|
+
## Color restraint
|
|
40
|
+
|
|
41
|
+
- The base is near-monochrome on purpose. A restrained base makes one accent count.
|
|
42
|
+
- A toned or colored element should mean something. If everything is colored, nothing reads.
|
|
43
|
+
- Default to neutral surfaces. Spend color where it carries weight.
|
|
44
|
+
|
|
45
|
+
## Semantic variables for custom markup
|
|
46
|
+
|
|
47
|
+
When no component covers a case, use the semantic variables. They resolve everywhere and follow the nearest tone:
|
|
48
|
+
|
|
49
|
+
- `var(--background-low)` for a surface
|
|
50
|
+
- `var(--separator-low)` for a border
|
|
51
|
+
- `var(--foreground-high)` and `var(--foreground-low)` for text
|
|
52
|
+
|
|
53
|
+
Toned elements set these variables for their children. A toned Card therefore sets its own surface and text colors on its own.
|
|
54
|
+
|
|
55
|
+
The names `--tone-surface` and `--tone-separator` are not defined by any version. A declaration that uses them does nothing.
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is generated by scripts/write-version.js. Do not edit.
|
|
2
|
-
export const VERSION = '
|
|
3
|
-
export const HASH = '
|
|
2
|
+
export const VERSION = '500alpha23'
|
|
3
|
+
export const HASH = '79941a'
|