@sanity/ui 5.0.0-alpha.26 → 5.0.0-alpha.28
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/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/docs/components/box.dsds.yaml +2 -2
- package/docs/components/button.dsds.yaml +4 -3
- package/docs/components/card.dsds.yaml +1 -1
- package/docs/components/dialog.dsds.yaml +2 -2
- package/docs/components/divider.dsds.yaml +1 -1
- package/docs/components/flex.dsds.yaml +1 -1
- package/docs/components/grid.dsds.yaml +3 -3
- package/docs/components/h-stack.dsds.yaml +1 -1
- package/docs/components/icon-button.dsds.yaml +1 -1
- package/docs/components/indicator-stack.dsds.yaml +1 -1
- package/docs/components/indicator.dsds.yaml +2 -1
- package/docs/components/list-item-button.dsds.yaml +150 -0
- package/docs/components/list-item-image.dsds.yaml +6 -3
- package/docs/components/list-item.dsds.yaml +51 -66
- package/docs/components/list.dsds.yaml +26 -30
- package/docs/components/popover.dsds.yaml +3 -3
- package/docs/components/press-area.dsds.yaml +3 -3
- package/docs/components/search-input.dsds.yaml +115 -0
- package/docs/components/select.dsds.yaml +1 -1
- package/docs/components/tabs-panel.dsds.yaml +1 -1
- package/docs/components/tooltip.dsds.yaml +1 -1
- package/docs/components/v-stack.dsds.yaml +3 -2
- package/docs/components/visually-hidden.dsds.yaml +1 -1
- package/docs/foundations/color-guidelines.dsds.yaml +6 -6
- package/docs/index.dsds.yaml +20 -19
- package/docs/overview/api-essentials.dsds.yaml +2 -2
- package/docs/overview/component-reference.dsds.yaml +4 -4
- package/docs/overview/quick-start.dsds.yaml +1 -0
- package/docs/patterns/confirmation-dialogs.dsds.yaml +3 -3
- package/docs/patterns/layouts.dsds.yaml +8 -7
- package/docs/patterns/navigation.dsds.yaml +37 -37
- package/docs/patterns/responsive.dsds.yaml +1 -1
- package/docs/tokens/dtcg/README.md +4 -4
- package/docs/tokens/dtcg/css/color.css +1 -1
- package/docs/tokens/dtcg/css/semantic.css +7 -7
- package/docs/tokens/dtcg/json/color.tokens.json +2 -2
- package/docs/tokens/dtcg/json/semantic.tokens.json +18 -21
- package/package.json +2 -2
- package/src/components/tabs/tabs.css +1 -1
- package/src/utils/getProps.test.ts +22 -0
- package/src/utils/getProps.ts +5 -1
- package/src/version.ts +2 -2
- package/docs/components/list-button-item.dsds.yaml +0 -103
- package/docs/components/list-item-text.dsds.yaml +0 -80
|
@@ -56,7 +56,7 @@ sections:
|
|
|
56
56
|
- refs:
|
|
57
57
|
- to: api-essentials#sizing-is-a-css-string
|
|
58
58
|
rel: same-as
|
|
59
|
-
- id: box-styling-props
|
|
59
|
+
- id: box-styling-props
|
|
60
60
|
level: should
|
|
61
61
|
statement: Use Box's styling props (tone, padding, width, and similar) to adjust visual appearance rather than inline styles — every visual style Box supports through a prop is set through that prop, not the style attribute.
|
|
62
62
|
example:
|
|
@@ -92,7 +92,7 @@ sections:
|
|
|
92
92
|
alternatives:
|
|
93
93
|
- to: flex
|
|
94
94
|
checkedBy: manual
|
|
95
|
-
- id: box-no-style-prop
|
|
95
|
+
- id: box-no-style-prop
|
|
96
96
|
level: must-not
|
|
97
97
|
statement: Don't use the style prop for attributes that have a matching Box prop (width, height, borderRadius, background, and similar) — no Box element should set these through style.
|
|
98
98
|
example:
|
|
@@ -33,9 +33,9 @@ sections:
|
|
|
33
33
|
alternatives:
|
|
34
34
|
- to: link
|
|
35
35
|
- level: should-not
|
|
36
|
-
statement: 'As nav items within a sidebar or menu. Use List.
|
|
36
|
+
statement: 'As nav items within a sidebar or menu. Use List.ItemButton instead.'
|
|
37
37
|
alternatives:
|
|
38
|
-
- to: list-button
|
|
38
|
+
- to: list-item-button
|
|
39
39
|
- level: should-not
|
|
40
40
|
statement: To switch views on a screen. Use Tab instead. The Tab component has ARIA attributes that make keyboard navigation accessible.
|
|
41
41
|
alternatives:
|
|
@@ -107,6 +107,7 @@ sections:
|
|
|
107
107
|
refines:
|
|
108
108
|
- to: accessibility-guidelines#disabled-control-no-tooltip
|
|
109
109
|
- level: must-not
|
|
110
|
+
id: text-label-required
|
|
110
111
|
statement: Don't use Button without a text label. Button relies on the text label to describe its purpose. Use IconButton in cases where the icon is the only visual indicator.
|
|
111
112
|
- level: must
|
|
112
113
|
statement: Button defaults to `type="button"`. To submit a form, set `type="submit"` explicitly.
|
|
@@ -186,7 +187,7 @@ uses:
|
|
|
186
187
|
alternatives:
|
|
187
188
|
- to: icon-button
|
|
188
189
|
- to: link
|
|
189
|
-
- to: list-button
|
|
190
|
+
- to: list-item-button
|
|
190
191
|
- to: switch
|
|
191
192
|
refs:
|
|
192
193
|
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32075-2332
|
|
@@ -18,7 +18,7 @@ sections:
|
|
|
18
18
|
statement: To create visual separation between content regions.
|
|
19
19
|
- level: should
|
|
20
20
|
statement: To wrap content that needs consistent internal padding and rounded corners.
|
|
21
|
-
- id:
|
|
21
|
+
- id: no-surface-use-box
|
|
22
22
|
level: should-not
|
|
23
23
|
statement: For layout without a distinct visual surface — use Box or Flex.
|
|
24
24
|
alternatives:
|
|
@@ -61,7 +61,7 @@ sections:
|
|
|
61
61
|
- level: must
|
|
62
62
|
statement: Dialog must be cancelable or dismissible. Users should not be trapped into agreeing or initiating an action.
|
|
63
63
|
tags: [interaction]
|
|
64
|
-
- id: destructive-
|
|
64
|
+
- id: destructive-title-names-target
|
|
65
65
|
level: must
|
|
66
66
|
statement: 'Destructive-action Dialogs must name the action and its target in the title — for example, "Delete [PAGE NAME]?", not a vague title like "Delete?". The consequence goes in the body, not the title: what will be lost and whether it can be recovered.'
|
|
67
67
|
checks:
|
|
@@ -77,7 +77,7 @@ sections:
|
|
|
77
77
|
tags: [content]
|
|
78
78
|
- tags: [content]
|
|
79
79
|
refs:
|
|
80
|
-
- to: shared-foundations#destructive-
|
|
80
|
+
- to: shared-foundations#destructive-critical-tone
|
|
81
81
|
rel: same-as
|
|
82
82
|
- level: should
|
|
83
83
|
statement: >-
|
|
@@ -64,7 +64,7 @@ sections:
|
|
|
64
64
|
items:
|
|
65
65
|
- level: should
|
|
66
66
|
statement: Divider renders as `<hr>`, which carries the implicit ARIA role `separator`. Screen readers announce it as a thematic break. Use it only when the content on either side is distinct — not for visual spacing alone.
|
|
67
|
-
- id: divider-focusable
|
|
67
|
+
- id: divider-not-focusable
|
|
68
68
|
level: should
|
|
69
69
|
statement: Divider is not focusable and has no keyboard interaction. Do not add `onClick` or other event handlers to it.
|
|
70
70
|
- level: should
|
|
@@ -88,7 +88,7 @@ sections:
|
|
|
88
88
|
$extensions:
|
|
89
89
|
io.jev:
|
|
90
90
|
type: boolean
|
|
91
|
-
- id: flex-reverse-
|
|
91
|
+
- id: flex-reverse-order
|
|
92
92
|
level: must-not
|
|
93
93
|
statement: Don't use row-reverse or column-reverse to change sort order — these only change visual order, not tab order. When a reverse direction is used, the DOM order of child elements must still match the intended reading and tab order.
|
|
94
94
|
example:
|
|
@@ -39,7 +39,7 @@ sections:
|
|
|
39
39
|
- refs:
|
|
40
40
|
- to: api-essentials#sizing-is-a-css-string
|
|
41
41
|
rel: same-as
|
|
42
|
-
- id: grid-
|
|
42
|
+
- id: grid-columns-fluid-units
|
|
43
43
|
level: should
|
|
44
44
|
statement: 'Use gridTemplateColumns with repeat() and fr units, minmax(), auto, or responsive arrays to build layouts that adapt gracefully — avoid bare pixel values.'
|
|
45
45
|
example:
|
|
@@ -57,14 +57,14 @@ sections:
|
|
|
57
57
|
- to: shared-foundations#layout-primitive-no-text-styles
|
|
58
58
|
rel: same-as
|
|
59
59
|
tags: [content]
|
|
60
|
-
- id: no-visual-reorder
|
|
60
|
+
- id: grid-no-visual-reorder
|
|
61
61
|
level: must-not
|
|
62
62
|
statement: Don't use CSS order, gridColumn, or gridRow to visually reorder items away from their DOM order — screen readers follow DOM order, so the visual order of grid items should match their DOM source order.
|
|
63
63
|
example:
|
|
64
64
|
title: How to satisfy this
|
|
65
65
|
description: Tab through the grid with keyboard-only navigation and confirm focus moves in the same sequence as the visual reading order. Inspect the rendered DOM in browser DevTools and confirm the sequence of child nodes matches the left-to-right, top-to-bottom visual order of the grid. Use a screen reader and verify the announced order of items matches what a sighted user would read.
|
|
66
66
|
checkedBy: manual
|
|
67
|
-
- id: no-hardcoded-px
|
|
67
|
+
- id: grid-no-hardcoded-px
|
|
68
68
|
level: must-not
|
|
69
69
|
statement: Don't hardcode pixel values in gridTemplateColumns when a fluid unit like fr, minmax(), or auto would serve the same purpose more resiliently.
|
|
70
70
|
example:
|
|
@@ -23,7 +23,7 @@ sections:
|
|
|
23
23
|
statement: For full-width rows that stretch across their container. Use Flex instead.
|
|
24
24
|
alternatives:
|
|
25
25
|
- to: flex
|
|
26
|
-
- id:
|
|
26
|
+
- id: hstack-custom-alignment
|
|
27
27
|
level: should-not
|
|
28
28
|
statement: For horizontal layouts that need custom alignment, or that must stay on one line. Use Flex instead.
|
|
29
29
|
alternatives:
|
|
@@ -88,7 +88,7 @@ sections:
|
|
|
88
88
|
- level: must
|
|
89
89
|
statement: "Use tone='critical' for destructive actions, with an icon that signals the action, like TrashIcon."
|
|
90
90
|
refines:
|
|
91
|
-
- to: shared-foundations#destructive-
|
|
91
|
+
- to: shared-foundations#destructive-critical-tone
|
|
92
92
|
- level: should
|
|
93
93
|
statement: IconButton defaults to level='primary', like Button. Set level='tertiary' on toolbar and list row actions. Leave `level` out only on the single most critical action in a group.
|
|
94
94
|
- level: should
|
|
@@ -40,6 +40,7 @@ sections:
|
|
|
40
40
|
framing: how-to-use
|
|
41
41
|
items:
|
|
42
42
|
- level: must
|
|
43
|
+
id: label-when-only-signal
|
|
43
44
|
statement: 'Provide a label when the indicator is the only signal for a status. Without it, the dot is invisible to screen readers. Omit label only when adjacent visible text conveys the same status.'
|
|
44
45
|
- level: should
|
|
45
46
|
statement: 'Pair the indicator with a visible text label. To show the status in a Tooltip instead, wrap Indicator in PressArea. The Tooltip needs it as a target.'
|
|
@@ -62,7 +63,7 @@ sections:
|
|
|
62
63
|
level: should
|
|
63
64
|
statement: Omit `label` only when adjacent visible text already conveys the status. The dot becomes `aria-hidden` in that case.
|
|
64
65
|
refines:
|
|
65
|
-
- to: indicator#
|
|
66
|
+
- to: indicator#label-when-only-signal
|
|
66
67
|
- level: should
|
|
67
68
|
statement: For document or item status (Published, Draft), pair the dot with a shape or icon difference in addition to tone. Put the status word in the row's accessible name or visible text — not only in the dot's color (WCAG 1.4.1).
|
|
68
69
|
refines:
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
kind: component
|
|
2
|
+
id: list-item-button
|
|
3
|
+
name: List.ItemButton
|
|
4
|
+
description: The pressable row inside a List.
|
|
5
|
+
metadata:
|
|
6
|
+
tags: [list, item, row, button, interactive, selectable, navigation, current]
|
|
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. For example, a document in a browser list, a sidebar nav item, or a selectable row in a picker.
|
|
17
|
+
- level: should
|
|
18
|
+
statement: A navigation row. Pass `as="a"` and `href` so the row is a real link.
|
|
19
|
+
- level: should-not
|
|
20
|
+
statement: A row with no interaction. Use 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 or anchor break keyboard and screen-reader expectations. Use one press target per row.
|
|
25
|
+
- kind: guidelines
|
|
26
|
+
for: all
|
|
27
|
+
framing: how-to-use
|
|
28
|
+
items:
|
|
29
|
+
- id: list-item-button-in-list-item
|
|
30
|
+
level: must
|
|
31
|
+
statement: Wrap every List.ItemButton in a List.Item. A List renders a <ul>, which accepts only <li> children, and List.ItemButton renders a button or anchor.
|
|
32
|
+
- level: should
|
|
33
|
+
statement: Pass the main label as `text` and the secondary line as `subtext`. They are clamped to one line each. Do not wrap them in Text.
|
|
34
|
+
- level: should
|
|
35
|
+
statement: Set `density` on each row to match the surrounding layout. Density sets the row's gap, horizontal padding and minimum height together.
|
|
36
|
+
- level: should
|
|
37
|
+
statement: Pass `current` to mark the active row, as `current={isActive}`. The component sets `aria-current="true"` for `true`, and styles the row only for that value.
|
|
38
|
+
- level: must-not
|
|
39
|
+
statement: Don't use `aria-current` with a string such as "page" and expect the active style. The style applies only when the attribute is "true". Use `current` and let the component set the attribute.
|
|
40
|
+
- level: must-not
|
|
41
|
+
statement: Don't place a button, link or other interactive element inside List.ItemButton, in `start`, `end` or children.
|
|
42
|
+
- level: must-not
|
|
43
|
+
statement: Don't use List.ItemButton outside of a List.Item inside a List.
|
|
44
|
+
- kind: guidelines
|
|
45
|
+
for: agent
|
|
46
|
+
framing: how-to-use
|
|
47
|
+
items:
|
|
48
|
+
- id: button-props-forward
|
|
49
|
+
level: must
|
|
50
|
+
statement: Props other than `as`, `current`, `density`, `start`, `end`, `text`, `subtext` and `children` pass to the inner button or anchor. Put `onClick`, `href` and `aria-*` on List.ItemButton.
|
|
51
|
+
- refs:
|
|
52
|
+
- to: list#subcomponents-not-named-exports
|
|
53
|
+
rel: same-as
|
|
54
|
+
- level: must-not
|
|
55
|
+
statement: Don't pass `selected` to List.ItemButton. It is not a prop. Use `current`.
|
|
56
|
+
- level: must-not
|
|
57
|
+
statement: Don't use onClick on a List.Item. List.Item is not interactive and has none of the keyboard handling List.ItemButton provides. Use List.ItemButton for any pressable row.
|
|
58
|
+
- kind: section
|
|
59
|
+
for: all
|
|
60
|
+
freeform:
|
|
61
|
+
- title: Slots and density
|
|
62
|
+
body: |-
|
|
63
|
+
Content renders in this order: `start`, then the text block made of `text`, `subtext` and children, then `end`. Use `start` for a thumbnail or icon. Use `end` for a non-interactive badge, icon or timestamp.
|
|
64
|
+
|
|
65
|
+
| Density | gap | paddingX | minHeight |
|
|
66
|
+
|---------|-----|----------|-----------|
|
|
67
|
+
| `compact` | 2 | 1 | 33px |
|
|
68
|
+
| `regular` | 2 | 2 | 37px |
|
|
69
|
+
| `loose` | 3 | 3 | 45px |
|
|
70
|
+
|
|
71
|
+
`regular` is the default. Density is a single prop. Set it, rather than padding or height, on the row.
|
|
72
|
+
|
|
73
|
+
- title: Examples
|
|
74
|
+
body: |-
|
|
75
|
+
A list of documents, where one is the current row:
|
|
76
|
+
|
|
77
|
+
```tsx
|
|
78
|
+
import { Badge, List } from '@sanity/ui'
|
|
79
|
+
|
|
80
|
+
<List>
|
|
81
|
+
{documents.map((doc) => (
|
|
82
|
+
<List.Item key={doc.id}>
|
|
83
|
+
<List.ItemButton
|
|
84
|
+
onClick={() => setActiveId(doc.id)}
|
|
85
|
+
current={activeId === doc.id}
|
|
86
|
+
text={doc.title}
|
|
87
|
+
subtext={doc.updatedAt}
|
|
88
|
+
start={<List.ItemImage src={doc.thumbnailUrl} alt="" />}
|
|
89
|
+
end={<Badge>{doc.status}</Badge>}
|
|
90
|
+
/>
|
|
91
|
+
</List.Item>
|
|
92
|
+
))}
|
|
93
|
+
</List>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
A navigation row that renders as a link:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
import { List } from '@sanity/ui'
|
|
100
|
+
|
|
101
|
+
<List>
|
|
102
|
+
<List.Item>
|
|
103
|
+
<List.ItemButton as="a" href="/guides" current text="Guides" />
|
|
104
|
+
</List.Item>
|
|
105
|
+
</List>
|
|
106
|
+
```
|
|
107
|
+
alternatives:
|
|
108
|
+
- to: list-item
|
|
109
|
+
note: The non-interactive row. See **List.Item**
|
|
110
|
+
- to: press-area
|
|
111
|
+
note: The lower-level interaction primitive List.ItemButton is built on
|
|
112
|
+
refs:
|
|
113
|
+
- to: list
|
|
114
|
+
rel: relates-to
|
|
115
|
+
note: The parent component. See **List** for full compound component docs
|
|
116
|
+
- to: list-item
|
|
117
|
+
rel: relates-to
|
|
118
|
+
note: The wrapper every List.ItemButton sits inside
|
|
119
|
+
- to: list-item-image
|
|
120
|
+
rel: relates-to
|
|
121
|
+
note: Thumbnail for the start slot
|
|
122
|
+
sourceFiles:
|
|
123
|
+
- platform: react
|
|
124
|
+
file: packages/ui/src/components/list/List.tsx
|
|
125
|
+
imports:
|
|
126
|
+
- platform: react
|
|
127
|
+
code: import { List } from '@sanity/ui'
|
|
128
|
+
package: '@sanity/ui'
|
|
129
|
+
traits:
|
|
130
|
+
- traitType: state
|
|
131
|
+
kind: boolean
|
|
132
|
+
id: current
|
|
133
|
+
description: Marks the row as the current item. Sets aria-current="true", which the component styles as the active row.
|
|
134
|
+
- traitType: variant
|
|
135
|
+
kind: enum
|
|
136
|
+
id: density
|
|
137
|
+
description: Composite prop setting horizontal padding, gap and minimum height together.
|
|
138
|
+
values:
|
|
139
|
+
- id: compact
|
|
140
|
+
description: Padding 1, gap 2, minimum height 33px.
|
|
141
|
+
- id: regular
|
|
142
|
+
description: Padding 2, gap 2, minimum height 37px (default).
|
|
143
|
+
- id: loose
|
|
144
|
+
description: Padding 3, gap 3, minimum height 45px.
|
|
145
|
+
|
|
146
|
+
$extensions:
|
|
147
|
+
com.sanity.ui:
|
|
148
|
+
implementationStatus:
|
|
149
|
+
context: Implementation status. Lets a tool tell a component that is coming from one that does not exist, without parsing the status note.
|
|
150
|
+
implemented: true
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
kind: component
|
|
2
2
|
id: list-item-image
|
|
3
3
|
name: List.ItemImage
|
|
4
|
-
description: A thumbnail image
|
|
4
|
+
description: A thumbnail image for a List row.
|
|
5
5
|
metadata:
|
|
6
6
|
tags: [list, item, image, thumbnail, avatar]
|
|
7
7
|
status:
|
|
@@ -52,15 +52,18 @@ sections:
|
|
|
52
52
|
<List.ItemImage src="/thumb.jpg" alt="" style={{ width: 80, height: 80 }} />
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
On a pressable row, pass List.ItemImage as the `start` of List.ItemButton. On a non-interactive row, put it first among the children of List.Item.
|
|
56
56
|
|
|
57
57
|
refs:
|
|
58
58
|
- href: https://www.figma.com/design/5mhVqXlldJEEB2VWZeKQ4i/Sanity-UI?node-id=32249-481
|
|
59
59
|
rel: design
|
|
60
60
|
role: Figma component (v5)
|
|
61
|
+
- to: list-item-button
|
|
62
|
+
rel: relates-to
|
|
63
|
+
note: The pressable row. Pass the image as its `start`
|
|
61
64
|
- to: list-item
|
|
62
65
|
rel: relates-to
|
|
63
|
-
note: The
|
|
66
|
+
note: The non-interactive row
|
|
64
67
|
- to: list
|
|
65
68
|
rel: relates-to
|
|
66
69
|
note: The root list component — see **List** for full compound component docs
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
kind: component
|
|
2
2
|
id: list-item
|
|
3
3
|
name: List.Item
|
|
4
|
-
description: A
|
|
4
|
+
description: A non-interactive row inside a List.
|
|
5
5
|
metadata:
|
|
6
6
|
tags: [list, item, row, li]
|
|
7
7
|
status:
|
|
@@ -9,16 +9,27 @@ metadata:
|
|
|
9
9
|
sections:
|
|
10
10
|
- kind: guidelines
|
|
11
11
|
for: all
|
|
12
|
-
framing:
|
|
12
|
+
framing: when-to-use
|
|
13
|
+
title: When to use
|
|
13
14
|
items:
|
|
14
15
|
- level: should
|
|
15
|
-
statement:
|
|
16
|
+
statement: A row that shows content and takes no action, such as a summary entry or a read-only record.
|
|
17
|
+
- level: should-not
|
|
18
|
+
statement: A row the user can press, select or navigate. Use List.ItemButton instead.
|
|
19
|
+
alternatives:
|
|
20
|
+
- to: list-item-button
|
|
21
|
+
- kind: guidelines
|
|
22
|
+
for: all
|
|
23
|
+
framing: how-to-use
|
|
24
|
+
items:
|
|
16
25
|
- id: don-list-item-outside-list
|
|
17
26
|
level: must-not
|
|
18
|
-
statement: Don't use List.Item outside of a List
|
|
27
|
+
statement: Don't use List.Item outside of a List. It renders as <li> and requires a <ul> or <ol> parent.
|
|
28
|
+
- level: should
|
|
29
|
+
statement: Lay out the row's children yourself, for example with Flex, when the row holds an image and text. List.Item adds no padding and no density.
|
|
19
30
|
- id: don-place-more-one-interactive
|
|
20
31
|
level: must-not
|
|
21
|
-
statement: Don't place
|
|
32
|
+
statement: Don't place an interactive element, such as a button or link, inside List.Item. Use List.ItemButton for the row's action, so it has one press target.
|
|
22
33
|
- kind: guidelines
|
|
23
34
|
for: agent
|
|
24
35
|
framing: how-to-use
|
|
@@ -27,21 +38,18 @@ sections:
|
|
|
27
38
|
- to: list#subcomponents-not-named-exports
|
|
28
39
|
rel: same-as
|
|
29
40
|
- level: must-not
|
|
30
|
-
statement: Do not
|
|
41
|
+
statement: Do not use List.Item for an interactive row. Use List.ItemButton, which takes `density`, `start`, `end`, `text` and `subtext`. List.Item has none of these props.
|
|
31
42
|
- level: must-not
|
|
32
|
-
statement:
|
|
33
|
-
|
|
43
|
+
statement: Do not pass paddingX, paddingY, padding or margin to List.Item. Those props are not part of its API.
|
|
44
|
+
- level: must-not
|
|
45
|
+
statement: Don't pass `trailing` to List.Item. Use `end` on List.ItemButton.
|
|
34
46
|
- kind: guidelines
|
|
35
47
|
for: all
|
|
36
48
|
title: Accessibility
|
|
37
49
|
tags: [accessibility]
|
|
38
50
|
items:
|
|
39
|
-
- level: must
|
|
40
|
-
statement: Buttons in `start` or `end` must have an accessible name via `aria-label` or visible text.
|
|
41
51
|
- level: should
|
|
42
|
-
statement:
|
|
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.
|
|
52
|
+
statement: A decorative preview image (`List.ItemImage`) whose `alt` repeats the row's own name announces that name twice. Mark it decorative instead.
|
|
45
53
|
- level: must-not
|
|
46
54
|
statement: '`List.Item` renders as `<li>`. Do not use it outside a `<ul>` or `<ol>`.'
|
|
47
55
|
- kind: section
|
|
@@ -49,62 +57,51 @@ sections:
|
|
|
49
57
|
freeform:
|
|
50
58
|
- title: Composition pattern
|
|
51
59
|
body: |-
|
|
52
|
-
List.Item is always a direct child of List.
|
|
60
|
+
List.Item is always a direct child of List. Its children render as the row's content. It has no start or end slots, because those belong to List.ItemButton.
|
|
53
61
|
|
|
54
62
|
```tsx
|
|
55
|
-
import {
|
|
56
|
-
import { EllipsisVerticalIcon } from '@sanity/icons/EllipsisVertical'
|
|
63
|
+
import { Flex, List, Text } from '@sanity/ui'
|
|
57
64
|
|
|
58
65
|
<List>
|
|
59
|
-
<List.Item
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
icon={EllipsisVerticalIcon}
|
|
65
|
-
aria-label="More actions"
|
|
66
|
-
/>
|
|
67
|
-
}
|
|
68
|
-
>
|
|
69
|
-
<List.ItemText title="My document" subtitle="Last edited 2 hours ago" />
|
|
66
|
+
<List.Item>
|
|
67
|
+
<Flex align="center" gap={3}>
|
|
68
|
+
<List.ItemImage src="/thumb.jpg" alt="" />
|
|
69
|
+
<Text size={1}>My document</Text>
|
|
70
|
+
</Flex>
|
|
70
71
|
</List.Item>
|
|
71
72
|
</List>
|
|
72
73
|
```
|
|
73
74
|
|
|
74
|
-
|
|
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`.
|
|
75
|
+
For a row the user can press, put a List.ItemButton inside the List.Item instead. See **List.ItemButton** for the density values and slots.
|
|
84
76
|
|
|
85
77
|
- kind: section
|
|
86
78
|
for: all
|
|
87
79
|
freeform:
|
|
88
80
|
- title: Examples
|
|
89
81
|
body: |-
|
|
90
|
-
|
|
82
|
+
A non-interactive row, with a thumbnail and text:
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { Flex, List, Text } from '@sanity/ui'
|
|
91
86
|
|
|
87
|
+
<List>
|
|
88
|
+
<List.Item>
|
|
89
|
+
<Flex align="center" gap={3}>
|
|
90
|
+
<List.ItemImage src="/thumb.jpg" alt="Document thumbnail" />
|
|
91
|
+
<Text size={1}>My document</Text>
|
|
92
|
+
</Flex>
|
|
93
|
+
</List.Item>
|
|
94
|
+
</List>
|
|
92
95
|
```
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
|
|
97
|
+
A pressable row. The List.ItemButton is the only child, so the row has one press target:
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
import { List } from '@sanity/ui'
|
|
95
101
|
|
|
96
102
|
<List>
|
|
97
|
-
<List.Item
|
|
98
|
-
|
|
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" />
|
|
103
|
+
<List.Item>
|
|
104
|
+
<List.ItemButton text="My document" subtext="Last edited 2 hours ago" />
|
|
108
105
|
</List.Item>
|
|
109
106
|
</List>
|
|
110
107
|
```
|
|
@@ -114,10 +111,10 @@ refs:
|
|
|
114
111
|
role: Figma component (v5)
|
|
115
112
|
- to: list
|
|
116
113
|
rel: relates-to
|
|
117
|
-
note: The parent component
|
|
118
|
-
- to: list-item-
|
|
114
|
+
note: The parent component. See **List** for full compound component docs
|
|
115
|
+
- to: list-item-button
|
|
119
116
|
rel: relates-to
|
|
120
|
-
note:
|
|
117
|
+
note: The pressable row. Put it inside List.Item
|
|
121
118
|
- to: list-item-image
|
|
122
119
|
rel: relates-to
|
|
123
120
|
note: Thumbnail image for the row
|
|
@@ -128,18 +125,6 @@ imports:
|
|
|
128
125
|
- platform: react
|
|
129
126
|
code: import { List } from '@sanity/ui'
|
|
130
127
|
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
128
|
|
|
144
129
|
$extensions:
|
|
145
130
|
com.sanity.ui:
|