@utilitywarehouse/hearth-react 0.28.7 → 0.29.0
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 +34 -20
- package/SKILL.md +355 -0
- package/dist/{chunk-TLCA3FQZ.js → chunk-ABES5BZY.js} +2 -2
- package/dist/{chunk-OHPQ5IRM.cjs → chunk-Y2CHQFKQ.cjs} +2 -2
- package/dist/{chunk-OHPQ5IRM.cjs.map → chunk-Y2CHQFKQ.cjs.map} +1 -1
- package/dist/components/CardAccordion/CardAccordion.context.d.ts.map +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.cjs +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.js +1 -1
- package/dist/components/ProgressBar/ProgressBar.cjs +1 -1
- package/dist/components/ProgressBar/ProgressBar.js +1 -1
- package/dist/helpers/get-classname-styles.d.ts.map +1 -1
- package/dist/helpers/logger.d.ts.map +1 -1
- package/dist/helpers/merge-ids.d.ts.map +1 -1
- package/dist/hooks/use-ids.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -10
- package/public/llms/components/accordion.md +321 -0
- package/public/llms/components/alert.md +217 -0
- package/public/llms/components/avatar.md +112 -0
- package/public/llms/components/badge.md +158 -0
- package/public/llms/components/body-text.md +200 -0
- package/public/llms/components/box.md +148 -0
- package/public/llms/components/breadcrumbs.md +97 -0
- package/public/llms/components/button.md +595 -0
- package/public/llms/components/card-accordion.md +277 -0
- package/public/llms/components/card.md +985 -0
- package/public/llms/components/checkbox-group.md +193 -0
- package/public/llms/components/checkbox-tile.md +116 -0
- package/public/llms/components/checkbox.md +108 -0
- package/public/llms/components/combobox.md +360 -0
- package/public/llms/components/container.md +162 -0
- package/public/llms/components/currency-input.md +85 -0
- package/public/llms/components/date-input.md +90 -0
- package/public/llms/components/date-picker.md +159 -0
- package/public/llms/components/description-list.md +149 -0
- package/public/llms/components/detail-text.md +89 -0
- package/public/llms/components/divider.md +88 -0
- package/public/llms/components/em.md +43 -0
- package/public/llms/components/expandable-card.md +231 -0
- package/public/llms/components/flex.md +197 -0
- package/public/llms/components/grid.md +244 -0
- package/public/llms/components/heading.md +65 -0
- package/public/llms/components/helper-text.md +27 -0
- package/public/llms/components/highlight-banner.md +94 -0
- package/public/llms/components/icon-button.md +516 -0
- package/public/llms/components/icon-container.md +247 -0
- package/public/llms/components/inline-link.md +190 -0
- package/public/llms/components/label.md +28 -0
- package/public/llms/components/link.md +236 -0
- package/public/llms/components/list.md +715 -0
- package/public/llms/components/menu.md +270 -0
- package/public/llms/components/modal.md +328 -0
- package/public/llms/components/pagination.md +138 -0
- package/public/llms/components/password-input.md +93 -0
- package/public/llms/components/progress-bar.md +139 -0
- package/public/llms/components/progress-stepper.md +147 -0
- package/public/llms/components/radio-group.md +487 -0
- package/public/llms/components/search-input.md +132 -0
- package/public/llms/components/section-header.md +82 -0
- package/public/llms/components/select.md +148 -0
- package/public/llms/components/skeleton.md +282 -0
- package/public/llms/components/spinner.md +59 -0
- package/public/llms/components/strong.md +49 -0
- package/public/llms/components/switch.md +106 -0
- package/public/llms/components/table.md +230 -0
- package/public/llms/components/tabs.md +320 -0
- package/public/llms/components/text-area.md +141 -0
- package/public/llms/components/text-input.md +228 -0
- package/public/llms/components/toast.md +323 -0
- package/public/llms/components/toggle-button-card.md +513 -0
- package/public/llms/components/tooltip.md +188 -0
- package/public/llms/components/unstyled-icon-button.md +175 -0
- package/public/llms/components/validation-text.md +29 -0
- package/public/llms/components/verification-input.md +96 -0
- package/public/llms/docs/changelog.md +1430 -0
- package/public/llms/docs/common-props/align-self.md +90 -0
- package/public/llms/docs/common-props/border.md +308 -0
- package/public/llms/docs/common-props/colour.md +221 -0
- package/public/llms/docs/common-props/flex-items.md +91 -0
- package/public/llms/docs/common-props/gap.md +111 -0
- package/public/llms/docs/common-props/grid-items.md +96 -0
- package/public/llms/docs/common-props/margin.md +105 -0
- package/public/llms/docs/common-props/opacity.md +100 -0
- package/public/llms/docs/common-props/order.md +90 -0
- package/public/llms/docs/common-props/overflow.md +89 -0
- package/public/llms/docs/common-props/padding.md +102 -0
- package/public/llms/docs/common-props/position.md +92 -0
- package/public/llms/docs/common-props/size.md +93 -0
- package/public/llms/docs/common-props/spacing.md +97 -0
- package/public/llms/docs/common-props/text.md +35 -0
- package/public/llms/docs/common-props/z-index.md +88 -0
- package/public/llms/docs/design-tokens.md +72 -0
- package/public/llms/docs/getting-started.md +117 -0
- package/public/llms/docs/layout.md +135 -0
- package/public/llms/docs/migrating.md +302 -0
- package/public/llms/docs/responsive-design/breakpoints.md +119 -0
- package/public/llms/docs/responsive-design/media-queries.md +89 -0
- package/public/llms/docs/responsive-design/responsive-props.md +37 -0
- package/public/llms.txt +97 -0
- package/scripts/init-ai.js +142 -0
- package/styles.css +1 -1
- /package/dist/{chunk-TLCA3FQZ.js.map → chunk-ABES5BZY.js.map} +0 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
# List
|
|
2
|
+
|
|
3
|
+
The `List` component is a flexible and customizable component for displaying a
|
|
4
|
+
list of items. It supports various visual variants, color schemes, and
|
|
5
|
+
additional features like helper text and links.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
<Box width="400px">
|
|
9
|
+
<List
|
|
10
|
+
{...args}
|
|
11
|
+
trailingContent={
|
|
12
|
+
<Link href="#">
|
|
13
|
+
Link
|
|
14
|
+
<ChevronRightSmallIcon />
|
|
15
|
+
</Link>
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
<ListItem>List item</ListItem>
|
|
19
|
+
<ListItem>
|
|
20
|
+
<ListItemContent heading="List item" helperText="Helper text" />
|
|
21
|
+
</ListItem>
|
|
22
|
+
<ListItem>
|
|
23
|
+
<ListItemButton
|
|
24
|
+
heading="List item button"
|
|
25
|
+
helperText="Helper text"
|
|
26
|
+
onClick={() => console.log('clickety click')}
|
|
27
|
+
/>
|
|
28
|
+
</ListItem>
|
|
29
|
+
<ListItem>
|
|
30
|
+
<ListItemButton
|
|
31
|
+
heading="List item button"
|
|
32
|
+
helperText="Helper text"
|
|
33
|
+
leadingContent={<SettingsMediumIcon />}
|
|
34
|
+
onClick={() => console.log('clickety click')}
|
|
35
|
+
/>
|
|
36
|
+
</ListItem>
|
|
37
|
+
<ListItem>
|
|
38
|
+
<ListItemButton
|
|
39
|
+
disabled
|
|
40
|
+
heading="List item disabled button"
|
|
41
|
+
helperText="Helper text"
|
|
42
|
+
leadingContent={<SettingsMediumIcon />}
|
|
43
|
+
onClick={() => console.log('clickety click')}
|
|
44
|
+
/>
|
|
45
|
+
</ListItem>
|
|
46
|
+
<ListItem>
|
|
47
|
+
<ListItemLink heading="List item as link" href="#" />
|
|
48
|
+
</ListItem>
|
|
49
|
+
<ListItem>
|
|
50
|
+
<ListItemLink
|
|
51
|
+
heading="List item link"
|
|
52
|
+
helperText="Helper text"
|
|
53
|
+
leadingContent={<SettingsMediumIcon />}
|
|
54
|
+
href="#"
|
|
55
|
+
/>
|
|
56
|
+
</ListItem>
|
|
57
|
+
<ListItem>
|
|
58
|
+
<ListActionButton>List action</ListActionButton>
|
|
59
|
+
</ListItem>
|
|
60
|
+
<ListItem>
|
|
61
|
+
<ListActionButton disabled>Disabled list action</ListActionButton>
|
|
62
|
+
</ListItem>
|
|
63
|
+
</List>
|
|
64
|
+
</Box>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- [Usage](#usage)
|
|
68
|
+
- [Appearance](#appearance)
|
|
69
|
+
- [Variant](#variant)
|
|
70
|
+
- [ColorScheme](#colorscheme)
|
|
71
|
+
- [Padding None](#padding-none)
|
|
72
|
+
- [Heading](#heading)
|
|
73
|
+
- [Leading content](#leading-content)
|
|
74
|
+
- [Trailing content](#trailing-content)
|
|
75
|
+
- [Advanced Content](#advanced-content)
|
|
76
|
+
- [List actions](#list-actions)
|
|
77
|
+
- [API](#api)
|
|
78
|
+
|
|
79
|
+
## Usage
|
|
80
|
+
|
|
81
|
+
- The `List` component can be customized with different variants and color schemes.
|
|
82
|
+
- Use `ListItem` by itself for simple text content, or as a container for more complex, or interactive, content.
|
|
83
|
+
- Use `ListItemContent` as a child of `ListItem` to include `helperText` or a `leadingIcon`.
|
|
84
|
+
- Use `ListItemButton` as a child of `ListItem` when you need the list item to perform an action.
|
|
85
|
+
- Use `ListItemLink` as a child of `ListItem` when you need the list item to navigate somewhere.
|
|
86
|
+
- Use `ListActionLink` as a child of `ListItem` when you need an action for the list to navigate somewhere.
|
|
87
|
+
- Use `ListActionButton` as a child of `ListItem` when you need an action for the list to do something.
|
|
88
|
+
|
|
89
|
+
### With Next.js
|
|
90
|
+
|
|
91
|
+
You can use the `ListItemLink` component with Next.js's `Link` component by using the
|
|
92
|
+
`asChild` prop. This allows you to wrap the `ListItemLink` around Next.js's `Link`
|
|
93
|
+
component, enabling client-side navigation while maintaining the styling and
|
|
94
|
+
functionality of the `ListItemLink`.
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import NextLink from 'next/link';
|
|
98
|
+
import { List, ListItem, ListItemLink } from '@utilitywarehouse/hearth-react';
|
|
99
|
+
|
|
100
|
+
[...]
|
|
101
|
+
|
|
102
|
+
<List>
|
|
103
|
+
<ListItem>
|
|
104
|
+
<ListItemLink heading="Page One" asChild>
|
|
105
|
+
<NextLink href="/one" />
|
|
106
|
+
</ListItemLink>
|
|
107
|
+
</ListItem>
|
|
108
|
+
<ListItem>
|
|
109
|
+
<ListItemLink heading="Page Two" asChild>
|
|
110
|
+
<NextLink href="/two" />
|
|
111
|
+
</ListItemLink>
|
|
112
|
+
</ListItem>
|
|
113
|
+
</List>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Appearance
|
|
117
|
+
|
|
118
|
+
**Important:** The `variant` prop must be used together with the `colorScheme`
|
|
119
|
+
prop. If either `variant` or `colorScheme` is `undefined`, the list will fall
|
|
120
|
+
back to its default appearance.
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<Flex direction="column" gap="600">
|
|
124
|
+
<Box width="300px">
|
|
125
|
+
<List {...args}>
|
|
126
|
+
<ListItem>List item</ListItem>
|
|
127
|
+
<ListItem>List item</ListItem>
|
|
128
|
+
<ListItem>List item</ListItem>
|
|
129
|
+
<ListItem>List item</ListItem>
|
|
130
|
+
<ListItem>List item</ListItem>
|
|
131
|
+
</List>
|
|
132
|
+
</Box>
|
|
133
|
+
{(['subtle', 'emphasis'] as const).map(variant => (
|
|
134
|
+
<Flex key={variant} gap="400">
|
|
135
|
+
{(['neutralStrong', 'neutralSubtle'] as const).map(colorScheme => (
|
|
136
|
+
<Box key={colorScheme} width="300px">
|
|
137
|
+
<List
|
|
138
|
+
{...args}
|
|
139
|
+
key={`${variant}${colorScheme}`}
|
|
140
|
+
variant={variant}
|
|
141
|
+
colorScheme={colorScheme}
|
|
142
|
+
>
|
|
143
|
+
<ListItem>List item</ListItem>
|
|
144
|
+
<ListItem>List item</ListItem>
|
|
145
|
+
<ListItem>List item</ListItem>
|
|
146
|
+
<ListItem>List item</ListItem>
|
|
147
|
+
<ListItem>List item</ListItem>
|
|
148
|
+
</List>
|
|
149
|
+
</Box>
|
|
150
|
+
))}
|
|
151
|
+
</Flex>
|
|
152
|
+
))}
|
|
153
|
+
</Flex>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Variant
|
|
157
|
+
|
|
158
|
+
The `variant` prop controls the overall style of the list. It can be used to
|
|
159
|
+
adjust the visual prominence of the list.
|
|
160
|
+
|
|
161
|
+
- **`undefined`**: Default appearance with no special styling.
|
|
162
|
+
- **`'subtle'`**: A minimal style with subtle borders and background.
|
|
163
|
+
- **`'emphasis'`**: A more pronounced style with stronger borders and background.
|
|
164
|
+
|
|
165
|
+
### ColorScheme
|
|
166
|
+
|
|
167
|
+
The `colorScheme` prop adjusts the background color of the list. It works in
|
|
168
|
+
conjunction with the `variant` prop.
|
|
169
|
+
|
|
170
|
+
- **`undefined`**: Default color scheme.
|
|
171
|
+
- **`'neutralStrong'`**: A clean, neutral white background.
|
|
172
|
+
- **`'neutralSubtle'`**: A softer, warmer white background.
|
|
173
|
+
|
|
174
|
+
### Padding None
|
|
175
|
+
|
|
176
|
+
You can remove the inline padding from all list items with the `paddingNone`
|
|
177
|
+
prop. This only has an effect when the variant or colorScheme are not set.
|
|
178
|
+
|
|
179
|
+
## Heading
|
|
180
|
+
|
|
181
|
+
The `heading` prop specifies the title of the list. This is useful for
|
|
182
|
+
providing context or describing the purpose of the list.
|
|
183
|
+
|
|
184
|
+
The `headingElement` prop allows you to specify the HTML element used for the
|
|
185
|
+
heading. This is important for maintaining semantic structure in your document.
|
|
186
|
+
|
|
187
|
+
- Use `'h1'`, `'h2'`, etc., for headings that are part of your page's hierarchy.
|
|
188
|
+
- Use `'div'` if the heading is purely decorative or doesn't fit into the semantic structure.
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
<List heading="My List" headingElement="h2">
|
|
192
|
+
<ListItem>Item 1</ListItem>
|
|
193
|
+
<ListItem>Item 2</ListItem>
|
|
194
|
+
</List>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Link
|
|
198
|
+
|
|
199
|
+
Use the `link` prop to provide a call-to-action or navigation link.
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<List
|
|
203
|
+
heading="My Bills"
|
|
204
|
+
link={
|
|
205
|
+
<Link href="https://uw.co.uk/bills">
|
|
206
|
+
View all
|
|
207
|
+
<ChevronRightSmallIcon />
|
|
208
|
+
</Link>
|
|
209
|
+
}
|
|
210
|
+
>
|
|
211
|
+
<ListItem>January 2025</ListItem>
|
|
212
|
+
<ListItem>February 2025</ListItem>
|
|
213
|
+
</List>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Helper text
|
|
217
|
+
|
|
218
|
+
The `helperText` prop provides additional context or instructions for the list.
|
|
219
|
+
It is displayed below the heading.
|
|
220
|
+
|
|
221
|
+
### Badge
|
|
222
|
+
|
|
223
|
+
You can include a `Badge` component, using the `badge` prop, with the
|
|
224
|
+
`badgePlacement` prop enabling you to change the position between `top` &
|
|
225
|
+
`bottom`.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
<Box width="300px">
|
|
229
|
+
<List {...args}>
|
|
230
|
+
<ListItem>
|
|
231
|
+
<ListItemContent
|
|
232
|
+
heading="List item content"
|
|
233
|
+
helperText="Helper text"
|
|
234
|
+
badge={<Badge size="sm">Badge</Badge>}
|
|
235
|
+
/>
|
|
236
|
+
</ListItem>
|
|
237
|
+
<ListItem>
|
|
238
|
+
<ListItemContent
|
|
239
|
+
heading="List item content"
|
|
240
|
+
helperText="Helper text"
|
|
241
|
+
badgePlacement="top"
|
|
242
|
+
badge={
|
|
243
|
+
<Badge size="sm" marginBottom="100">
|
|
244
|
+
Badge
|
|
245
|
+
</Badge>
|
|
246
|
+
}
|
|
247
|
+
/>
|
|
248
|
+
</ListItem>
|
|
249
|
+
</List>
|
|
250
|
+
</Box>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Leading content
|
|
254
|
+
|
|
255
|
+
Use the `leadingContent` prop on the `ListItemContent`, `ListItemButton` &
|
|
256
|
+
`ListItemLink` components to include a visual element at the start of a list
|
|
257
|
+
item. Typically, this would be an icon, `IconContainer`, or `Avatar`.
|
|
258
|
+
|
|
259
|
+
```tsx
|
|
260
|
+
<Box width="400px">
|
|
261
|
+
<List {...args}>
|
|
262
|
+
<ListItem>
|
|
263
|
+
<ListItemContent heading="Icon leading content" leadingContent={<InfoMediumIcon />} />
|
|
264
|
+
</ListItem>
|
|
265
|
+
<ListItem>
|
|
266
|
+
<ListItemContent
|
|
267
|
+
heading="Icon leading content"
|
|
268
|
+
helperText="Helper text"
|
|
269
|
+
leadingContent={<InfoMediumIcon />}
|
|
270
|
+
/>
|
|
271
|
+
</ListItem>
|
|
272
|
+
<ListItem>
|
|
273
|
+
<ListItemContent
|
|
274
|
+
heading="Icon container leading content"
|
|
275
|
+
leadingContent={
|
|
276
|
+
<IconContainer variant="subtle" colorScheme="cashback" size="sm">
|
|
277
|
+
<CashbackCardSmallIcon />
|
|
278
|
+
</IconContainer>
|
|
279
|
+
}
|
|
280
|
+
/>
|
|
281
|
+
</ListItem>
|
|
282
|
+
<ListItem>
|
|
283
|
+
<ListItemContent
|
|
284
|
+
heading="Icon container leading content"
|
|
285
|
+
helperText="Helper text"
|
|
286
|
+
leadingContent={
|
|
287
|
+
<IconContainer variant="subtle" colorScheme="cashback" size="sm">
|
|
288
|
+
<CashbackCardSmallIcon />
|
|
289
|
+
</IconContainer>
|
|
290
|
+
}
|
|
291
|
+
/>
|
|
292
|
+
</ListItem>
|
|
293
|
+
<ListItem>
|
|
294
|
+
<ListItemContent heading="Avatar leading content" leadingContent={<Avatar size="sm" />} />
|
|
295
|
+
</ListItem>
|
|
296
|
+
<ListItem>
|
|
297
|
+
<ListItemContent
|
|
298
|
+
heading="Avatar leading content"
|
|
299
|
+
helperText="Helper text"
|
|
300
|
+
leadingContent={<Avatar size="sm" />}
|
|
301
|
+
/>
|
|
302
|
+
</ListItem>
|
|
303
|
+
</List>
|
|
304
|
+
</Box>
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
## Trailing content
|
|
308
|
+
|
|
309
|
+
Use the `trailingContent` prop on the `ListItemContent`, `ListItemButton` &
|
|
310
|
+
`ListItemLink` components to include a visual element at the end of a list
|
|
311
|
+
item. Typically, this would be an icon, `Switch`, `Link` or transaction, though
|
|
312
|
+
interactive elements such as `Switch` & `Link` should **NOT** be used as
|
|
313
|
+
trailing content with the `ListItemButton` & `ListItemLink` components.
|
|
314
|
+
|
|
315
|
+
```tsx
|
|
316
|
+
<Box width="400px">
|
|
317
|
+
<List {...args}>
|
|
318
|
+
<ListItem>
|
|
319
|
+
<ListItemContent
|
|
320
|
+
heading="Trailing content"
|
|
321
|
+
helperText="With custom icon"
|
|
322
|
+
trailingContent={<InfoMediumIcon />}
|
|
323
|
+
/>
|
|
324
|
+
</ListItem>
|
|
325
|
+
<ListItem>
|
|
326
|
+
<ListItemContent
|
|
327
|
+
heading="Trailing content"
|
|
328
|
+
helperText="With Switch"
|
|
329
|
+
trailingContent={<Switch aria-label="list item switch" size="sm" />}
|
|
330
|
+
/>
|
|
331
|
+
</ListItem>
|
|
332
|
+
<ListItem>
|
|
333
|
+
<ListItemContent
|
|
334
|
+
heading="Trailing content"
|
|
335
|
+
helperText="With Link"
|
|
336
|
+
trailingContent={<Link href="#">Link</Link>}
|
|
337
|
+
/>
|
|
338
|
+
</ListItem>
|
|
339
|
+
<ListItem>
|
|
340
|
+
<ListItemContent
|
|
341
|
+
heading="Transaction trailing content"
|
|
342
|
+
helperText="With multiple transactions"
|
|
343
|
+
trailingContent={
|
|
344
|
+
<Flex direction="column">
|
|
345
|
+
<BodyText size="md" as="span">
|
|
346
|
+
-£100.00
|
|
347
|
+
</BodyText>
|
|
348
|
+
<BodyText size="md" as="span" style={{ color: 'var(--h-text-brand)' }}>
|
|
349
|
+
+£1.00 CB
|
|
350
|
+
</BodyText>
|
|
351
|
+
</Flex>
|
|
352
|
+
}
|
|
353
|
+
/>
|
|
354
|
+
</ListItem>
|
|
355
|
+
<ListItem>
|
|
356
|
+
<ListItemContent
|
|
357
|
+
heading="Transaction trailing content"
|
|
358
|
+
helperText="With a single transaction"
|
|
359
|
+
trailingContent={
|
|
360
|
+
<Flex>
|
|
361
|
+
<BodyText size="md" as="span" style={{ color: 'var(--h-text-affirmative)' }}>
|
|
362
|
+
+£10.00
|
|
363
|
+
</BodyText>
|
|
364
|
+
</Flex>
|
|
365
|
+
}
|
|
366
|
+
/>
|
|
367
|
+
</ListItem>
|
|
368
|
+
</List>
|
|
369
|
+
</Box>
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Custom trailing content
|
|
373
|
+
|
|
374
|
+
You can also include custom content, such as a transaction. The layout should
|
|
375
|
+
be handled for you, however if necessary you can always wrap your custom
|
|
376
|
+
content in a `Flex` component.
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
<ListItem>
|
|
380
|
+
<ListItemContent
|
|
381
|
+
heading="Transaction"
|
|
382
|
+
trailingContent={
|
|
383
|
+
<>
|
|
384
|
+
<BodyText size="md" as="span">
|
|
385
|
+
-£100.00
|
|
386
|
+
</BodyText>
|
|
387
|
+
<BodyText size="md" as="span" style={{ color: 'var(--h-text-brand)' }}>
|
|
388
|
+
+£1.00 CB
|
|
389
|
+
</BodyText>
|
|
390
|
+
</>
|
|
391
|
+
}
|
|
392
|
+
/>
|
|
393
|
+
</ListItem>
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
<Box width="300px">
|
|
398
|
+
<List {...args}>
|
|
399
|
+
<ListItem>
|
|
400
|
+
<ListItemContent
|
|
401
|
+
heading="Boots"
|
|
402
|
+
helperText="5:30pm"
|
|
403
|
+
trailingContent={
|
|
404
|
+
<Flex direction="column" alignItems="end">
|
|
405
|
+
<BodyText size="md" as="span">
|
|
406
|
+
-£100.00
|
|
407
|
+
</BodyText>
|
|
408
|
+
<BodyText size="md" as="span" color="brand">
|
|
409
|
+
+£1.00 CB
|
|
410
|
+
</BodyText>
|
|
411
|
+
</Flex>
|
|
412
|
+
}
|
|
413
|
+
/>
|
|
414
|
+
</ListItem>
|
|
415
|
+
<ListItem>
|
|
416
|
+
<ListItemContent
|
|
417
|
+
heading="Top-up"
|
|
418
|
+
helperText="4:00pm"
|
|
419
|
+
trailingContent={
|
|
420
|
+
<Flex alignSelf="start">
|
|
421
|
+
<BodyText size="md" as="span" color="affirmative">
|
|
422
|
+
+£10.00
|
|
423
|
+
</BodyText>
|
|
424
|
+
</Flex>
|
|
425
|
+
}
|
|
426
|
+
/>
|
|
427
|
+
</ListItem>
|
|
428
|
+
</List>
|
|
429
|
+
</Box>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Advanced Content
|
|
433
|
+
|
|
434
|
+
You can compose more complex content within the `ListItem` component. The
|
|
435
|
+
`ListItemButton` and `ListItemLink` components will continue to make the entire
|
|
436
|
+
list item interactive.
|
|
437
|
+
|
|
438
|
+
```tsx
|
|
439
|
+
<List {...args} aria-label="Partner events">
|
|
440
|
+
{events.map(event => (
|
|
441
|
+
<ListItem key={event.title}>
|
|
442
|
+
<Flex direction="column" width="44px" textAlign="center">
|
|
443
|
+
<BodyText size="md">{event.date.month}</BodyText>
|
|
444
|
+
<DetailText size="2xl">{event.date.day}</DetailText>
|
|
445
|
+
</Flex>
|
|
446
|
+
|
|
447
|
+
<ListItemButton
|
|
448
|
+
heading={event.title}
|
|
449
|
+
helperText={event.location}
|
|
450
|
+
badgePlacement="top"
|
|
451
|
+
badge={
|
|
452
|
+
<Badge
|
|
453
|
+
colorScheme={event.type.includes('Buzz') ? 'positive' : 'info'}
|
|
454
|
+
size="sm"
|
|
455
|
+
marginBottom="100"
|
|
456
|
+
>
|
|
457
|
+
{event.type}
|
|
458
|
+
</Badge>
|
|
459
|
+
}
|
|
460
|
+
/>
|
|
461
|
+
</ListItem>
|
|
462
|
+
))}
|
|
463
|
+
</List>
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
## List actions
|
|
467
|
+
|
|
468
|
+
A single List Action can be applied to any List that sits within a container.
|
|
469
|
+
Use List Action to apply to actions that apply to the content of the list. For
|
|
470
|
+
example, "View older bills"
|
|
471
|
+
|
|
472
|
+
```tsx
|
|
473
|
+
<Flex gap="400" width="700px">
|
|
474
|
+
<List {...args}>
|
|
475
|
+
<ListItem>
|
|
476
|
+
<ListItemButton
|
|
477
|
+
heading="List item"
|
|
478
|
+
helperText="Helper text"
|
|
479
|
+
leadingContent={<SettingsMediumIcon />}
|
|
480
|
+
onClick={() => console.log('clickety click')}
|
|
481
|
+
/>
|
|
482
|
+
</ListItem>
|
|
483
|
+
<ListItem>
|
|
484
|
+
<ListItemButton
|
|
485
|
+
heading="List item"
|
|
486
|
+
helperText="Helper text"
|
|
487
|
+
leadingContent={<SettingsMediumIcon />}
|
|
488
|
+
onClick={() => console.log('clickety click')}
|
|
489
|
+
/>
|
|
490
|
+
</ListItem>
|
|
491
|
+
<ListItem>
|
|
492
|
+
<ListItemButton
|
|
493
|
+
heading="List item"
|
|
494
|
+
helperText="Helper text"
|
|
495
|
+
leadingContent={<SettingsMediumIcon />}
|
|
496
|
+
onClick={() => console.log('clickety click')}
|
|
497
|
+
/>
|
|
498
|
+
</ListItem>
|
|
499
|
+
<ListItem>
|
|
500
|
+
<ListActionLink href="#">List action link</ListActionLink>
|
|
501
|
+
</ListItem>
|
|
502
|
+
</List>
|
|
503
|
+
|
|
504
|
+
<List {...args}>
|
|
505
|
+
<ListItem>
|
|
506
|
+
<ListItemButton
|
|
507
|
+
heading="List item"
|
|
508
|
+
helperText="Helper text"
|
|
509
|
+
leadingContent={<SettingsMediumIcon />}
|
|
510
|
+
onClick={() => console.log('clickety click')}
|
|
511
|
+
/>
|
|
512
|
+
</ListItem>
|
|
513
|
+
<ListItem>
|
|
514
|
+
<ListItemButton
|
|
515
|
+
heading="List item"
|
|
516
|
+
helperText="Helper text"
|
|
517
|
+
leadingContent={<SettingsMediumIcon />}
|
|
518
|
+
onClick={() => console.log('clickety click')}
|
|
519
|
+
/>
|
|
520
|
+
</ListItem>
|
|
521
|
+
<ListItem>
|
|
522
|
+
<ListItemButton
|
|
523
|
+
heading="List item"
|
|
524
|
+
helperText="Helper text"
|
|
525
|
+
leadingContent={<SettingsMediumIcon />}
|
|
526
|
+
onClick={() => console.log('clickety click')}
|
|
527
|
+
/>
|
|
528
|
+
</ListItem>
|
|
529
|
+
<ListItem>
|
|
530
|
+
<ListActionButton>List action button</ListActionButton>
|
|
531
|
+
</ListItem>
|
|
532
|
+
</List>
|
|
533
|
+
</Flex>
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## API
|
|
537
|
+
|
|
538
|
+
This component is based on the `ul` element and supports the following common props:
|
|
539
|
+
|
|
540
|
+
- Margin
|
|
541
|
+
|
|
542
|
+
| Prop | Type | Default | Description |
|
|
543
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------- |
|
|
544
|
+
| `heading` | `string` | — | Actual string to display as section header |
|
|
545
|
+
| `headingElement` | `"div" \| "h1" \| "h2" \| "h3" \| "h4"` | `h2` | |
|
|
546
|
+
| `helperText` | `string` | — | Optional helper text to provide additional context or instructions. |
|
|
547
|
+
| `trailingContent` | `ReactNode` | — | Optional trailing content element |
|
|
548
|
+
| `validationStatus` | `"invalid"` | — | Indicates the validation state |
|
|
549
|
+
| `validationText` | `string` | — | Text to display when the `validationStatus` is set. |
|
|
550
|
+
| `direction` | `Responsive<"row" \| "column">` | — | Responsive direction of the section header content. By default, the content is laid out in a row. |
|
|
551
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
552
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
553
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
554
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
555
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
556
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
557
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
558
|
+
| `variant` | `"emphasis" \| "subtle"` | `undefined` | Sets the visual variant of the list. |
|
|
559
|
+
| `colorScheme` | `"neutralStrong" \| "neutralSubtle"` | — | Sets the color scheme of the list. |
|
|
560
|
+
| `as` | `"ol" \| "ul"` | `ul` | Shorthand for changing the default rendered element into a semantically appropriate alternative. |
|
|
561
|
+
| `paddingNone` | `boolean` | — | Remove the inline padding for better alignment with other elements. |
|
|
562
|
+
|
|
563
|
+
## ListItem
|
|
564
|
+
|
|
565
|
+
The `ListItem` component represents an individual item in the `List`. It can be
|
|
566
|
+
used by itself to present simple text content. It also works as a wrapper when
|
|
567
|
+
you need to present advanced content or interactive list items.
|
|
568
|
+
|
|
569
|
+
```tsx
|
|
570
|
+
<List heading="Example List">
|
|
571
|
+
<ListItem>Item 1</ListItem>
|
|
572
|
+
<ListItem>Item 2</ListItem>
|
|
573
|
+
</List>
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
This component is base on the `li` element and supports the following common props:
|
|
577
|
+
|
|
578
|
+
- Size
|
|
579
|
+
- Gap
|
|
580
|
+
|
|
581
|
+
As well as the following Flex component props:
|
|
582
|
+
|
|
583
|
+
- direction
|
|
584
|
+
- alignItems
|
|
585
|
+
- alignContent
|
|
586
|
+
- justifyContent
|
|
587
|
+
- wrap
|
|
588
|
+
|
|
589
|
+
## ListItemContent
|
|
590
|
+
|
|
591
|
+
The `ListItemContent` component is used to render more advanced text content.
|
|
592
|
+
|
|
593
|
+
```tsx
|
|
594
|
+
<Box width="300px">
|
|
595
|
+
<List {...args}>
|
|
596
|
+
<ListItem>
|
|
597
|
+
<ListItemContent
|
|
598
|
+
heading="List item content"
|
|
599
|
+
leadingContent={<SettingsMediumIcon />}
|
|
600
|
+
helperText="Helper text"
|
|
601
|
+
/>
|
|
602
|
+
</ListItem>
|
|
603
|
+
<ListItem>
|
|
604
|
+
<ListItemContent
|
|
605
|
+
heading="List item content"
|
|
606
|
+
leadingContent={<SettingsMediumIcon />}
|
|
607
|
+
helperText="Helper text"
|
|
608
|
+
/>
|
|
609
|
+
</ListItem>
|
|
610
|
+
<ListItem>
|
|
611
|
+
<ListItemContent
|
|
612
|
+
heading="List item content"
|
|
613
|
+
leadingContent={<SettingsMediumIcon />}
|
|
614
|
+
helperText="Helper text"
|
|
615
|
+
/>
|
|
616
|
+
</ListItem>
|
|
617
|
+
</List>
|
|
618
|
+
</Box>
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
This component is base on the `div` element.
|
|
622
|
+
|
|
623
|
+
| Prop | Type | Default | Description |
|
|
624
|
+
| ----------------- | ------------------- | -------- | ------------------------------------------------------------------- |
|
|
625
|
+
| `heading` | `string` | — | |
|
|
626
|
+
| `helperText` | `ReactNode` | — | Optional helper text to provide additional context or instructions. |
|
|
627
|
+
| `leadingContent` | `ReactNode` | — | |
|
|
628
|
+
| `trailingContent` | `ReactNode` | — | |
|
|
629
|
+
| `badge` | `ReactNode` | — | |
|
|
630
|
+
| `badgePlacement` | `"top" \| "bottom"` | `bottom` | Placement of the badge element |
|
|
631
|
+
|
|
632
|
+
## ListItemButton
|
|
633
|
+
|
|
634
|
+
The `ListItemButton` component is used to render a list item as a button, and
|
|
635
|
+
should be wrapped in a `ListItem` component.
|
|
636
|
+
|
|
637
|
+
This component is base on the `button` element and extends the
|
|
638
|
+
`ListItemContent` component, so it supports all the same props.
|
|
639
|
+
|
|
640
|
+
```tsx
|
|
641
|
+
<Box width="300px">
|
|
642
|
+
<List {...args}>
|
|
643
|
+
<ListItem>
|
|
644
|
+
<ListItemButton heading="List item button" />
|
|
645
|
+
</ListItem>
|
|
646
|
+
<ListItem>
|
|
647
|
+
<ListItemButton heading="List item button" />
|
|
648
|
+
</ListItem>
|
|
649
|
+
<ListItem>
|
|
650
|
+
<ListItemButton heading="List item button" />
|
|
651
|
+
</ListItem>
|
|
652
|
+
<ListItem>
|
|
653
|
+
<ListItemButton heading="List item button" />
|
|
654
|
+
</ListItem>
|
|
655
|
+
<ListItem>
|
|
656
|
+
<ListItemButton heading="List item button" />
|
|
657
|
+
</ListItem>
|
|
658
|
+
</List>
|
|
659
|
+
</Box>
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
## ListItemLink
|
|
663
|
+
|
|
664
|
+
The `ListItemLink` component is used to render a list item as a link, and
|
|
665
|
+
should be wrapped in a `ListItem` component.
|
|
666
|
+
|
|
667
|
+
```tsx
|
|
668
|
+
<Box width="300px">
|
|
669
|
+
<List {...args}>
|
|
670
|
+
<ListItem>
|
|
671
|
+
<ListItemLink heading="List item link" />
|
|
672
|
+
</ListItem>
|
|
673
|
+
<ListItem>
|
|
674
|
+
<ListItemLink heading="List item link" />
|
|
675
|
+
</ListItem>
|
|
676
|
+
<ListItem>
|
|
677
|
+
<ListItemLink heading="List item link" />
|
|
678
|
+
</ListItem>
|
|
679
|
+
<ListItem>
|
|
680
|
+
<ListItemLink heading="List item link" />
|
|
681
|
+
</ListItem>
|
|
682
|
+
<ListItem>
|
|
683
|
+
<ListItemLink heading="List item link" />
|
|
684
|
+
</ListItem>
|
|
685
|
+
</List>
|
|
686
|
+
</Box>
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
This component is base on the `a` element and extends the `ListItemContent`
|
|
690
|
+
component, so it supports all the same props, as well as the following
|
|
691
|
+
additional props:
|
|
692
|
+
|
|
693
|
+
| Prop | Type | Default | Description |
|
|
694
|
+
| ----------------- | ------------------- | ---------- | ---------------------------------------------------------------------------------------------------- |
|
|
695
|
+
| `heading` | `string` | — | |
|
|
696
|
+
| `helperText` | `ReactNode` | — | Optional helper text to provide additional context or instructions. |
|
|
697
|
+
| `leadingContent` | `ReactNode` | — | |
|
|
698
|
+
| `trailingContent` | `ReactNode` | — | |
|
|
699
|
+
| `badge` | `ReactNode` | — | |
|
|
700
|
+
| `badgePlacement` | `"top" \| "bottom"` | `'bottom'` | Placement of the badge element |
|
|
701
|
+
| `asChild` | `boolean` | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
|
|
702
|
+
|
|
703
|
+
## ListActionLink
|
|
704
|
+
|
|
705
|
+
A single `ListActionLink` component can render a list action as a link, and
|
|
706
|
+
should be wrapped in a `ListItem` component.
|
|
707
|
+
|
|
708
|
+
This component is based on the `a` element.
|
|
709
|
+
|
|
710
|
+
## ListActionButton
|
|
711
|
+
|
|
712
|
+
A single `ListActionButton` component can render a list action as a button, and
|
|
713
|
+
should be wrapped in a `ListItem` component.
|
|
714
|
+
|
|
715
|
+
This component is based on the `button` element.
|