@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,108 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: link
|
|
3
|
+
name: Link
|
|
4
|
+
description: Acts as a navigational element to move across pages.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [link, anchor, navigation, href, url, external, internal]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: when-to-use
|
|
13
|
+
title: When to use
|
|
14
|
+
items:
|
|
15
|
+
- level: should
|
|
16
|
+
statement: To navigate to another page or external URL.
|
|
17
|
+
- level: should
|
|
18
|
+
statement: To scroll to a fragment within the same page (href='#section').
|
|
19
|
+
- level: should-not
|
|
20
|
+
statement: To trigger an action that doesn't navigate. Use Button instead.
|
|
21
|
+
alternatives:
|
|
22
|
+
- to: button
|
|
23
|
+
- level: should-not
|
|
24
|
+
statement: To switch between views on a screen. Use Tab instead.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: tabs
|
|
27
|
+
- kind: guidelines
|
|
28
|
+
for: agent
|
|
29
|
+
framing: when-to-use
|
|
30
|
+
title: When to use
|
|
31
|
+
items:
|
|
32
|
+
- level: should-not
|
|
33
|
+
statement: SkipToContent is a specialized skip-navigation Link; use it at the top of the page for keyboard bypass.
|
|
34
|
+
alternatives:
|
|
35
|
+
- to: skip-to-content
|
|
36
|
+
- kind: guidelines
|
|
37
|
+
for: all
|
|
38
|
+
framing: how-to-use
|
|
39
|
+
items:
|
|
40
|
+
- refs:
|
|
41
|
+
- to: content-guidelines#name-the-action
|
|
42
|
+
rel: same-as
|
|
43
|
+
- id: link-open-in-new-tab-prop
|
|
44
|
+
level: should
|
|
45
|
+
statement: Use the openInNewTab prop instead of manually setting target='_blank', so it sets both target='_blank' and rel='noopener noreferrer' together.
|
|
46
|
+
example:
|
|
47
|
+
title: How to satisfy this
|
|
48
|
+
description: Review the component source or JSX and confirm that any link intended to open in a new tab passes openInNewTab={true} rather than target='_blank'. Inspect the rendered anchor element in DevTools and confirm rel='noopener noreferrer' is present alongside target='_blank'.
|
|
49
|
+
checkedBy: manual
|
|
50
|
+
- id: link-not-used-for-actions
|
|
51
|
+
level: must-not
|
|
52
|
+
statement: Don't use Link to trigger a side effect, such as opening a dialog, submitting data, or toggling state, without navigating to a new URL or fragment — use Button instead.
|
|
53
|
+
example:
|
|
54
|
+
title: How to satisfy this
|
|
55
|
+
description: Review each Link's onClick handler and href. Confirm the href is a real destination (URL, path, or fragment), not '#' or 'javascript:void(0)'. For any link that triggers an action, confirm the element has been replaced with a Button.
|
|
56
|
+
alternatives:
|
|
57
|
+
- to: button
|
|
58
|
+
checkedBy: manual
|
|
59
|
+
- id: link-no-nested-interactive
|
|
60
|
+
level: must-not
|
|
61
|
+
statement: "Don't nest interactive elements inside Link's children, such as a Button, input, select, textarea, or another anchor."
|
|
62
|
+
example:
|
|
63
|
+
title: How to satisfy this
|
|
64
|
+
description: Inspect the rendered DOM and confirm there is no button, input, select, textarea, or anchor element descendant inside the Link's anchor tag. Review the JSX passed to the children prop and confirm it contains only non-interactive content (text, icons, inline images).
|
|
65
|
+
checkedBy: manual
|
|
66
|
+
- id: link-no-unsafe-blank-target
|
|
67
|
+
level: must-not
|
|
68
|
+
statement: Don't hand-set target='_blank' without also setting rel='noopener noreferrer' — use the openInNewTab prop, which sets both safely.
|
|
69
|
+
example:
|
|
70
|
+
title: How to satisfy this
|
|
71
|
+
description: Search the codebase for target='_blank' and confirm every occurrence either uses the openInNewTab prop or explicitly includes rel='noopener noreferrer'. Inspect rendered anchor elements with target='_blank' in DevTools and confirm the rel attribute includes both 'noopener' and 'noreferrer'.
|
|
72
|
+
checkedBy: manual
|
|
73
|
+
- kind: guidelines
|
|
74
|
+
for: all
|
|
75
|
+
title: Content
|
|
76
|
+
tags: [content]
|
|
77
|
+
items:
|
|
78
|
+
- level: should-not
|
|
79
|
+
statement: Don’t format text in a link any differently than regular text content.
|
|
80
|
+
- level: should-not
|
|
81
|
+
statement: Don’t add a trailing period when the link is a phrase on its own. Keep the period when the link sits inside a sentence.
|
|
82
|
+
alternatives:
|
|
83
|
+
- to: button
|
|
84
|
+
note: For actions that don't navigate
|
|
85
|
+
- to: skip-to-content
|
|
86
|
+
note: A built-in skip-navigation link that uses Link
|
|
87
|
+
sourceFiles:
|
|
88
|
+
- platform: react
|
|
89
|
+
file: packages/ui/src/components/link/Link.tsx
|
|
90
|
+
imports:
|
|
91
|
+
- platform: react
|
|
92
|
+
code: import { Link } from '@sanity/ui'
|
|
93
|
+
package: '@sanity/ui'
|
|
94
|
+
$extensions:
|
|
95
|
+
com.sanity.ui:
|
|
96
|
+
implementationStatus:
|
|
97
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
98
|
+
implemented: true
|
|
99
|
+
migrationGuide:
|
|
100
|
+
context: 'Migration guide for this component, covering the codemod and the changes it cannot make. Held as an extension because it is temporary: migration tooling and porting agents read it, and it should be dropped when Sanity UI 3 support ends.'
|
|
101
|
+
guidance: |-
|
|
102
|
+
In v3, links were either bare `<a>` tags or composed with `<Text>`. Link is a typed anchor with consistent defaults.
|
|
103
|
+
|
|
104
|
+
| v3 pattern | v5 pattern | Notes |
|
|
105
|
+
| :---- | :---- | :---- |
|
|
106
|
+
| `<a href="...">...</a>` | `<Link href="...">...</Link>` | Same API, different component; adds `sui-Link` class and `data-ui` attribute |
|
|
107
|
+
| `<a target="_blank" rel="noopener noreferrer">` | `<Link openInNewTab>` | New prop handles both attributes together |
|
|
108
|
+
| `text-decoration: underline` (CSS) | `underlined` (prop, default `true`) | Set `underlined={false}` to remove the underline |
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list-button-item
|
|
3
|
+
name: List.ButtonItem
|
|
4
|
+
description: The interactive, selectable variant of List.Item.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, item, row, li, button, interactive, selectable]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: when-to-use
|
|
13
|
+
title: When to use
|
|
14
|
+
items:
|
|
15
|
+
- level: should
|
|
16
|
+
statement: A row that navigates, selects, or triggers an action — a document in a browser list, a sidebar nav item, a selectable row in a picker.
|
|
17
|
+
- level: should
|
|
18
|
+
statement: Anywhere you would otherwise wrap List.Item in PressArea by hand.
|
|
19
|
+
- level: should-not
|
|
20
|
+
statement: A row with no interaction. Use plain List.Item instead.
|
|
21
|
+
alternatives:
|
|
22
|
+
- to: list-item
|
|
23
|
+
- level: should-not
|
|
24
|
+
statement: A row containing more than one interactive control. Nested interactive elements inside a button/anchor break keyboard and screen-reader expectations — use List.Item with start/end slots and make only one child interactive.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: list-item
|
|
27
|
+
- kind: guidelines
|
|
28
|
+
for: all
|
|
29
|
+
framing: how-to-use
|
|
30
|
+
items:
|
|
31
|
+
- id: every-prop-besides-selected-density
|
|
32
|
+
level: must
|
|
33
|
+
statement: Every prop besides as/selected/density/start/end/children forwards to the inner <button>/<a>, not the outer <li>. This differs from plain List.Item, whose extra props land on the <li> itself.
|
|
34
|
+
- level: must-not
|
|
35
|
+
statement: Don't use List.ButtonItem outside of a List — it renders as <li> and requires a <ul> or <ol> parent.
|
|
36
|
+
- level: must-not
|
|
37
|
+
statement: 'Don''t pass selected unconditionally. selected={false} still renders data-selected="false", and the component''s CSS selects on attribute presence ([data-selected]), not value — so selected={false} looks identical to selected={true}. Only omit the prop to render the unselected state: {...(isActive ? {selected: true} : {})}, or selected={isActive || undefined}.'
|
|
38
|
+
- id: don-nest-another-interactive-element
|
|
39
|
+
level: must-not
|
|
40
|
+
statement: Don't nest another interactive element (Button, a second PressArea) inside List.ButtonItem. The whole row is already one press target.
|
|
41
|
+
- kind: guidelines
|
|
42
|
+
for: agent
|
|
43
|
+
framing: how-to-use
|
|
44
|
+
items:
|
|
45
|
+
- refs:
|
|
46
|
+
- to: list#subcomponents-not-named-exports
|
|
47
|
+
rel: same-as
|
|
48
|
+
- level: must
|
|
49
|
+
statement: The selected prop sets no ARIA state — only a data-selected styling hook. When using selected, also set aria-current="true" (for a current-item-in-a-list pattern like active nav) or aria-selected="true" (inside a listbox/grid with role wired accordingly) when the row is selected, and omit that ARIA attribute entirely when it is not (do not set it to "false").
|
|
50
|
+
- level: must-not
|
|
51
|
+
statement: selected={false} is not equivalent to omitting selected. Because the component's CSS rule is `.sui-ListButtonItem[data-selected]` (an attribute-presence selector, not a value match) and React renders data-selected={false} as the literal attribute data-selected="false", a row with selected={false} is styled identically to selected={true}. Only pass the selected prop when true — use selected={isActive || undefined} or a conditional spread, never a bare boolean expression.
|
|
52
|
+
- level: must-not
|
|
53
|
+
statement: "Using onClick on a plain List.Item instead of List.ButtonItem. Instead: List.Item is not interactive and has none of List.ButtonItem's keyboard handling — use List.ButtonItem for any pressable row."
|
|
54
|
+
- kind: section
|
|
55
|
+
for: all
|
|
56
|
+
freeform:
|
|
57
|
+
- title: Composition
|
|
58
|
+
body: |-
|
|
59
|
+
Same child order as List.Item: `start`, then the row's text content, then `end`. Use `start` for a thumbnail or icon, and `end` for an action, badge, or timestamp.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { List } from '@sanity/ui'
|
|
63
|
+
|
|
64
|
+
<List>
|
|
65
|
+
{documents.map((doc) => (
|
|
66
|
+
<List.ButtonItem
|
|
67
|
+
key={doc.id}
|
|
68
|
+
onClick={() => setActiveId(doc.id)}
|
|
69
|
+
selected={activeId === doc.id || undefined}
|
|
70
|
+
start={<List.ItemImage src={doc.thumbnailUrl} alt="" />}
|
|
71
|
+
>
|
|
72
|
+
<List.ItemText title={doc.title} subtitle={doc.updatedAt} />
|
|
73
|
+
</List.ButtonItem>
|
|
74
|
+
))}
|
|
75
|
+
</List>
|
|
76
|
+
```
|
|
77
|
+
alternatives:
|
|
78
|
+
- to: list-item
|
|
79
|
+
note: The non-interactive row — see **List.Item** docs
|
|
80
|
+
- to: press-area
|
|
81
|
+
note: The lower-level interaction primitive List.ButtonItem is built on
|
|
82
|
+
refs:
|
|
83
|
+
- to: list
|
|
84
|
+
rel: relates-to
|
|
85
|
+
note: The parent component — see **List** for full compound component docs
|
|
86
|
+
sourceFiles:
|
|
87
|
+
- platform: react
|
|
88
|
+
file: packages/ui/src/components/list/List.tsx
|
|
89
|
+
imports:
|
|
90
|
+
- platform: react
|
|
91
|
+
code: import { List } from '@sanity/ui'
|
|
92
|
+
package: '@sanity/ui'
|
|
93
|
+
traits:
|
|
94
|
+
- traitType: state
|
|
95
|
+
kind: boolean
|
|
96
|
+
id: selected
|
|
97
|
+
description: Marks the row as the current selection via a data-selected styling hook. Only pass this prop when true — see the how-to-use guidance below.
|
|
98
|
+
|
|
99
|
+
$extensions:
|
|
100
|
+
com.sanity.ui:
|
|
101
|
+
implementationStatus:
|
|
102
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
103
|
+
implemented: true
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list-item-image
|
|
3
|
+
name: List.ItemImage
|
|
4
|
+
description: A thumbnail image slot inside a List.Item.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, item, image, thumbnail, avatar]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- level: should
|
|
15
|
+
statement: Use the --aspect-ratio CSS custom property to change the image aspect ratio from the default square.
|
|
16
|
+
- level: must-not
|
|
17
|
+
statement: "Don't override width, height, or max-width with inline styles. The fixed size (42px max-width) keeps rows visually even."
|
|
18
|
+
- kind: guidelines
|
|
19
|
+
for: agent
|
|
20
|
+
framing: how-to-use
|
|
21
|
+
items:
|
|
22
|
+
- refs:
|
|
23
|
+
- to: list#subcomponents-not-named-exports
|
|
24
|
+
rel: same-as
|
|
25
|
+
|
|
26
|
+
- kind: guidelines
|
|
27
|
+
for: all
|
|
28
|
+
title: Accessibility
|
|
29
|
+
tags: [accessibility]
|
|
30
|
+
items:
|
|
31
|
+
- id: list-item-image-alt-always-required
|
|
32
|
+
level: must
|
|
33
|
+
statement: Always pass `alt`. The component renders a native `<img>` with no implicit accessible name.
|
|
34
|
+
- id: only-image-decorative-row-title
|
|
35
|
+
level: must
|
|
36
|
+
statement: Use `alt=""` only when the image is decorative and the row title already describes the item.
|
|
37
|
+
- kind: section
|
|
38
|
+
for: agent
|
|
39
|
+
freeform:
|
|
40
|
+
- title: Examples
|
|
41
|
+
body: |-
|
|
42
|
+
List.ItemImage renders a fixed-size (42px max-width) square thumbnail.
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
// ✓ — meaningful image: item has no adjacent text describing it
|
|
46
|
+
<List.ItemImage src="/user.jpg" alt="Jane Doe" />
|
|
47
|
+
|
|
48
|
+
// ✓ — decorative: adjacent title already describes the item
|
|
49
|
+
<List.ItemImage src="/thumb.jpg" alt="" />
|
|
50
|
+
|
|
51
|
+
// ✗ — do not override dimensions
|
|
52
|
+
<List.ItemImage src="/thumb.jpg" alt="" style={{ width: 80, height: 80 }} />
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Place List.ItemImage before `List.ItemText` inside `List.Item`.
|
|
56
|
+
|
|
57
|
+
refs:
|
|
58
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32249-481
|
|
59
|
+
rel: design
|
|
60
|
+
role: Figma component (v5)
|
|
61
|
+
- to: list-item
|
|
62
|
+
rel: relates-to
|
|
63
|
+
note: The parent row
|
|
64
|
+
- to: list
|
|
65
|
+
rel: relates-to
|
|
66
|
+
note: The root list component — see **List** for full compound component docs
|
|
67
|
+
- to: avatar
|
|
68
|
+
rel: relates-to
|
|
69
|
+
note: A good fit for user portraits inside list rows
|
|
70
|
+
sourceFiles:
|
|
71
|
+
- platform: react
|
|
72
|
+
file: packages/ui/src/components/list/List.tsx
|
|
73
|
+
imports:
|
|
74
|
+
- platform: react
|
|
75
|
+
code: import { List } from '@sanity/ui'
|
|
76
|
+
package: '@sanity/ui'
|
|
77
|
+
|
|
78
|
+
$extensions:
|
|
79
|
+
com.sanity.ui:
|
|
80
|
+
implementationStatus:
|
|
81
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
82
|
+
implemented: true
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list-item-text
|
|
3
|
+
name: List.ItemText
|
|
4
|
+
description: The text content slot inside a List.Item.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, item, text, title, subtitle]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- level: should
|
|
15
|
+
statement: Keep titles short — they are clamped to one line.
|
|
16
|
+
- level: must-not
|
|
17
|
+
statement: Don't use List.ItemText outside of List.Item. It relies on the flex layout of the parent row.
|
|
18
|
+
- kind: guidelines
|
|
19
|
+
for: agent
|
|
20
|
+
framing: how-to-use
|
|
21
|
+
items:
|
|
22
|
+
- refs:
|
|
23
|
+
- to: list#subcomponents-not-named-exports
|
|
24
|
+
rel: same-as
|
|
25
|
+
- level: must-not
|
|
26
|
+
statement: Do not wrap title or subtitle in a Text component — List.ItemText applies sizing, weight, and truncation internally.
|
|
27
|
+
- kind: guidelines
|
|
28
|
+
for: all
|
|
29
|
+
title: Content
|
|
30
|
+
tags: [content]
|
|
31
|
+
items:
|
|
32
|
+
- refs:
|
|
33
|
+
- to: content-guidelines#sentence-case-all-system-set
|
|
34
|
+
rel: same-as
|
|
35
|
+
- kind: section
|
|
36
|
+
for: agent
|
|
37
|
+
freeform:
|
|
38
|
+
- title: Examples
|
|
39
|
+
body: |-
|
|
40
|
+
List.ItemText renders a two-line label block with built-in styling.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
// ✓ — ItemText applies size, weight, and truncation internally
|
|
44
|
+
<List.ItemText title="My document" subtitle="Last edited 2 hours ago" />
|
|
45
|
+
|
|
46
|
+
// ✗ — wrapping in Text adds conflicting styles
|
|
47
|
+
<List.ItemText
|
|
48
|
+
title={<Text size={1} weight="medium">My document</Text>}
|
|
49
|
+
subtitle="..."
|
|
50
|
+
/>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Both `title` and `subtitle` accept `React.ReactNode`, so you can pass a `Badge` or `Icon` when needed. Keep the value short — both lines are clamped to one line (`truncate={1}`).
|
|
54
|
+
|
|
55
|
+
refs:
|
|
56
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32249-547
|
|
57
|
+
rel: design
|
|
58
|
+
role: Figma component (v5)
|
|
59
|
+
- to: list-item
|
|
60
|
+
rel: relates-to
|
|
61
|
+
note: The parent row
|
|
62
|
+
- to: list
|
|
63
|
+
rel: relates-to
|
|
64
|
+
note: The root list component — see **List** for full compound component docs
|
|
65
|
+
- to: tooltip
|
|
66
|
+
rel: relates-to
|
|
67
|
+
note: Use to reveal full text when a title is truncated
|
|
68
|
+
sourceFiles:
|
|
69
|
+
- platform: react
|
|
70
|
+
file: packages/ui/src/components/list/List.tsx
|
|
71
|
+
imports:
|
|
72
|
+
- platform: react
|
|
73
|
+
code: import { List } from '@sanity/ui'
|
|
74
|
+
package: '@sanity/ui'
|
|
75
|
+
|
|
76
|
+
$extensions:
|
|
77
|
+
com.sanity.ui:
|
|
78
|
+
implementationStatus:
|
|
79
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
80
|
+
implemented: true
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list-item
|
|
3
|
+
name: List.Item
|
|
4
|
+
description: A single row inside a List.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, item, row, li]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: how-to-use
|
|
13
|
+
items:
|
|
14
|
+
- level: should
|
|
15
|
+
statement: Match the density of List.Item to the surrounding layout density.
|
|
16
|
+
- id: don-list-item-outside-list
|
|
17
|
+
level: must-not
|
|
18
|
+
statement: Don't use List.Item outside of a List — it renders as <li> and requires a <ul> or <ol> parent.
|
|
19
|
+
- id: don-place-more-one-interactive
|
|
20
|
+
level: must-not
|
|
21
|
+
statement: Don't place more than one interactive element in the end slot (or the start slot). It creates an unclear tab order.
|
|
22
|
+
- kind: guidelines
|
|
23
|
+
for: agent
|
|
24
|
+
framing: how-to-use
|
|
25
|
+
items:
|
|
26
|
+
- refs:
|
|
27
|
+
- to: list#subcomponents-not-named-exports
|
|
28
|
+
rel: same-as
|
|
29
|
+
- level: must-not
|
|
30
|
+
statement: Do not pass paddingX, paddingY, padding, or margin to List.Item — those props do not exist on it and cause a TypeScript error. Use density to control spacing instead.
|
|
31
|
+
- level: must-not
|
|
32
|
+
statement: There is no `trailing` prop on List.Item — it was replaced by `start` and `end` in a breaking change. `trailing={...}` is a TypeScript error (unknown prop); use `end` instead.
|
|
33
|
+
|
|
34
|
+
- kind: guidelines
|
|
35
|
+
for: all
|
|
36
|
+
title: Accessibility
|
|
37
|
+
tags: [accessibility]
|
|
38
|
+
items:
|
|
39
|
+
- level: must
|
|
40
|
+
statement: Buttons in `start` or `end` must have an accessible name via `aria-label` or visible text.
|
|
41
|
+
- level: should
|
|
42
|
+
statement: '**Don''t nest an interactive role inside another.** If the row itself carries an interactive role (`option`, `link`), don''t also wrap its content in an `<a>` or `<button>` — choose one interactive role per row (see the Accessibility foundation, "Nested interactive elements").'
|
|
43
|
+
- level: should
|
|
44
|
+
statement: A decorative preview image (`List.ItemImage`) whose `alt` repeats the row's own name announces that name twice — mark it decorative instead.
|
|
45
|
+
- level: must-not
|
|
46
|
+
statement: '`List.Item` renders as `<li>`. Do not use it outside a `<ul>` or `<ol>`.'
|
|
47
|
+
- kind: section
|
|
48
|
+
for: agent
|
|
49
|
+
freeform:
|
|
50
|
+
- title: Composition pattern
|
|
51
|
+
body: |-
|
|
52
|
+
List.Item is always a direct child of List. `start` renders before the row's children (left edge); `end` renders after them (right edge) — both render outside the flex-grown content area, per the component's own layout (`{start}<Flex flexGrow={1}>{children}</Flex>{end}`).
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { IconButton, List } from '@sanity/ui'
|
|
56
|
+
import { EllipsisVerticalIcon } from '@sanity/icons/EllipsisVertical'
|
|
57
|
+
|
|
58
|
+
<List>
|
|
59
|
+
<List.Item
|
|
60
|
+
start={<List.ItemImage src="/thumb.jpg" alt="Document thumbnail" />}
|
|
61
|
+
end={
|
|
62
|
+
<IconButton
|
|
63
|
+
level="tertiary"
|
|
64
|
+
icon={EllipsisVerticalIcon}
|
|
65
|
+
aria-label="More actions"
|
|
66
|
+
/>
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
<List.ItemText title="My document" subtitle="Last edited 2 hours ago" />
|
|
70
|
+
</List.Item>
|
|
71
|
+
</List>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
There is no `trailing` prop — it was replaced by `start`/`end` (breaking change).
|
|
75
|
+
- title: density values
|
|
76
|
+
body: |-
|
|
77
|
+
| Value | gap | paddingX | minHeight |
|
|
78
|
+
|-------|-----|----------|-----------|
|
|
79
|
+
| `compact` | 2 | 1 | 33px |
|
|
80
|
+
| `regular` | 2 | 2 | 37px |
|
|
81
|
+
| `loose` | 3 | 3 | 45px |
|
|
82
|
+
|
|
83
|
+
Match density to surrounding layout. Defaults to `regular`.
|
|
84
|
+
|
|
85
|
+
- kind: section
|
|
86
|
+
for: all
|
|
87
|
+
freeform:
|
|
88
|
+
- title: Examples
|
|
89
|
+
body: |-
|
|
90
|
+
Place children in this order: `start`, then the row's text content, then `end`. Use `start` for a thumbnail or icon, and `end` for an action, badge, or timestamp.
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
import { List, IconButton } from '@sanity/ui'
|
|
94
|
+
import { EllipsisVerticalIcon } from '@sanity/icons/EllipsisVertical'
|
|
95
|
+
|
|
96
|
+
<List>
|
|
97
|
+
<List.Item
|
|
98
|
+
start={<List.ItemImage src="/thumb.jpg" alt="Document thumbnail" />}
|
|
99
|
+
end={
|
|
100
|
+
<IconButton
|
|
101
|
+
level="tertiary"
|
|
102
|
+
icon={EllipsisVerticalIcon}
|
|
103
|
+
aria-label="More actions"
|
|
104
|
+
/>
|
|
105
|
+
}
|
|
106
|
+
>
|
|
107
|
+
<List.ItemText title="My document" subtitle="Last edited 2 hours ago" />
|
|
108
|
+
</List.Item>
|
|
109
|
+
</List>
|
|
110
|
+
```
|
|
111
|
+
refs:
|
|
112
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32243-2
|
|
113
|
+
rel: design
|
|
114
|
+
role: Figma component (v5)
|
|
115
|
+
- to: list
|
|
116
|
+
rel: relates-to
|
|
117
|
+
note: The parent component — see **List** for full compound component docs
|
|
118
|
+
- to: list-item-text
|
|
119
|
+
rel: relates-to
|
|
120
|
+
note: Text content for the row
|
|
121
|
+
- to: list-item-image
|
|
122
|
+
rel: relates-to
|
|
123
|
+
note: Thumbnail image for the row
|
|
124
|
+
sourceFiles:
|
|
125
|
+
- platform: react
|
|
126
|
+
file: packages/ui/src/components/list/List.tsx
|
|
127
|
+
imports:
|
|
128
|
+
- platform: react
|
|
129
|
+
code: import { List } from '@sanity/ui'
|
|
130
|
+
package: '@sanity/ui'
|
|
131
|
+
traits:
|
|
132
|
+
- traitType: variant
|
|
133
|
+
kind: enum
|
|
134
|
+
id: density
|
|
135
|
+
description: Composite prop setting padding, gap, and minimum height together.
|
|
136
|
+
values:
|
|
137
|
+
- id: compact
|
|
138
|
+
description: Padding 1, gap 2, minimum height 33px.
|
|
139
|
+
- id: regular
|
|
140
|
+
description: Padding 2, gap 2, minimum height 37px (default).
|
|
141
|
+
- id: loose
|
|
142
|
+
description: Padding 3, gap 3, minimum height 45px.
|
|
143
|
+
|
|
144
|
+
$extensions:
|
|
145
|
+
com.sanity.ui:
|
|
146
|
+
implementationStatus:
|
|
147
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
148
|
+
implemented: true
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list
|
|
3
|
+
name: List
|
|
4
|
+
description: A compound component for displaying structured rows.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, rows, item, compound, document, navigation]
|
|
7
|
+
status:
|
|
8
|
+
status: beta
|
|
9
|
+
sections:
|
|
10
|
+
- kind: guidelines
|
|
11
|
+
for: all
|
|
12
|
+
framing: when-to-use
|
|
13
|
+
title: When to use
|
|
14
|
+
items:
|
|
15
|
+
- level: should
|
|
16
|
+
statement: To list documents in a navigational or summary context.
|
|
17
|
+
- level: should
|
|
18
|
+
statement: Any repeating vertical list of scannable rows.
|
|
19
|
+
- level: should-not
|
|
20
|
+
statement: For simple stacked content with no row structure. Use VStack instead.
|
|
21
|
+
alternatives:
|
|
22
|
+
- to: v-stack
|
|
23
|
+
- level: should-not
|
|
24
|
+
statement: For action menus or dropdown options. Use List.ButtonItem inside a Popover instead.
|
|
25
|
+
alternatives:
|
|
26
|
+
- to: popover
|
|
27
|
+
- to: list-button-item
|
|
28
|
+
- level: should-not
|
|
29
|
+
statement: For table data with column headers. Use a table element directly.
|
|
30
|
+
- kind: guidelines
|
|
31
|
+
for: all
|
|
32
|
+
framing: how-to-use
|
|
33
|
+
items:
|
|
34
|
+
- level: should
|
|
35
|
+
statement: Use density='compact' on the List.Item or List.ButtonItem rows in sidebars and panels, and density='loose' for touch-first UIs.
|
|
36
|
+
- level: should
|
|
37
|
+
statement: Use as='ol' when list order is meaningful (ranked results, step sequences).
|
|
38
|
+
- level: should
|
|
39
|
+
statement: 'Keep each of the start and end slots compact — one element only: a thumbnail or icon for start; a button, badge, or timestamp for end.'
|
|
40
|
+
- id: don-list-itemtext-outside-list
|
|
41
|
+
level: must-not
|
|
42
|
+
statement: Don't use List.ItemText outside of List.Item. It relies on the flex layout of the parent row.
|
|
43
|
+
- level: must-not
|
|
44
|
+
statement: "Don't place two or more buttons or other interactive elements in the end slot (or the start slot). It creates an unclear tab order."
|
|
45
|
+
- level: must-not
|
|
46
|
+
statement: Don't override List.ItemImage dimensions with inline styles. The fixed size keeps rows visually even.
|
|
47
|
+
- kind: guidelines
|
|
48
|
+
for: agent
|
|
49
|
+
framing: how-to-use
|
|
50
|
+
items:
|
|
51
|
+
- level: must
|
|
52
|
+
statement: List has subcomponents, List.Item, List.ItemText, List.ItemImage and List.ButtonItem. Each has its own entry, `list-item`, `list-item-text`, `list-item-image` and `list-button-item`. Read each one's entry in `docs/components/` before you write it. Its props are not listed here.
|
|
53
|
+
- id: subcomponents-not-named-exports
|
|
54
|
+
level: must
|
|
55
|
+
statement: "Access subcomponents via dot notation: List.Item, List.ItemText, List.ItemImage, List.ButtonItem. They are not separate named exports, so don't import them that way."
|
|
56
|
+
- level: must
|
|
57
|
+
statement: Provide alt on every List.ItemImage — it renders a native <img> with no implicit accessible name.
|
|
58
|
+
- id: no-density-on-list
|
|
59
|
+
level: must-not
|
|
60
|
+
statement: Do not set `density` on List. It has no `density` prop, and `<List density="compact">` is a TypeScript error. Set it on each List.Item or List.ButtonItem.
|
|
61
|
+
- level: must-not
|
|
62
|
+
statement: List.Item does not support the `as` prop — it always renders as `<li>`. Passing `as` to List.Item causes a TypeScript error.
|
|
63
|
+
- level: must-not
|
|
64
|
+
statement: There is no `trailing` prop on List.Item — it was replaced by `start` and `end` in a breaking change. `trailing={...}` is a TypeScript error (unknown prop); use `end` instead.
|
|
65
|
+
|
|
66
|
+
- kind: guidelines
|
|
67
|
+
for: all
|
|
68
|
+
title: Content
|
|
69
|
+
tags: [content]
|
|
70
|
+
items:
|
|
71
|
+
- refs:
|
|
72
|
+
- to: content-guidelines#sentence-case-all-system-set
|
|
73
|
+
rel: same-as
|
|
74
|
+
- level: should
|
|
75
|
+
statement: Keep titles short. Aim for one line at the target container width.
|
|
76
|
+
- level: should
|
|
77
|
+
statement: Use `subtitle` for metadata, not for key actions or status.
|
|
78
|
+
- refs:
|
|
79
|
+
- to: content-guidelines#plain-language
|
|
80
|
+
rel: same-as
|
|
81
|
+
- kind: guidelines
|
|
82
|
+
for: all
|
|
83
|
+
title: Accessibility
|
|
84
|
+
tags: [accessibility]
|
|
85
|
+
items:
|
|
86
|
+
- id: list-item-image-alt-required
|
|
87
|
+
level: must
|
|
88
|
+
statement: Always pass `alt` on `List.ItemImage`. Use `alt=""` only if the image is decorative and the title text already describes the item.
|
|
89
|
+
- level: must
|
|
90
|
+
statement: Buttons in `start` or `end` must have an accessible name via `aria-label` or visible text.
|
|
91
|
+
- level: should
|
|
92
|
+
statement: '`List` renders as `<ul>` by default. Use `as="ol"` when order is meaningful.'
|
|
93
|
+
- level: must-not
|
|
94
|
+
statement: '`List.Item` renders as `<li>`. Do not use it outside a `<ul>` or `<ol>`.'
|
|
95
|
+
|
|
96
|
+
alternatives:
|
|
97
|
+
- to: v-stack
|
|
98
|
+
note: Plain vertical stacking without list semantics
|
|
99
|
+
- to: list-button-item
|
|
100
|
+
note: Action rows inside a Popover
|
|
101
|
+
refs:
|
|
102
|
+
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32244-2
|
|
103
|
+
rel: design
|
|
104
|
+
role: Figma component (v5)
|
|
105
|
+
- to: space
|
|
106
|
+
rel: relates-to
|
|
107
|
+
- to: list-button-item
|
|
108
|
+
rel: relates-to
|
|
109
|
+
note: Action rows inside a Popover
|
|
110
|
+
- to: badge
|
|
111
|
+
rel: relates-to
|
|
112
|
+
note: Good as an `end` element for status indicators
|
|
113
|
+
- to: list-button-item
|
|
114
|
+
rel: relates-to
|
|
115
|
+
note: The interactive/selectable variant of **List.Item**
|
|
116
|
+
- to: avatar
|
|
117
|
+
rel: relates-to
|
|
118
|
+
note: Good as a start element before `List.ItemText`
|
|
119
|
+
sourceFiles:
|
|
120
|
+
- platform: react
|
|
121
|
+
file: packages/ui/src/components/list/List.tsx
|
|
122
|
+
imports:
|
|
123
|
+
- platform: react
|
|
124
|
+
code: import { List } from '@sanity/ui'
|
|
125
|
+
package: '@sanity/ui'
|
|
126
|
+
$extensions:
|
|
127
|
+
com.sanity.ui:
|
|
128
|
+
implementationStatus:
|
|
129
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
130
|
+
implemented: true
|
|
131
|
+
migrationGuide:
|
|
132
|
+
context: 'Migration guide for this component, covering the codemod and the changes it cannot make. Held as an extension because it is temporary: migration tooling and porting agents read it, and it should be dropped when Sanity UI 3 support ends.'
|
|
133
|
+
guidance: |-
|
|
134
|
+
List is new in v5, with no direct v3 match. v3 list patterns were built with `Stack` \+ `Card` or custom `<ul>/<li>` markup.
|
|
135
|
+
|
|
136
|
+
The new `List` formalizes that pattern. It adds built-in density, start/end slots, and an image slot.
|
|
137
|
+
|
|
138
|
+
### **Key differences**
|
|
139
|
+
|
|
140
|
+
- `List.Item` handles its own layout. No need to wrap rows in `Card` or `Box` for spacing.
|
|
141
|
+
- `List.ItemText` has built-in sizing and truncation. No need to set `Text` props on each item.
|
|
142
|
+
- `List.ItemImage` provides a standard thumbnail slot with fixed sizing and rounded corners.
|
|
143
|
+
|
|
144
|
+
### **If you used Stack \+ Card rows**
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
// v3 pattern
|
|
148
|
+
<Stack space={1}>
|
|
149
|
+
<Card padding={3}>
|
|
150
|
+
<Flex align="center" gap={3}>
|
|
151
|
+
<Text weight="semibold">{item.title}</Text>
|
|
152
|
+
</Flex>
|
|
153
|
+
</Card>
|
|
154
|
+
</Stack>
|
|
155
|
+
|
|
156
|
+
// v5 equivalent
|
|
157
|
+
<List>
|
|
158
|
+
<List.Item>
|
|
159
|
+
<List.ItemText title={item.title} />
|
|
160
|
+
</List.Item>
|
|
161
|
+
</List>
|
|
162
|
+
```
|