@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,320 @@
|
|
|
1
|
+
# Tabs
|
|
2
|
+
|
|
3
|
+
Use Tabs to organize and navigate between content sections within the same context without leaving the page.
|
|
4
|
+
|
|
5
|
+
- [Usage](#usage)
|
|
6
|
+
- [Examples](#examples)
|
|
7
|
+
- [Controlled](#controlled)
|
|
8
|
+
- [Overflow & Scrolling](#overflow--scrolling)
|
|
9
|
+
- [With icons](#with-icons)
|
|
10
|
+
- [Size variants](#size-variants)
|
|
11
|
+
- [Activation mode](#activation-mode)
|
|
12
|
+
- [Accessibility](#accessibility)
|
|
13
|
+
- [API](#api)
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<Tabs {...args}>
|
|
17
|
+
<TabsList>
|
|
18
|
+
<Tab value="account">Account</Tab>
|
|
19
|
+
<Tab value="security">Security</Tab>
|
|
20
|
+
<Tab value="billing">Billing</Tab>
|
|
21
|
+
</TabsList>
|
|
22
|
+
<TabContent value="account">
|
|
23
|
+
<BodyText>Manage your personal details and preferences.</BodyText>
|
|
24
|
+
</TabContent>
|
|
25
|
+
<TabContent value="security">
|
|
26
|
+
<BodyText>Update your password and security settings.</BodyText>
|
|
27
|
+
</TabContent>
|
|
28
|
+
<TabContent value="billing">
|
|
29
|
+
<BodyText>View invoices and update payment methods.</BodyText>
|
|
30
|
+
</TabContent>
|
|
31
|
+
</Tabs>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
Use Tabs to organize and navigate between content sections within the same page context.
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
import { Tabs, TabsList, Tab, TabContent } from '@utilitywarehouse/hearth-react';
|
|
40
|
+
|
|
41
|
+
<Tabs defaultValue="account">
|
|
42
|
+
<TabsList>
|
|
43
|
+
<Tab value="account">Account</Tab>
|
|
44
|
+
<Tab value="security">Security</Tab>
|
|
45
|
+
<Tab value="billing">Billing</Tab>
|
|
46
|
+
</TabsList>
|
|
47
|
+
<TabContent value="account">Account content</TabContent>
|
|
48
|
+
<TabContent value="security">Security content</TabContent>
|
|
49
|
+
<TabContent value="billing">Billing content</TabContent>
|
|
50
|
+
</Tabs>;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Spacing
|
|
54
|
+
|
|
55
|
+
The `spacing` prop on the `Tabs` component controls the space between the `TabsList` and the `TabContent`.
|
|
56
|
+
It is set to `"xl"` by default, and can be overridden as needed.
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
<Tabs defaultValue="account" spacing="lg">
|
|
60
|
+
<TabsList>
|
|
61
|
+
<Tab value="account">Account</Tab>
|
|
62
|
+
<Tab value="security">Security</Tab>
|
|
63
|
+
<Tab value="billing">Billing</Tab>
|
|
64
|
+
</TabsList>
|
|
65
|
+
<TabContent value="account">Account content</TabContent>
|
|
66
|
+
<TabContent value="security">Security content</TabContent>
|
|
67
|
+
<TabContent value="billing">Billing content</TabContent>
|
|
68
|
+
</Tabs>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Controlled
|
|
72
|
+
|
|
73
|
+
Tabs can be controlled by passing `value` and `onValueChange` to the `Tabs` root.
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
const [tab, setTab] = useState('account');
|
|
77
|
+
<Tabs value={tab} onValueChange={setTab}>
|
|
78
|
+
<TabsList>
|
|
79
|
+
<Tab value="account">Account</Tab>
|
|
80
|
+
<Tab value="billing">Billing</Tab>
|
|
81
|
+
<Tab value="usage">Usage</Tab>
|
|
82
|
+
</TabsList>
|
|
83
|
+
<TabContent value="account">Account content</TabContent>
|
|
84
|
+
<TabContent value="billing">Billing content</TabContent>
|
|
85
|
+
<TabContent value="usage">Usage metrics content</TabContent>
|
|
86
|
+
</Tabs>;
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
<Flex direction="row" gap="400" alignItems="center">
|
|
91
|
+
<Tabs value={value} onValueChange={setValue}>
|
|
92
|
+
<TabsList>
|
|
93
|
+
<Tab value="account">Account</Tab>
|
|
94
|
+
<Tab value="billing">Billing</Tab>
|
|
95
|
+
<Tab value="usage">Usage</Tab>
|
|
96
|
+
</TabsList>
|
|
97
|
+
<TabContent value="account">
|
|
98
|
+
<BodyText>Account content</BodyText>
|
|
99
|
+
</TabContent>
|
|
100
|
+
<TabContent value="billing">
|
|
101
|
+
<BodyText>Billing content</BodyText>
|
|
102
|
+
</TabContent>
|
|
103
|
+
<TabContent value="usage">
|
|
104
|
+
<BodyText>Usage metrics content</BodyText>
|
|
105
|
+
</TabContent>
|
|
106
|
+
</Tabs>
|
|
107
|
+
<Button onClick={next}>Next Tab</Button>
|
|
108
|
+
</Flex>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Overflow & Scrolling
|
|
112
|
+
|
|
113
|
+
When tab labels exceed the available width, the list becomes horizontally
|
|
114
|
+
scrollable. Contextual scroll buttons appear only when further scrolling is
|
|
115
|
+
possible.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
<Tabs defaultValue="one">
|
|
119
|
+
<TabsList>
|
|
120
|
+
<Tab value="one">One</Tab>
|
|
121
|
+
<Tab value="two">Two</Tab>
|
|
122
|
+
<Tab value="three">Three</Tab>
|
|
123
|
+
<Tab value="four">Four</Tab>
|
|
124
|
+
<Tab value="five">Five</Tab>
|
|
125
|
+
<Tab value="six">Six</Tab>
|
|
126
|
+
<Tab value="seven">Seven</Tab>
|
|
127
|
+
<Tab value="eight">Eight</Tab>
|
|
128
|
+
<Tab value="nine">Nine</Tab>
|
|
129
|
+
<Tab value="ten">Ten</Tab>
|
|
130
|
+
<Tab value="eleven">Eleven</Tab>
|
|
131
|
+
<Tab value="twelve">Twelve</Tab>
|
|
132
|
+
<Tab value="thirteen">Thirteen</Tab>
|
|
133
|
+
<Tab value="fourteen">Fourteen</Tab>
|
|
134
|
+
<Tab value="fifteen">Fifteen</Tab>
|
|
135
|
+
<Tab value="sixteen">Sixteen</Tab>
|
|
136
|
+
<Tab value="seventeen">Seventeen</Tab>
|
|
137
|
+
<Tab value="eighteen">Eighteen</Tab>
|
|
138
|
+
<Tab value="nineteen">Nineteen</Tab>
|
|
139
|
+
<Tab value="twenty">Twenty</Tab>
|
|
140
|
+
</TabsList>
|
|
141
|
+
<TabContent value="one">
|
|
142
|
+
<BodyText>One panel</BodyText>
|
|
143
|
+
</TabContent>
|
|
144
|
+
<TabContent value="two">
|
|
145
|
+
<BodyText>Two panel</BodyText>
|
|
146
|
+
</TabContent>
|
|
147
|
+
<TabContent value="three">
|
|
148
|
+
<BodyText>Three panel</BodyText>
|
|
149
|
+
</TabContent>
|
|
150
|
+
<TabContent value="four">
|
|
151
|
+
<BodyText>Four panel</BodyText>
|
|
152
|
+
</TabContent>
|
|
153
|
+
<TabContent value="five">
|
|
154
|
+
<BodyText>Five panel</BodyText>
|
|
155
|
+
</TabContent>
|
|
156
|
+
<TabContent value="six">
|
|
157
|
+
<BodyText>Six panel</BodyText>
|
|
158
|
+
</TabContent>
|
|
159
|
+
<TabContent value="seven">
|
|
160
|
+
<BodyText>Seven panel</BodyText>
|
|
161
|
+
</TabContent>
|
|
162
|
+
<TabContent value="eight">
|
|
163
|
+
<BodyText>Eight panel</BodyText>
|
|
164
|
+
</TabContent>
|
|
165
|
+
<TabContent value="nine">
|
|
166
|
+
<BodyText>Nine panel</BodyText>
|
|
167
|
+
</TabContent>
|
|
168
|
+
<TabContent value="ten">
|
|
169
|
+
<BodyText>Ten panel</BodyText>
|
|
170
|
+
</TabContent>
|
|
171
|
+
<TabContent value="eleven">
|
|
172
|
+
<BodyText>Eleven panel</BodyText>
|
|
173
|
+
</TabContent>
|
|
174
|
+
<TabContent value="twelve">
|
|
175
|
+
<BodyText>Twelve panel</BodyText>
|
|
176
|
+
</TabContent>
|
|
177
|
+
<TabContent value="thirteen">
|
|
178
|
+
<BodyText>Thirteen panel</BodyText>
|
|
179
|
+
</TabContent>
|
|
180
|
+
<TabContent value="fourteen">
|
|
181
|
+
<BodyText>Fourteen panel</BodyText>
|
|
182
|
+
</TabContent>
|
|
183
|
+
<TabContent value="fifteen">
|
|
184
|
+
<BodyText>Fifteen panel</BodyText>
|
|
185
|
+
</TabContent>
|
|
186
|
+
<TabContent value="sixteen">
|
|
187
|
+
<BodyText>Sixteen panel</BodyText>
|
|
188
|
+
</TabContent>
|
|
189
|
+
<TabContent value="seventeen">
|
|
190
|
+
<BodyText>Seventeen panel</BodyText>
|
|
191
|
+
</TabContent>
|
|
192
|
+
<TabContent value="eighteen">
|
|
193
|
+
<BodyText>Eighteen panel</BodyText>
|
|
194
|
+
</TabContent>
|
|
195
|
+
<TabContent value="nineteen">
|
|
196
|
+
<BodyText>Nineteen panel</BodyText>
|
|
197
|
+
</TabContent>
|
|
198
|
+
<TabContent value="twenty">
|
|
199
|
+
<BodyText>Twenty panel</BodyText>
|
|
200
|
+
</TabContent>
|
|
201
|
+
</Tabs>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### With icons
|
|
205
|
+
|
|
206
|
+
You can include icons directly as children inside a `Tab`.
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
<Tabs defaultValue="one">
|
|
210
|
+
<TabsList>
|
|
211
|
+
<Tab value="one">
|
|
212
|
+
<ElectricityMediumIcon /> Energy
|
|
213
|
+
</Tab>
|
|
214
|
+
<Tab value="two">
|
|
215
|
+
<BroadbandMediumIcon /> Broadband
|
|
216
|
+
</Tab>
|
|
217
|
+
<Tab value="three">
|
|
218
|
+
<MobileMediumIcon /> Mobile
|
|
219
|
+
</Tab>
|
|
220
|
+
<Tab value="four">
|
|
221
|
+
<InsuranceMediumIcon /> Insurance
|
|
222
|
+
</Tab>
|
|
223
|
+
</TabsList>
|
|
224
|
+
<TabContent value="one">
|
|
225
|
+
<BodyText>One panel</BodyText>
|
|
226
|
+
</TabContent>
|
|
227
|
+
<TabContent value="two">
|
|
228
|
+
<BodyText>Two panel</BodyText>
|
|
229
|
+
</TabContent>
|
|
230
|
+
<TabContent value="three">
|
|
231
|
+
<BodyText>Three panel</BodyText>
|
|
232
|
+
</TabContent>
|
|
233
|
+
<TabContent value="four">
|
|
234
|
+
<BodyText>Four panel</BodyText>
|
|
235
|
+
</TabContent>
|
|
236
|
+
</Tabs>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Size variants
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
<Flex direction="column" gap="400">
|
|
243
|
+
<Tabs size="md" defaultValue="a">
|
|
244
|
+
<TabsList>
|
|
245
|
+
<Tab value="a">Medium A</Tab>
|
|
246
|
+
<Tab value="b">Medium B</Tab>
|
|
247
|
+
<Tab value="c">Medium C</Tab>
|
|
248
|
+
</TabsList>
|
|
249
|
+
<TabContent value="a">
|
|
250
|
+
<BodyText>Medium A panel</BodyText>
|
|
251
|
+
</TabContent>
|
|
252
|
+
<TabContent value="b">
|
|
253
|
+
<BodyText>Medium B panel</BodyText>
|
|
254
|
+
</TabContent>
|
|
255
|
+
<TabContent value="c">
|
|
256
|
+
<BodyText>Medium C panel</BodyText>
|
|
257
|
+
</TabContent>
|
|
258
|
+
</Tabs>
|
|
259
|
+
|
|
260
|
+
<Tabs size="lg" defaultValue="a">
|
|
261
|
+
<TabsList>
|
|
262
|
+
<Tab value="a">Large A</Tab>
|
|
263
|
+
<Tab value="b">Large B</Tab>
|
|
264
|
+
<Tab value="c">Large C</Tab>
|
|
265
|
+
</TabsList>
|
|
266
|
+
<TabContent value="a">
|
|
267
|
+
<BodyText>Large A panel</BodyText>
|
|
268
|
+
</TabContent>
|
|
269
|
+
<TabContent value="b">
|
|
270
|
+
<BodyText>Large B panel</BodyText>
|
|
271
|
+
</TabContent>
|
|
272
|
+
<TabContent value="c">
|
|
273
|
+
<BodyText>Large C panel</BodyText>
|
|
274
|
+
</TabContent>
|
|
275
|
+
</Tabs>
|
|
276
|
+
</Flex>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
## Activation mode
|
|
280
|
+
|
|
281
|
+
The `activationMode` prop controls how keyboard focus activates a tab:
|
|
282
|
+
|
|
283
|
+
- `automatic` (default): arrow keys both move focus and select the focused tab.
|
|
284
|
+
- `manual`: arrow keys move focus between tabs; selection changes when you press <kbd>Space</kbd> or <kbd>Enter</kbd>.
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
<Tabs defaultValue="a" activationMode="manual">
|
|
288
|
+
...
|
|
289
|
+
</Tabs>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Performance considerations
|
|
293
|
+
|
|
294
|
+
The default `automatic` mode provides the best user experience for most cases.
|
|
295
|
+
However, **use `manual` mode when tab panels contain heavily loaded content**
|
|
296
|
+
that might cause lag during automatic activation. This prevents automatic panel
|
|
297
|
+
switching as users navigate with arrow keys, avoiding performance issues.
|
|
298
|
+
|
|
299
|
+
**Prefetching panel data is the preferred solution** over relying on manual
|
|
300
|
+
activation mode. Consider preloading content for adjacent tabs to provide a
|
|
301
|
+
smooth experience while maintaining the benefits of automatic activation.
|
|
302
|
+
|
|
303
|
+
## Accessibility
|
|
304
|
+
|
|
305
|
+
- The `Tabs` root provides the `tablist` role; each `Tab` is a `tab`; each `TabContent` is a `tabpanel`.
|
|
306
|
+
- Selection is communicated via ARIA attributes and `data-state` provided by the underlying primitives.
|
|
307
|
+
- The animated indicator respects the user's reduced motion preferences.
|
|
308
|
+
- Overflow scroll buttons are hidden from assistive technologies and only render when scrolling is possible.
|
|
309
|
+
- Provide concise, descriptive tab labels; avoid relying on icons alone.
|
|
310
|
+
|
|
311
|
+
### Tabs
|
|
312
|
+
|
|
313
|
+
| Prop | Type | Default | Description |
|
|
314
|
+
| ---------------- | ------------------------------------------------------------------ | ------- | ---------------------------------------------------------- |
|
|
315
|
+
| `defaultValue` | `string` | — | The value of the tab to select by default, if uncontrolled |
|
|
316
|
+
| `value` | `string` | — | The value for the selected tab, if controlled |
|
|
317
|
+
| `onValueChange` | `((value: string) => void)` | — | A function called when a new tab is selected |
|
|
318
|
+
| `activationMode` | `"manual" \| "automatic"` | — | Activation mode for tabs |
|
|
319
|
+
| `size` | `Responsive<"md" \| "lg">` | — | Size variant |
|
|
320
|
+
| `spacing` | `"none" \| "md" \| "lg" \| "2xs" \| "xs" \| "sm" \| "xl" \| "2xl"` | — | |
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# TextArea
|
|
2
|
+
|
|
3
|
+
`TextArea` is a multi-line text input field that allows users to enter longer text content.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
<TextArea {...args} />
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- [Label](#label)
|
|
10
|
+
- [Helper Text](#helper-text)
|
|
11
|
+
- [Validation](#validation)
|
|
12
|
+
- [Disabled and Read-only](#disabled-and-read-only)
|
|
13
|
+
- [Custom Rows](#custom-rows)
|
|
14
|
+
- [Height](#height)
|
|
15
|
+
- [Controlled Usage](#controlled-usage)
|
|
16
|
+
- [API](#api)
|
|
17
|
+
|
|
18
|
+
## Label
|
|
19
|
+
|
|
20
|
+
A label is required for the `TextArea` component. It should clearly describe
|
|
21
|
+
the purpose of the field.
|
|
22
|
+
|
|
23
|
+
## Helper Text
|
|
24
|
+
|
|
25
|
+
You can provide additional context or instructions using the `helperText` prop.
|
|
26
|
+
|
|
27
|
+
## Validation
|
|
28
|
+
|
|
29
|
+
The `validationStatus` prop can be set to either `"valid"` or `"invalid"` to
|
|
30
|
+
indicate the validation state. This must be accompanied by a `validationText`
|
|
31
|
+
to explain the reason for the status.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<Flex direction="column" gap="400">
|
|
35
|
+
<TextArea
|
|
36
|
+
{...args}
|
|
37
|
+
label="Valid TextArea"
|
|
38
|
+
validationStatus="valid"
|
|
39
|
+
validationText="Looks good!"
|
|
40
|
+
value="This is valid input."
|
|
41
|
+
/>
|
|
42
|
+
<TextArea
|
|
43
|
+
{...args}
|
|
44
|
+
label="Invalid TextArea"
|
|
45
|
+
validationStatus="invalid"
|
|
46
|
+
validationText="Please correct the error."
|
|
47
|
+
value="This is invalid input."
|
|
48
|
+
/>
|
|
49
|
+
</Flex>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Disabled and Read-only
|
|
53
|
+
|
|
54
|
+
- **Disabled**: The `disabled` prop prevents user interaction with the `TextArea`.
|
|
55
|
+
- **Read-only**: The `readOnly` prop allows the field to be focusable but not editable.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<Flex direction="column" gap="400">
|
|
59
|
+
<TextArea {...args} label="Disabled" disabled helperText="This field is disabled." />
|
|
60
|
+
<TextArea
|
|
61
|
+
{...args}
|
|
62
|
+
label="Read-only"
|
|
63
|
+
readOnly
|
|
64
|
+
value="This is a read-only text area."
|
|
65
|
+
helperText="This field is read-only."
|
|
66
|
+
/>
|
|
67
|
+
</Flex>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Custom Rows
|
|
71
|
+
|
|
72
|
+
You can control the number of visible rows using the `rows` prop.
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<Flex direction="column" gap="400">
|
|
76
|
+
<TextArea {...args} label="3 Rows" rows={3} />
|
|
77
|
+
<TextArea {...args} label="5 Rows" rows={5} />
|
|
78
|
+
<TextArea {...args} label="10 Rows" rows={10} />
|
|
79
|
+
</Flex>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Height
|
|
83
|
+
|
|
84
|
+
You can set a minimum and maximum height for the `TextArea` using the `minHeight` & `maxHeight` props.
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<TextArea {...args} />
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Controlled Usage
|
|
91
|
+
|
|
92
|
+
The `TextArea` can be used as a controlled component by managing its `value` and `onChange` props.
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
const [value, setValue] = React.useState<string>('Initial value');
|
|
96
|
+
return (
|
|
97
|
+
<TextArea
|
|
98
|
+
{...args}
|
|
99
|
+
value={value}
|
|
100
|
+
onChange={(event: React.ChangeEvent<HTMLTextAreaElement>) => setValue(event.target.value)}
|
|
101
|
+
label="Controlled TextArea"
|
|
102
|
+
/>
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
<TextArea
|
|
108
|
+
{...args}
|
|
109
|
+
value={value}
|
|
110
|
+
onChange={(event: ChangeEvent<HTMLTextAreaElement>) => setValue(event.target.value)}
|
|
111
|
+
label="Controlled TextArea"
|
|
112
|
+
/>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## API
|
|
116
|
+
|
|
117
|
+
This component is based on the `textarea` element, and supports the following common props:
|
|
118
|
+
|
|
119
|
+
- Margin
|
|
120
|
+
|
|
121
|
+
| Prop | Type | Default | Description |
|
|
122
|
+
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------ |
|
|
123
|
+
| `label` | `string` | — | The label for the form field, describing its purpose. |
|
|
124
|
+
| `value` | `string` | — | The controlled value of the TextArea. Must be used with an `onChange` handler. |
|
|
125
|
+
| `labelId` | `string` | — | |
|
|
126
|
+
| `helperTextId` | `string` | — | |
|
|
127
|
+
| `validationTextId` | `string` | — | |
|
|
128
|
+
| `labelVariant` | `"body" \| "heading"` | — | Change the label variant |
|
|
129
|
+
| `helperText` | `string` | — | Optional helper text to provide additional context or instructions. |
|
|
130
|
+
| `validationText` | `string` | — | Text to display when the `validationStatus` is set. |
|
|
131
|
+
| `validationStatus` | `"valid" \| "invalid"` | — | Indicates the validation status. |
|
|
132
|
+
| `resize` | `"none" \| "both" \| "horizontal" \| "vertical"` | `"both"` | Controls the resize behavior of the TextArea. |
|
|
133
|
+
| `minHeight` | `Responsive<string>` | — | Sets the minimum height of the TextArea. |
|
|
134
|
+
| `maxHeight` | `Responsive<string>` | — | Sets the maximum height of the TextArea. |
|
|
135
|
+
| `margin` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
136
|
+
| `marginTop` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
137
|
+
| `marginRight` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
138
|
+
| `marginBottom` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
139
|
+
| `marginLeft` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
140
|
+
| `marginX` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|
|
141
|
+
| `marginY` | `Responsive<"auto" \| `var(--h-${string})` \| "0" \| "25" \| "50" \| "75" \| "100" \| "150" \| "175" \| "200" \| "250" \| "300" \| "350" \| "400" \| "500" \| "600" \| "700" \| "800" \| "900" \| "1000">` | — | |
|