@utilitywarehouse/hearth-react 0.28.6 → 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-O7RBVBMN.cjs → chunk-LWHIBSW2.cjs} +2 -2
- package/dist/{chunk-O7RBVBMN.cjs.map → chunk-LWHIBSW2.cjs.map} +1 -1
- package/dist/{chunk-JRVYOIXR.js → chunk-MIVYZGEV.js} +2 -2
- package/dist/components/CardAccordion/CardAccordion.context.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.cjs +1 -1
- package/dist/components/Combobox/Combobox.js +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.cjs +1 -1
- package/dist/components/ExpandableCard/ExpandableCard.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 +18 -12
- 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 +2 -2
- /package/dist/{chunk-JRVYOIXR.js.map → chunk-MIVYZGEV.js.map} +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
|
|
3
|
+
Using a Spinner is a common method for indicating that an asynchronous process is ongoing.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<Flex gap="600">
|
|
7
|
+
{sizes.map(size => (
|
|
8
|
+
<Spinner key={size} size={size} />
|
|
9
|
+
))}
|
|
10
|
+
</Flex>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
<Spinner size="md" />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Size
|
|
18
|
+
|
|
19
|
+
The size prop is responsive, so you can render different sizes at different breakpoints.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<Spinner size={{ mobile: 'sm', tablet: 'md', desktop: 'lg' }} />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Color
|
|
26
|
+
|
|
27
|
+
The color prop allows you to set the strok width colour to any of the colour token values.
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<Spinner color="uwPurple" />
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
If you are using the `Spinner` as an element within a parent component, and
|
|
34
|
+
need it to inherit the parent's colour scheme, you can set the `currentColor`
|
|
35
|
+
prop.
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<Spinner currentColor />
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
This component is based on the `div` element and supports the following common props:
|
|
44
|
+
|
|
45
|
+
- Color
|
|
46
|
+
- Margin
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Default | Description |
|
|
49
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
+
| `size` | `Responsive<"xs" \| "sm" \| "md" \| "lg">` | `md` | Sets the button height. |
|
|
51
|
+
| `color` | `"primary" \| "secondary" \| "brand" \| "inverted"` | — | Sets the fill color. |
|
|
52
|
+
| `currentColor` | `boolean` | — | Sets the Spinner stroke colour to `currentColor`. For use when the Spinner needs to inherit a parent component's colour scheme. |
|
|
53
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
54
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
55
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
56
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
57
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
58
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
59
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Strong
|
|
2
|
+
|
|
3
|
+
The `Strong` component is based on the HTML `strong` element and is used to indicate text that is of
|
|
4
|
+
strong importance, seriousness, or urgency. `Strong` should be wrapped in a `BodyText` component,
|
|
5
|
+
and will inherit its styles from its parent. You can also use this component within the `Heading`
|
|
6
|
+
component, however as `Heading` has only one font-weight there will be no visual distinction, and
|
|
7
|
+
so this is discouraged.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
<Flex direction="column" gap="100">
|
|
11
|
+
{sizes.map(size => (
|
|
12
|
+
<BodyText key={size} size={size}>
|
|
13
|
+
The most important thing to remember is, <Strong>stay positive</Strong>.
|
|
14
|
+
</BodyText>
|
|
15
|
+
))}
|
|
16
|
+
</Flex>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Alternatives
|
|
20
|
+
|
|
21
|
+
- BodyText - For body text
|
|
22
|
+
- DetailText - For detail text
|
|
23
|
+
- Heading - For heading-level text
|
|
24
|
+
- Em - For emphasis
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
This component is based on the `strong` element and supports the following common props:
|
|
29
|
+
|
|
30
|
+
- Margin
|
|
31
|
+
- Text transform
|
|
32
|
+
- Text align
|
|
33
|
+
- Text wrap
|
|
34
|
+
|
|
35
|
+
| Prop | Type | Default | Description |
|
|
36
|
+
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
37
|
+
| `asChild` | `boolean` | — | Change the default rendered element for the one passed as a child, merging their props and behavior. |
|
|
38
|
+
| `truncate` | `boolean` | — | If true, the text will not wrap, but instead will truncate with a text overflow ellipsis. Note that text overflow can only happen with block or inline-block level elements (the element needs to have a width in order to overflow). |
|
|
39
|
+
| `textAlign` | `Responsive<"center" \| "left" \| "right">` | — | |
|
|
40
|
+
| `textTransform` | `"none" \| "uppercase" \| "lowercase" \| "capitalize"` | — | Set the text-transform on the component. |
|
|
41
|
+
| `wrap` | `Responsive<"wrap" \| "nowrap" \| "balance" \| "pretty">` | — | DEPRECATED: use `textWrap` instead of `wrap` @deprecated Use `textWrap` instead of `wrap` |
|
|
42
|
+
| `textWrap` | `Responsive<"wrap" \| "nowrap" \| "balance" \| "pretty">` | — | |
|
|
43
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
44
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
45
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
46
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
47
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
48
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
49
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Switch
|
|
2
|
+
|
|
3
|
+
`Switch` is used to indicate switching between two opposing options. Switches
|
|
4
|
+
allow users to turn an individual option on or off. They are usually used to
|
|
5
|
+
activate or deactivate a specific setting.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
<Switch size="sm" label="Switch label" />
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Sizes
|
|
12
|
+
|
|
13
|
+
The `Switch` component supports two sizes: `sm` (small) and `md` (medium). You
|
|
14
|
+
can control the size using the `size` prop.
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
<Switch size="sm" />
|
|
18
|
+
<Switch size="md" />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
<Flex direction="row" gap="200">
|
|
23
|
+
{sizes.map(size => (
|
|
24
|
+
<Switch key={size} {...args} size={size} />
|
|
25
|
+
))}
|
|
26
|
+
</Flex>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Disabled State
|
|
30
|
+
|
|
31
|
+
The `Switch` can be disabled using the `disabled` prop. When disabled, the
|
|
32
|
+
`Switch` is non-interactive and visually indicates its disabled state.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
<Switch disabled />
|
|
36
|
+
<Switch disabled checked />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
<Flex direction="row" gap="200">
|
|
41
|
+
<Switch {...args} />
|
|
42
|
+
<Switch {...args} checked />
|
|
43
|
+
</Flex>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The disabled `Switch` uses `aria-disabled`, rather than the `disabled`
|
|
47
|
+
attribute, so that they are still focusable when using the keyboard. This means
|
|
48
|
+
that screen readers are still able to find the button, with the insight that it
|
|
49
|
+
is disabled and that there is perhaps an action which needs to be taken, rather
|
|
50
|
+
than not knowing there is a button there at all. The `onClick` handler will be
|
|
51
|
+
disabled, however you will need to make sure you disable any other expected
|
|
52
|
+
actions.
|
|
53
|
+
|
|
54
|
+
## Responsive Sizes
|
|
55
|
+
|
|
56
|
+
The `Switch` component supports responsive sizes. You can specify different
|
|
57
|
+
sizes for different breakpoints using a responsive object.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<Switch size={{ mobile: 'sm', desktop: 'md' }} />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Keyboard Interactions
|
|
64
|
+
|
|
65
|
+
- **Space**: Toggles the state of the `Switch`.
|
|
66
|
+
- **Tab**: Moves focus to the `Switch`.
|
|
67
|
+
|
|
68
|
+
### Label
|
|
69
|
+
|
|
70
|
+
Do not use `Switch` without a label. If you do not use the `label` prop, then
|
|
71
|
+
please make sure you properly label the component for screen reader users.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<Flex direction="column" gap="600">
|
|
75
|
+
<Flex direction="row" gap="200" alignItems="center">
|
|
76
|
+
<BodyText as="label" htmlFor="airplane-mode">
|
|
77
|
+
Airplane mode
|
|
78
|
+
</BodyText>
|
|
79
|
+
<Switch id="airplane-mode" {...args} />
|
|
80
|
+
</Flex>
|
|
81
|
+
<Switch aria-label="airplane-mode" {...args} />
|
|
82
|
+
</Flex>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
This component is based on the `button` element, and supports the following common props:
|
|
88
|
+
|
|
89
|
+
- Margin
|
|
90
|
+
|
|
91
|
+
| Prop | Type | Default | Description |
|
|
92
|
+
| ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------------------------------------- |
|
|
93
|
+
| `label` | `string` | — | The label for the Switch, describing its purpose. |
|
|
94
|
+
| `defaultChecked` | `boolean` | — | |
|
|
95
|
+
| `asChild` | `boolean` | — | |
|
|
96
|
+
| `size` | `Responsive<"sm" \| "md">` | — | |
|
|
97
|
+
| `checked` | `boolean` | — | |
|
|
98
|
+
| `required` | `boolean` | — | |
|
|
99
|
+
| `onCheckedChange` | `((checked: boolean) => void)` | — | |
|
|
100
|
+
| `margin` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
101
|
+
| `marginTop` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
102
|
+
| `marginRight` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
103
|
+
| `marginBottom` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
104
|
+
| `marginLeft` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
105
|
+
| `marginX` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
106
|
+
| `marginY` | `Responsive<"0" \| "auto" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Table
|
|
2
|
+
|
|
3
|
+
Use a `Table` to arrange data in rows and columns. They are used to communicate relationships between content and to display references, comparisons, and choices.
|
|
4
|
+
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Variants](#variants)
|
|
7
|
+
- [Pagination](#pagination)
|
|
8
|
+
- [Header cells](#header-cells)
|
|
9
|
+
- [API](#api)
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<Table {...args}>
|
|
13
|
+
<TableHeader>
|
|
14
|
+
<TableHeaderCell>Name</TableHeaderCell>
|
|
15
|
+
<TableHeaderCell>Email</TableHeaderCell>
|
|
16
|
+
<TableHeaderCell>Phone</TableHeaderCell>
|
|
17
|
+
<TableHeaderCell>City</TableHeaderCell>
|
|
18
|
+
</TableHeader>
|
|
19
|
+
<TableBody>
|
|
20
|
+
{personalDetails.slice(0, 3).map(person => (
|
|
21
|
+
<TableRow key={person.id}>
|
|
22
|
+
<TableCell>{person.name}</TableCell>
|
|
23
|
+
<TableCell>{person.email}</TableCell>
|
|
24
|
+
<TableCell>{person.phone}</TableCell>
|
|
25
|
+
<TableCell>{person.city}</TableCell>
|
|
26
|
+
</TableRow>
|
|
27
|
+
))}
|
|
28
|
+
</TableBody>
|
|
29
|
+
</Table>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
- `Table` groups the `TableHeader` and `TableBody` components, and provides UI variants.
|
|
35
|
+
- `TableHeader` groups table column headers
|
|
36
|
+
- `TableBody` provides the body of the table, grouping table rows.
|
|
37
|
+
- `TableRow` wraps rows of data cells
|
|
38
|
+
- `TableHeaderCell` provides the header cell, which can be used within both `TableHeader` and `TableRow` components.
|
|
39
|
+
- `TableCell` for data cells within a `TableRow`.
|
|
40
|
+
- `TablePagination` provides pagination controls for the table.
|
|
41
|
+
|
|
42
|
+
## Variants
|
|
43
|
+
|
|
44
|
+
`Table` supports the following variants, based on the `Card` component:
|
|
45
|
+
|
|
46
|
+
- `undefined` - No `Card` container, minimal styling
|
|
47
|
+
- `subtle` - Subtle `Card` container
|
|
48
|
+
- `emphasis` - Emphasis `Card` container
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<Table variant="subtle">
|
|
52
|
+
<TableHeader>
|
|
53
|
+
<TableHeaderCell>Name</TableHeaderCell>
|
|
54
|
+
<TableHeaderCell>Occupation</TableHeaderCell>
|
|
55
|
+
</TableHeader>
|
|
56
|
+
<TableBody>
|
|
57
|
+
<TableRow>
|
|
58
|
+
<TableHeaderCell row>Toni Morrison</TableCell>
|
|
59
|
+
<TableCell>Writer</TableCell>
|
|
60
|
+
</TableRow>
|
|
61
|
+
</TableBody>
|
|
62
|
+
</Table>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
<Flex direction="column" gap="600">
|
|
67
|
+
{variants.map(variant => (
|
|
68
|
+
<Table key={variant} variant={variant}>
|
|
69
|
+
<TableHeader>
|
|
70
|
+
<TableHeaderCell>Name</TableHeaderCell>
|
|
71
|
+
<TableHeaderCell>Email</TableHeaderCell>
|
|
72
|
+
<TableHeaderCell>Phone</TableHeaderCell>
|
|
73
|
+
<TableHeaderCell>City</TableHeaderCell>
|
|
74
|
+
</TableHeader>
|
|
75
|
+
<TableBody>
|
|
76
|
+
{personalDetails.slice(0, 5).map(person => (
|
|
77
|
+
<TableRow key={person.id}>
|
|
78
|
+
<TableHeaderCell row>{person.name}</TableHeaderCell>
|
|
79
|
+
<TableCell>{person.email}</TableCell>
|
|
80
|
+
<TableCell>{person.phone}</TableCell>
|
|
81
|
+
<TableCell>{person.city}</TableCell>
|
|
82
|
+
</TableRow>
|
|
83
|
+
))}
|
|
84
|
+
</TableBody>
|
|
85
|
+
</Table>
|
|
86
|
+
))}
|
|
87
|
+
</Flex>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Pagination
|
|
91
|
+
|
|
92
|
+
Use the `pagination` prop to include pagination.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<Table
|
|
96
|
+
pagination={
|
|
97
|
+
<TablePagination
|
|
98
|
+
currentPage={currentPage}
|
|
99
|
+
totalPages={totalPages}
|
|
100
|
+
onPageChange={setCurrentPage}
|
|
101
|
+
/>
|
|
102
|
+
}
|
|
103
|
+
>
|
|
104
|
+
<TableHeader>{...}</TableHeader>
|
|
105
|
+
<TableBody>{...}</TableBody>
|
|
106
|
+
</Table>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<Table
|
|
111
|
+
{...args}
|
|
112
|
+
pagination={
|
|
113
|
+
<TablePagination
|
|
114
|
+
currentPage={currentPage}
|
|
115
|
+
totalPages={totalPages}
|
|
116
|
+
onPageChange={setCurrentPage}
|
|
117
|
+
/>
|
|
118
|
+
}
|
|
119
|
+
>
|
|
120
|
+
<TableHeader>
|
|
121
|
+
<TableHeaderCell>Name</TableHeaderCell>
|
|
122
|
+
<TableHeaderCell>Email</TableHeaderCell>
|
|
123
|
+
<TableHeaderCell>Phone</TableHeaderCell>
|
|
124
|
+
<TableHeaderCell>City</TableHeaderCell>
|
|
125
|
+
</TableHeader>
|
|
126
|
+
<TableBody>
|
|
127
|
+
{pageData.map(person => (
|
|
128
|
+
<TableRow key={person.id}>
|
|
129
|
+
<TableHeaderCell row>{person.name}</TableHeaderCell>
|
|
130
|
+
<TableCell>{person.email}</TableCell>
|
|
131
|
+
<TableCell>{person.phone}</TableCell>
|
|
132
|
+
<TableCell>{person.city}</TableCell>
|
|
133
|
+
</TableRow>
|
|
134
|
+
))}
|
|
135
|
+
</TableBody>
|
|
136
|
+
</Table>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Header cells
|
|
140
|
+
|
|
141
|
+
The `TableHeaderCell` component is used for column header cell within the `TableHeader` component.
|
|
142
|
+
|
|
143
|
+
When the `row` prop is set it can also be used as the first cell in a `TableRow`.
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
<Table>
|
|
147
|
+
<TableHeader>
|
|
148
|
+
<TableHeaderCell>Name</TableHeaderCell>
|
|
149
|
+
<TableHeaderCell>Occupation</TableHeaderCell>
|
|
150
|
+
</TableHeader>
|
|
151
|
+
<TableBody>
|
|
152
|
+
<TableRow>
|
|
153
|
+
<TableHeaderCell row>Toni Morrison</TableHeaderCell>
|
|
154
|
+
<TableCell>Writer</TableCell>
|
|
155
|
+
</TableRow>
|
|
156
|
+
</TableBody>
|
|
157
|
+
</Table>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Text Align
|
|
161
|
+
|
|
162
|
+
You can align the text in both the `TableHeaderCell` and `TableCell` components using the `textAlign` prop.
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
<Table>
|
|
166
|
+
<TableHeader>
|
|
167
|
+
<TableHeaderCell textAlign="left">Name</TableHeaderCell>
|
|
168
|
+
<TableHeaderCell textAlign="center">Occupation</TableHeaderCell>
|
|
169
|
+
<TableHeaderCell textAlign="right">Location</TableHeaderCell>
|
|
170
|
+
</TableHeader>
|
|
171
|
+
<TableBody>
|
|
172
|
+
<TableRow>
|
|
173
|
+
<TableCell textAlign="left">Toni Morrison</TableCell>
|
|
174
|
+
<TableCell textAlign="center">Writer</TableCell>
|
|
175
|
+
<TableCell textAlign="right">United States</TableCell>
|
|
176
|
+
</TableRow>
|
|
177
|
+
</TableBody>
|
|
178
|
+
</Table>
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## API
|
|
182
|
+
|
|
183
|
+
This component is based on the `table` element and supports the following common props:
|
|
184
|
+
|
|
185
|
+
- Margin
|
|
186
|
+
|
|
187
|
+
| Prop | Type | Default | Description |
|
|
188
|
+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------- |
|
|
189
|
+
| `margin` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
190
|
+
| `marginTop` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
191
|
+
| `marginRight` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
192
|
+
| `marginBottom` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
193
|
+
| `marginLeft` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
194
|
+
| `marginX` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
195
|
+
| `marginY` | `Responsive<"auto" \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000" \| `var(--h-${string})`>` | — | |
|
|
196
|
+
| `variant` | `"emphasis" \| "subtle"` | — | Sets the visual variant of the table. When undefined, the table is rendered without a Card wrapper. |
|
|
197
|
+
| `pagination` | `ReactElement<TablePaginationProps, string \| JSXElementConstructor<any>>` | — | |
|
|
198
|
+
|
|
199
|
+
### TableHeader API
|
|
200
|
+
|
|
201
|
+
This component is based on the `thead` element.
|
|
202
|
+
|
|
203
|
+
### TableHeaderCell API
|
|
204
|
+
|
|
205
|
+
This component is based on the `th` element and supports the following common props:
|
|
206
|
+
|
|
207
|
+
- Text Align
|
|
208
|
+
|
|
209
|
+
| Prop | Type | Default | Description |
|
|
210
|
+
| ----------- | ------------------------------------------- | ------- | ----------- |
|
|
211
|
+
| `row` | `boolean` | — | |
|
|
212
|
+
| `textAlign` | `Responsive<"center" \| "left" \| "right">` | — | |
|
|
213
|
+
|
|
214
|
+
### TableBody API
|
|
215
|
+
|
|
216
|
+
This component is based on the `tbody` element.
|
|
217
|
+
|
|
218
|
+
### TableRow API
|
|
219
|
+
|
|
220
|
+
This component is based on the `tr` element.
|
|
221
|
+
|
|
222
|
+
### TableCell API
|
|
223
|
+
|
|
224
|
+
This component is based on the `td` element and supports the following common props:
|
|
225
|
+
|
|
226
|
+
- Text Align
|
|
227
|
+
|
|
228
|
+
### TablePagination API
|
|
229
|
+
|
|
230
|
+
This component is based on the `Pagination` component.
|