@sanity/ui 5.0.0-alpha.21 → 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 +6 -3
- 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/css/classes/system/shadow.css +45 -0
- package/src/version.ts +2 -2
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
kind: sanity.guide
|
|
2
|
+
id: quick-start
|
|
3
|
+
name: Quick start
|
|
4
|
+
description: A step-by-step tutorial for building a three-region admin interface with Sanity UI, covering layout, accessibility, and key component patterns.
|
|
5
|
+
metadata:
|
|
6
|
+
tags:
|
|
7
|
+
- getting-started
|
|
8
|
+
- layout
|
|
9
|
+
- accessibility
|
|
10
|
+
- tutorial
|
|
11
|
+
- Box
|
|
12
|
+
- Flex
|
|
13
|
+
- Card
|
|
14
|
+
- Container
|
|
15
|
+
- VStack
|
|
16
|
+
- admin interface
|
|
17
|
+
- sidebar
|
|
18
|
+
- toolbar
|
|
19
|
+
status:
|
|
20
|
+
status: stable
|
|
21
|
+
sections:
|
|
22
|
+
- kind: guidelines
|
|
23
|
+
for: all
|
|
24
|
+
framing: how-to-use
|
|
25
|
+
items:
|
|
26
|
+
- level: must
|
|
27
|
+
statement: Place `SkipToContent` as the first focusable element in the layout, pointing to the main content region's `id`.
|
|
28
|
+
- level: must
|
|
29
|
+
statement: Never skip heading levels. Use one `<h1>` for the page title and `<h2>` for sidebar and card headings.
|
|
30
|
+
- refs:
|
|
31
|
+
- to: shared-foundations#container-inside-scroll-box
|
|
32
|
+
rel: same-as
|
|
33
|
+
- level: must
|
|
34
|
+
statement: Set `lang="en"` on the `<html>` element in `index.html` so screen readers can detect the page language (WCAG 3.1.1 A).
|
|
35
|
+
- level: must
|
|
36
|
+
statement: Add `flexWrap="wrap"` to every `Flex` with two or more children to prevent overflow at 320px.
|
|
37
|
+
- level: must
|
|
38
|
+
statement: Add `aria-label` to every icon-only button. A tooltip does not set an accessible name.
|
|
39
|
+
- level: should
|
|
40
|
+
statement: Use `VStack` for simple vertical lists with even spacing. Use `Flex flexDirection="column"` when you need `flexGrow`, `overflow`, `minHeight`, or full flex control.
|
|
41
|
+
- refs:
|
|
42
|
+
- to: shared-foundations#card-no-layout-props
|
|
43
|
+
rel: same-as
|
|
44
|
+
- level: must-not
|
|
45
|
+
statement: Do not add `Container` to app chrome (sidebar, toolbar). Use `Box` or `Flex` directly for those regions.
|
|
46
|
+
- refs:
|
|
47
|
+
- to: shared-foundations#card-not-for-structural-regions
|
|
48
|
+
rel: same-as
|
|
49
|
+
- kind: steps
|
|
50
|
+
for: all
|
|
51
|
+
ordered: true
|
|
52
|
+
title: Steps
|
|
53
|
+
items:
|
|
54
|
+
- title: 'Step 1: Create the outer shell'
|
|
55
|
+
description: |-
|
|
56
|
+
The outer shell is a `Flex` that fills the viewport. The sidebar and main area sit side by side. This assumes the project is set up as the `installation` guide shows: its `package.json`, `tsconfig.json` and entry file.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// src/App.tsx
|
|
60
|
+
import { useState } from 'react'
|
|
61
|
+
import { Box, Button, Flex, Heading, IconButton, SkipToContent } from '@sanity/ui'
|
|
62
|
+
import { MenuIcon } from '@sanity/icons/Menu'
|
|
63
|
+
|
|
64
|
+
const App = () => {
|
|
65
|
+
const [sidebarOpen, setSidebarOpen] = useState(true)
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Flex flexWrap="wrap" minHeight="100vh">
|
|
69
|
+
<SkipToContent href="#main-content" label="Skip to content" />
|
|
70
|
+
{sidebarOpen && (
|
|
71
|
+
<Box as="nav" aria-label="Main navigation" borderRight={[false, false, false, true]} flexBasis={['100%', '100%', '100%', '260px']} flexShrink={0}>
|
|
72
|
+
<Box padding={3}>
|
|
73
|
+
<Heading as="h2" size={1}>Studio</Heading>
|
|
74
|
+
</Box>
|
|
75
|
+
</Box>
|
|
76
|
+
)}
|
|
77
|
+
|
|
78
|
+
<Flex as="main" id="main-content" tabIndex={-1} flexBasis={['100%', '100%', '100%', '0']} flexDirection="column" flexGrow={1} minWidth="0" overflow="hidden">
|
|
79
|
+
<Box padding={3} borderBottom>
|
|
80
|
+
<Heading as="h1">All Documents</Heading>
|
|
81
|
+
</Box>
|
|
82
|
+
</Flex>
|
|
83
|
+
</Flex>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default App
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**What to notice:**
|
|
91
|
+
|
|
92
|
+
- `Box as="nav"` renders a `<nav>` element. Screen readers list it as a landmark.
|
|
93
|
+
- `Flex as="main"` renders a `<main>` element.
|
|
94
|
+
- `flexWrap="wrap"` on the outer Flex lets the sidebar stack above the content at narrow widths (WCAG 1.4.10).
|
|
95
|
+
- `minWidth="0"` on the main area prevents content from pushing the layout wider than the viewport.
|
|
96
|
+
- `as="h1"` on the page heading and `as="h2"` on the sidebar heading create a correct hierarchy.
|
|
97
|
+
- `SkipToContent` is the first focusable element. A keyboard user's first Tab press reveals it; activating it jumps focus to `#main-content`.
|
|
98
|
+
- title: 'Step 2: Add a toolbar with reflow'
|
|
99
|
+
description: |-
|
|
100
|
+
The toolbar holds the page title and an action button. Both wrap to separate lines on mobile.
|
|
101
|
+
|
|
102
|
+
Replace the `<Box padding={3} borderBottom>` inside `main` with:
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import { AddIcon } from '@sanity/icons/Add'
|
|
106
|
+
import { MenuIcon } from '@sanity/icons/Menu'
|
|
107
|
+
import { CloseIcon } from '@sanity/icons/Close'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
<Box padding={3} borderBottom>
|
|
112
|
+
<Flex alignItems="center" justifyContent="space-between" flexWrap="wrap" gap={2}>
|
|
113
|
+
<Flex alignItems="center" gap={3} minWidth="0">
|
|
114
|
+
{!sidebarOpen && (
|
|
115
|
+
<IconButton
|
|
116
|
+
level="tertiary"
|
|
117
|
+
icon={MenuIcon}
|
|
118
|
+
aria-label="Show navigation"
|
|
119
|
+
onClick={() => setSidebarOpen(true)}
|
|
120
|
+
/>
|
|
121
|
+
)}
|
|
122
|
+
<Heading truncate={1} as="h1">All Documents</Heading>
|
|
123
|
+
</Flex>
|
|
124
|
+
<Button text="New document" iconStart={AddIcon} />
|
|
125
|
+
</Flex>
|
|
126
|
+
</Box>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**What to notice:**
|
|
130
|
+
|
|
131
|
+
- `flexWrap="wrap"` is required on every `Flex` with two or more children. Without it the page overflows at 320px.
|
|
132
|
+
- `truncate={1}` on the Heading truncates long titles with an ellipsis.
|
|
133
|
+
- The `MenuIcon` button has `aria-label` because it has no visible text.
|
|
134
|
+
- Button `level` controls visual weight: `"primary"` is the default (solid, full visual weight).
|
|
135
|
+
- title: 'Step 3: Build the sidebar'
|
|
136
|
+
description: |-
|
|
137
|
+
Replace the sidebar placeholder with navigation links and a close button.
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { CloseIcon } from '@sanity/icons/Close'
|
|
141
|
+
import { Box, Flex, Heading, IconButton, Link, Text, VStack } from '@sanity/ui'
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
<Box as="nav" aria-label="Main navigation" borderRight={[false, false, false, true]} flexBasis={['100%', '100%', '100%', '260px']} flexShrink={0} overflowY="auto">
|
|
146
|
+
<VStack>
|
|
147
|
+
<Box padding={3} borderBottom>
|
|
148
|
+
<Flex alignItems="center" justifyContent="space-between">
|
|
149
|
+
<Heading as="h2" size={1}>Studio</Heading>
|
|
150
|
+
<IconButton
|
|
151
|
+
level="tertiary"
|
|
152
|
+
icon={CloseIcon}
|
|
153
|
+
aria-label="Close navigation"
|
|
154
|
+
onClick={() => setSidebarOpen(false)}
|
|
155
|
+
/>
|
|
156
|
+
</Flex>
|
|
157
|
+
</Box>
|
|
158
|
+
<Box padding={3}>
|
|
159
|
+
<VStack gap={3}>
|
|
160
|
+
<Link href="/documents">Documents</Link>
|
|
161
|
+
<Link href="/authors">Authors</Link>
|
|
162
|
+
<Link href="/settings">Settings</Link>
|
|
163
|
+
</VStack>
|
|
164
|
+
</Box>
|
|
165
|
+
</VStack>
|
|
166
|
+
</Box>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**What to notice:**
|
|
170
|
+
|
|
171
|
+
- `VStack` lays children out in a column with even `gap` spacing. It exposes only `as` and `gap`. For full flex control, use `Flex flexDirection="column"`.
|
|
172
|
+
- `Link` renders a native `<a>` element and inherits color from the container. It adds an underline by default — use `underlined={false}` to remove it for nav links.
|
|
173
|
+
- title: 'Step 4: Add document cards'
|
|
174
|
+
description: |-
|
|
175
|
+
Create a scrollable list of cards below the toolbar.
|
|
176
|
+
|
|
177
|
+
```tsx
|
|
178
|
+
import { Badge, Card, Container } from '@sanity/ui'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
const DOCUMENTS = [
|
|
183
|
+
{ title: 'Getting Started', status: 'Published' },
|
|
184
|
+
{ title: 'API Reference', status: 'Draft' },
|
|
185
|
+
{ title: 'Design Tokens', status: 'Published' },
|
|
186
|
+
]
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Add this below the toolbar `Box`, still inside the `main` Flex:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
<Box padding={4} flexGrow={1} overflowY="auto">
|
|
193
|
+
<Container>
|
|
194
|
+
<VStack gap={3}>
|
|
195
|
+
{DOCUMENTS.map((doc) => (
|
|
196
|
+
<Card key={doc.title}>
|
|
197
|
+
<Flex alignItems="center" justifyContent="space-between" flexWrap="wrap" gap={2}>
|
|
198
|
+
<VStack gap={2}>
|
|
199
|
+
<Heading as="h2">{doc.title}</Heading>
|
|
200
|
+
<Text as="p" size={1} muted>Last edited 2 hours ago</Text>
|
|
201
|
+
</VStack>
|
|
202
|
+
<Badge tone={doc.status === 'Published' ? 'positive' : 'caution'}>
|
|
203
|
+
{doc.status}
|
|
204
|
+
</Badge>
|
|
205
|
+
</Flex>
|
|
206
|
+
</Card>
|
|
207
|
+
))}
|
|
208
|
+
</VStack>
|
|
209
|
+
</Container>
|
|
210
|
+
</Box>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**What to notice:**
|
|
214
|
+
|
|
215
|
+
- `Container size={2}` caps the card list at the width of {container-2} and centers it. On a wide monitor the cards won't stretch edge to edge.
|
|
216
|
+
- `Container` goes inside the scroll `Box`, not around it. The `Box` handles `flexGrow` and `overflowY`; Container handles max-width only.
|
|
217
|
+
- Don't add Container to the sidebar or toolbar — those are app chrome and should fill their available width.
|
|
218
|
+
- `Card` is a content surface — it adds a background and border. Do not use it for structural regions like sidebars or toolbars.
|
|
219
|
+
- Layout props like `flexGrow` go on `Box`, not on `Card`. Passing one to Card is a TypeScript error.
|
|
220
|
+
- Each card heading is `as="h2"` because `as="h1"` is the page title above. Never skip heading levels.
|
|
221
|
+
- title: 'Step 5: Set the page language'
|
|
222
|
+
description: |-
|
|
223
|
+
In `index.html`, set `lang="en"` on the `<html>` element:
|
|
224
|
+
|
|
225
|
+
```html
|
|
226
|
+
<html lang="en">
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Without this, screen readers cannot detect the page language (WCAG 3.1.1 A).
|
|
230
|
+
- title: Run it
|
|
231
|
+
description: |-
|
|
232
|
+
```shell
|
|
233
|
+
npm run dev
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Open `http://localhost:5173`. You should see a sidebar with navigation links on the left and a document list on the right.
|
|
237
|
+
- kind: section
|
|
238
|
+
for: all
|
|
239
|
+
freeform:
|
|
240
|
+
- title: Overview
|
|
241
|
+
body: |-
|
|
242
|
+
This tutorial walks through building a three-region admin interface with Sanity UI. You will create a sidebar, a toolbar, and a content list — the same layout used in Sanity Studio.
|
|
243
|
+
|
|
244
|
+
**Before you start:** complete the steps in the `installation` guide. You should have `@sanity/ui@alpha` and `@sanity/icons` installed, plus a working entry file.
|
|
245
|
+
- title: What you will build
|
|
246
|
+
body: |-
|
|
247
|
+
A single-page app with:
|
|
248
|
+
|
|
249
|
+
- A collapsible sidebar (`<nav>`) with navigation links
|
|
250
|
+
- A toolbar with a page title and an action button
|
|
251
|
+
- A scrollable list of document cards with status badges
|
|
252
|
+
- Correct heading hierarchy, landmarks, keyboard access, and responsive reflow
|
|
253
|
+
- kind: section
|
|
254
|
+
for: all
|
|
255
|
+
freeform:
|
|
256
|
+
- title: What you built
|
|
257
|
+
body: |-
|
|
258
|
+
| Feature | How it works |
|
|
259
|
+
| :---- | :---- |
|
|
260
|
+
| Landmarks | `Box as="nav"` and `Flex as="main"` create `<nav>` and `<main>` for screen readers. |
|
|
261
|
+
| Responsive sidebar | `flexWrap="wrap"` on the outer Flex. At 320px the sidebar stacks above the content. |
|
|
262
|
+
| Toolbar reflow | `flexWrap="wrap"` on the toolbar Flex. Heading and button wrap at narrow widths. |
|
|
263
|
+
| Heading hierarchy | One `<h1>` for the page title. `<h2>` for sidebar and card headings. No skipped levels. |
|
|
264
|
+
| Page language | `<html lang="en">` in `index.html`. |
|
|
265
|
+
| Icon-only buttons | `aria-label` on every button without visible text. |
|
|
266
|
+
| Skip navigation | `SkipToContent` at the top of the layout. A keyboard user presses Tab to reveal it; activating it jumps focus to `#main-content`. |
|
|
267
|
+
| Navigation links | `Link` components in the sidebar. They render native `<a>` elements and inherit color from the container. |
|
|
268
|
+
- title: Key patterns
|
|
269
|
+
body: |-
|
|
270
|
+
### Box vs Flex vs Card vs Container
|
|
271
|
+
|
|
272
|
+
| Component | Use for | Adds a visual surface? |
|
|
273
|
+
| :---- | :---- | :---- |
|
|
274
|
+
| `Box` | Padding, borders, scroll containers, landmarks | No |
|
|
275
|
+
| `Flex` | Row/column layout with alignment and gap | No |
|
|
276
|
+
| `Card` | Content that needs a background, border, and tone | Yes |
|
|
277
|
+
| `Container` | Max-width constraint and horizontal centering for content areas | No |
|
|
278
|
+
|
|
279
|
+
Do not use `Card` for toolbars, sidebars, or scroll wrappers. Use `Box` or `Flex`. Do not use `Container` for app chrome — use `Box` or `Flex` directly.
|
|
280
|
+
|
|
281
|
+
### VStack vs Flex for vertical layout
|
|
282
|
+
|
|
283
|
+
| Use `VStack` | Use `Flex flexDirection="column"` |
|
|
284
|
+
| :---- | :---- |
|
|
285
|
+
| Simple vertical list with even spacing | Container needs `flexGrow`, `overflow`, or `minHeight` |
|
|
286
|
+
| Exposes only `as` and `gap` | Full flex control: `alignItems`, `justifyContent`, `flexWrap` |
|
|
287
|
+
|
|
288
|
+
### Card does not accept layout props
|
|
289
|
+
|
|
290
|
+
`Card` does not accept `flexGrow`, `minWidth`, `overflow`, or any other layout prop. Passing one directly is a TypeScript error (TS2322). Wrap it in a `Box`:
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
{/* ✗ — flexGrow on Card does nothing */}
|
|
294
|
+
<Card flexGrow={1}>...</Card>
|
|
295
|
+
|
|
296
|
+
{/* ✓ — Box handles layout, Card handles the surface */}
|
|
297
|
+
<Box flexGrow={1}>
|
|
298
|
+
<Card>...</Card>
|
|
299
|
+
</Box>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Icon-only buttons need aria-label
|
|
303
|
+
|
|
304
|
+
A tooltip does not set an accessible name. Add `aria-label`:
|
|
305
|
+
|
|
306
|
+
```tsx
|
|
307
|
+
<IconButton icon={SearchIcon} level="tertiary" aria-label="Search" />
|
|
308
|
+
```
|
|
309
|
+
- title: Next steps
|
|
310
|
+
body: |-
|
|
311
|
+
- Add a right-side inspector panel with `Box as="aside" aria-label="Inspector"`.
|
|
312
|
+
- Use `tone` on Card and Button for status: Button accepts `"neutral" and `"critical"`. Card accepts `"neutral"`, `"positive"`, `"caution"`, `"critical"`, `"suggest"`. Always a critical Button with an icon.
|
|
313
|
+
- kind: section
|
|
314
|
+
for: agent
|
|
315
|
+
freeform:
|
|
316
|
+
- title: Intent
|
|
317
|
+
body: Use this guide to scaffold a three-region admin layout with Sanity UI, following correct accessibility, heading hierarchy, and responsive reflow patterns.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
kind: sanity.guide
|
|
2
|
+
id: resources
|
|
3
|
+
name: Resources
|
|
4
|
+
description: Links to Sanity UI's project tracking, code repositories, package registry, and Figma libraries.
|
|
5
|
+
metadata:
|
|
6
|
+
tags:
|
|
7
|
+
- resources
|
|
8
|
+
- links
|
|
9
|
+
- figma
|
|
10
|
+
- github
|
|
11
|
+
- npm
|
|
12
|
+
- linear
|
|
13
|
+
status:
|
|
14
|
+
status: stable
|
|
15
|
+
sections:
|
|
16
|
+
- kind: section
|
|
17
|
+
for: all
|
|
18
|
+
freeform:
|
|
19
|
+
- title: Project management and tracking
|
|
20
|
+
body: |-
|
|
21
|
+
- [Linear project](https://linear.app/sanity/project/sanity-ui-v4-7ed2e7c751c0/issues)
|
|
22
|
+
- title: Code repositories and package management
|
|
23
|
+
body: |-
|
|
24
|
+
- [Sanity UI codebase](https://github.com/sanity-io/ui)
|
|
25
|
+
- [npm registry](https://www.npmjs.com/package/@sanity/ui)
|
|
26
|
+
- title: Figma
|
|
27
|
+
body: |-
|
|
28
|
+
- [Sanity UI Figma library](https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?m=auto&node-id=23381-4374)
|
|
29
|
+
- [Sanity Icons Figma library](https://www.figma.com/design/KxLfxXqB2TM73IfQM9UghN/%F0%9F%94%A3-Sanity-Icons?m=auto)
|
|
30
|
+
- kind: section
|
|
31
|
+
for: agent
|
|
32
|
+
freeform:
|
|
33
|
+
- title: Intent
|
|
34
|
+
body: Use this as the canonical link list for Sanity UI's project tracking, code, package, and design-file locations.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
kind: sanity.pattern
|
|
2
|
+
id: confirmation-dialogs
|
|
3
|
+
name: Confirmation & action dialogs
|
|
4
|
+
description: '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.'
|
|
5
|
+
metadata:
|
|
6
|
+
tags:
|
|
7
|
+
- tutorial
|
|
8
|
+
- confirm
|
|
9
|
+
- confirmation
|
|
10
|
+
- dialog
|
|
11
|
+
- modal
|
|
12
|
+
- popover
|
|
13
|
+
- destructive
|
|
14
|
+
- delete
|
|
15
|
+
- focus trap
|
|
16
|
+
- escape
|
|
17
|
+
- dismissal
|
|
18
|
+
- critical
|
|
19
|
+
- alertdialog
|
|
20
|
+
status:
|
|
21
|
+
status: stable
|
|
22
|
+
sections:
|
|
23
|
+
- kind: guidelines
|
|
24
|
+
for: all
|
|
25
|
+
framing: how-to-use
|
|
26
|
+
items:
|
|
27
|
+
- level: must
|
|
28
|
+
statement: Anchor the inline confirm popover to the triggering element, not the viewport center. That's what makes it read as "confirming this row," not "confirming something."
|
|
29
|
+
- id: default-destructive-confirms-both-popover
|
|
30
|
+
level: must
|
|
31
|
+
statement: Default destructive confirms to `tone="critical"` on both the popover's accent and the confirm button, and give the confirm button `level="primary"`. The confirm button is the most important action on a confirmation surface — that is what the surface exists for — so it carries the primary level alongside the critical tone. Cancel is the secondary or tertiary action.
|
|
32
|
+
refines:
|
|
33
|
+
- to: shared-foundations#destructive-actions-use-critical-tone
|
|
34
|
+
- level: must
|
|
35
|
+
statement: 'Disable or hide the confirm action until an async impact check resolves — for example, counting how many other documents reference this one, or checking permissions. Once it resolves, name the consequence on the confirm button. A generic confirm gives a destructive action less friction than it needs, and lets someone confirm before they know what breaks.'
|
|
36
|
+
example:
|
|
37
|
+
title: Confirm waits on an async impact check
|
|
38
|
+
ref:
|
|
39
|
+
href: ../examples/confirmation-dialogs-3.tsx
|
|
40
|
+
rel: source
|
|
41
|
+
- id: guarantee-every-confirmation-surface-way
|
|
42
|
+
level: must
|
|
43
|
+
statement: Guarantee every confirmation surface a way out — Escape, click-outside, and an explicit Cancel/close control. A surface missing any of the three can trap whoever opened it.
|
|
44
|
+
- level: must
|
|
45
|
+
statement: 'When building a fully custom confirmation overlay instead of composing `Dialog` or `Popover`, wire Escape-to-close, click-outside, a backdrop dismissal, and an explicit close control yourself. Nothing gives you these for free outside of `Dialog` and `Popover`. Otherwise the surface can end up with no declared close handler at all — closeable by neither the keyboard nor a click.'
|
|
46
|
+
- level: should
|
|
47
|
+
statement: 'Name the resolved consequence on the confirm button itself once it''s known (for example, "Delete (3 refs)"), instead of leaving a generic "Confirm" label. "Delete (3 refs)" tells the user what they''re about to do; "Confirm" doesn''t. The confirm button must repeat the action verb, per the messaging pattern — even though the number in the label wasn''t known a moment ago.'
|
|
48
|
+
refines:
|
|
49
|
+
- to: content-guidelines#name-the-action
|
|
50
|
+
- level: must-not
|
|
51
|
+
statement: Never let one confirmation shape lose a dismissal path that another shape has. If the popover version of a confirm closes on Escape, click-outside, and Cancel, the Dialog version of that same confirm must close the same three ways. Consistency here isn't cosmetic — it's what a keyboard user learns to expect from every confirm in the product.
|
|
52
|
+
- level: must-not
|
|
53
|
+
statement: 'Do not hand-build a confirmation surface — a fixed-position `div` with a manual backdrop — instead of composing `Dialog`. A hand-built modal reproduces what `Dialog` already provides, and usually drops the parts that are easy to forget: focus trapping, Escape handling, and returning focus to the trigger on close.'
|
|
54
|
+
example:
|
|
55
|
+
title: Hand-built confirmation vs. Dialog
|
|
56
|
+
ref:
|
|
57
|
+
href: ../examples/confirmation-dialogs-4.tsx
|
|
58
|
+
rel: source
|
|
59
|
+
- kind: guidelines
|
|
60
|
+
for: agent
|
|
61
|
+
framing: how-to-use
|
|
62
|
+
items:
|
|
63
|
+
- level: must
|
|
64
|
+
statement: Use a full Dialog for destructive actions with rich content to show; use an inline Popover confirm, anchored to the trigger, for a single row's action.
|
|
65
|
+
- kind: steps
|
|
66
|
+
for: all
|
|
67
|
+
ordered: false
|
|
68
|
+
title: Accessibility checklist
|
|
69
|
+
items:
|
|
70
|
+
- title: Focus lands on Cancel (or the container), never on the destructive confirm button, when the surface opens.
|
|
71
|
+
- title: Escape, click-outside, and an explicit Cancel/close control all resolve to the same close behavior.
|
|
72
|
+
- title: The confirm button is disabled, not styled to look disabled, while an async impact check is pending.
|
|
73
|
+
- title: The confirm button's label names the action and, when known, its scale — not a bare "Confirm."
|
|
74
|
+
- title: Destructive confirms use `tone="critical"` on the confirm button, not color alone, and `level="primary"` — the confirm action is not visually demoted for being destructive.
|
|
75
|
+
- kind: section
|
|
76
|
+
for: all
|
|
77
|
+
freeform:
|
|
78
|
+
- title: Overview
|
|
79
|
+
body: 'Sanity UI has one modal overlay (`Dialog`) and one floating layer (`Popover`). It has no built-in "lightweight inline confirm." Studio composes exactly that on top of `Popover`, for confirms that don''t need a full modal. This page covers which shape to reach for. It also covers the one rule that holds no matter which you choose: a confirmation surface must have a guaranteed way to close.'
|
|
80
|
+
- title: Two shapes of confirmation
|
|
81
|
+
body: |-
|
|
82
|
+
| | Full `Dialog` | Inline confirm popover |
|
|
83
|
+
| --- | --- | --- |
|
|
84
|
+
| Use for | A destructive action with rich content: a document, or what else it references | A small, local action: one row's delete button, an inline discard |
|
|
85
|
+
| Anchoring | Centered, blocks the whole page | Anchored beside the trigger that opened it |
|
|
86
|
+
| Body content | A heading, body text, optionally a list or preview of affected items | One line of consequence text |
|
|
87
|
+
| Focus behavior | Traps focus; nothing behind it is reachable | Does not trap focus; the rest of the page stays interactive |
|
|
88
|
+
|
|
89
|
+
**Reach for a full `Dialog` when the confirmation needs to show something, not describe it.** A delete that also removes other documents needs to list those documents. That's rich content — it earns a dialog. A delete on one list row with nothing else at stake needs one sentence next to the row it affects.
|
|
90
|
+
- kind: section
|
|
91
|
+
for: all
|
|
92
|
+
freeform:
|
|
93
|
+
- title: The escape-hatch rule
|
|
94
|
+
body: |-
|
|
95
|
+
Every confirmation surface must guarantee a way out, regardless of mechanism: Escape, click-outside, or an explicit Cancel/close control.
|
|
96
|
+
|
|
97
|
+
| Surface | Closes via |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `Dialog` | Header close icon, click-outside (via `closedby="any"`), Escape — all routed to the same `onClose` |
|
|
100
|
+
| Inline confirm popover | Escape, click-outside, or the Cancel button — route all three to the same handler |
|
|
101
|
+
| A fully custom overlay | Nothing automatic. You build every dismissal path yourself. |
|
|
102
|
+
- kind: section
|
|
103
|
+
for: agent
|
|
104
|
+
freeform:
|
|
105
|
+
- title: Intent
|
|
106
|
+
body: Choose a full Dialog when a confirmation needs to show something (a document or its references); choose an inline Popover confirm for a small, local action. Whichever shape is used, guarantee a way to close it, and never render a generic confirm button while an async impact check is still pending.
|
|
107
|
+
traits:
|
|
108
|
+
- traitType: variant
|
|
109
|
+
kind: enum
|
|
110
|
+
id: shape
|
|
111
|
+
name: Confirmation shape
|
|
112
|
+
description: Which surface a confirmation renders in, chosen by how much the confirmation needs to show.
|
|
113
|
+
values:
|
|
114
|
+
- id: dialog
|
|
115
|
+
name: Full Dialog
|
|
116
|
+
description: Use for a destructive action with rich content — a document, or what else it references. Centered, blocks the whole page, and traps focus so nothing behind it is reachable. Body content can include a heading, body text, and a list or preview of affected items.
|
|
117
|
+
examples:
|
|
118
|
+
- title: Confirmation built on Dialog
|
|
119
|
+
description: Dialog handles the backdrop, focus trap, and Escape for a full confirmation.
|
|
120
|
+
ref:
|
|
121
|
+
href: ../examples/confirmation-dialogs-1.tsx
|
|
122
|
+
rel: source
|
|
123
|
+
- id: inline-popover
|
|
124
|
+
name: Inline confirm popover
|
|
125
|
+
description: Use for a small, local action — one row's delete button, an inline discard. Anchored beside the trigger that opened it, does not trap focus, and the rest of the page stays interactive. Body content is one line of consequence text.
|
|
126
|
+
examples:
|
|
127
|
+
- title: Popover + Button composing an inline confirm
|
|
128
|
+
description: Popover and Button compose the whole thing. Anchor the popover to the row's own trigger element, and default its tone to critical for destructive confirms.
|
|
129
|
+
ref:
|
|
130
|
+
href: ../examples/confirmation-dialogs-2.tsx
|
|
131
|
+
rel: source
|
|
132
|
+
uses:
|
|
133
|
+
- to: dialog
|
|
134
|
+
note: Required part.
|
|
135
|
+
- to: popover
|
|
136
|
+
note: Required part.
|
|
137
|
+
- to: button
|
|
138
|
+
note: Required part.
|
|
139
|
+
- to: messaging
|
|
140
|
+
- to: error-messaging
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
kind: sanity.pattern
|
|
2
|
+
id: error-messaging
|
|
3
|
+
name: Error messaging
|
|
4
|
+
description: Guidelines for writing clear, actionable error messages that name the problem and direct users to the next step.
|
|
5
|
+
metadata:
|
|
6
|
+
tags:
|
|
7
|
+
- tutorial
|
|
8
|
+
- errors
|
|
9
|
+
- messaging
|
|
10
|
+
- copy
|
|
11
|
+
- accessibility
|
|
12
|
+
- feedback
|
|
13
|
+
- error
|
|
14
|
+
- error message
|
|
15
|
+
- validation
|
|
16
|
+
- field error
|
|
17
|
+
- tone
|
|
18
|
+
- critical
|
|
19
|
+
- WCAG
|
|
20
|
+
status:
|
|
21
|
+
status: stable
|
|
22
|
+
sections:
|
|
23
|
+
- kind: guidelines
|
|
24
|
+
for: all
|
|
25
|
+
framing: how-to-use
|
|
26
|
+
items:
|
|
27
|
+
- id: name-what-failed
|
|
28
|
+
level: must
|
|
29
|
+
statement: 'Name what failed: the thing, and what went wrong with it. Use plain words, with no error codes or stack traces. Use "Something went wrong" only as a last resort, when you can''t find the cause.'
|
|
30
|
+
refines:
|
|
31
|
+
- to: content-guidelines#plain-language
|
|
32
|
+
- id: state-next-step
|
|
33
|
+
level: must
|
|
34
|
+
statement: 'State the next step when the user can act. Example: "The image failed to upload. Try a file under 10 MB." When they cannot act, describe what the system is doing.'
|
|
35
|
+
- level: must
|
|
36
|
+
statement: 'For errors the user can''t fix, say what the system does. Never invent a step the user can''t take. Name who to contact instead. Example: "This didn''t save. We''re retrying — your work is safe."'
|
|
37
|
+
- id: field-error-names-field
|
|
38
|
+
level: must
|
|
39
|
+
statement: Field errors must identify their field. A message that floats free of its input fails WCAG 3.3.1 Error Identification. Place it with its input, and name that field's problem.
|
|
40
|
+
- id: error-message-length
|
|
41
|
+
level: should
|
|
42
|
+
statement: Keep messages to two sentences at most. Link to docs or offer a "Details" toggle for longer context.
|
|
43
|
+
- id: dont-blame-the-user
|
|
44
|
+
level: must-not
|
|
45
|
+
statement: Don't blame the user. Frame errors as states, not faults. Use "This file type is not allowed," not "You sent a bad file."
|
|
46
|
+
- kind: guidelines
|
|
47
|
+
for: agent
|
|
48
|
+
framing: how-to-use
|
|
49
|
+
items:
|
|
50
|
+
- level: must
|
|
51
|
+
statement: 'Lead an error message with the state ("**Error:** …") or pair tone="critical" with ErrorOutlineIcon.'
|
|
52
|
+
refines:
|
|
53
|
+
- to: shared-foundations#tone-paired-with-second-channel
|
|
54
|
+
- kind: section
|
|
55
|
+
for: agent
|
|
56
|
+
freeform:
|
|
57
|
+
- title: Intent
|
|
58
|
+
body: Apply these rules when writing or reviewing error message copy in Sanity UI components to ensure messages are clear, actionable, and accessible.
|