@ceed/ads 1.29.1 → 1.30.0-next.1
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/components/CurrencyInput/CurrencyInput.d.ts +1 -1
- package/dist/components/CurrencyInput/hooks/use-currency-setting.d.ts +2 -2
- package/dist/components/ProfileMenu/ProfileMenu.d.ts +1 -1
- package/dist/components/SearchBar/SearchBar.d.ts +21 -0
- package/dist/components/SearchBar/index.d.ts +3 -0
- package/dist/components/data-display/Badge.md +39 -71
- package/dist/components/data-display/DataTable.md +1 -1
- package/dist/components/data-display/InfoSign.md +98 -74
- package/dist/components/data-display/Typography.md +97 -363
- package/dist/components/feedback/Dialog.md +62 -76
- package/dist/components/feedback/Modal.md +44 -259
- package/dist/components/feedback/llms.txt +0 -2
- package/dist/components/index.d.ts +2 -0
- package/dist/components/inputs/Autocomplete.md +107 -356
- package/dist/components/inputs/ButtonGroup.md +106 -115
- package/dist/components/inputs/Calendar.md +459 -98
- package/dist/components/inputs/CurrencyInput.md +5 -183
- package/dist/components/inputs/DatePicker.md +431 -108
- package/dist/components/inputs/DateRangePicker.md +492 -131
- package/dist/components/inputs/FilterMenu.md +19 -169
- package/dist/components/inputs/FilterableCheckboxGroup.md +23 -123
- package/dist/components/inputs/IconButton.md +88 -137
- package/dist/components/inputs/Input.md +0 -5
- package/dist/components/inputs/MonthPicker.md +422 -95
- package/dist/components/inputs/MonthRangePicker.md +466 -89
- package/dist/components/inputs/PercentageInput.md +16 -185
- package/dist/components/inputs/RadioButton.md +35 -163
- package/dist/components/inputs/RadioTileGroup.md +61 -150
- package/dist/components/inputs/SearchBar.md +44 -0
- package/dist/components/inputs/Select.md +326 -222
- package/dist/components/inputs/Switch.md +376 -136
- package/dist/components/inputs/Textarea.md +10 -213
- package/dist/components/inputs/Uploader/Uploader.md +66 -145
- package/dist/components/inputs/llms.txt +1 -3
- package/dist/components/navigation/Breadcrumbs.md +322 -80
- package/dist/components/navigation/Dropdown.md +221 -92
- package/dist/components/navigation/IconMenuButton.md +502 -40
- package/dist/components/navigation/InsetDrawer.md +738 -68
- package/dist/components/navigation/Link.md +298 -39
- package/dist/components/navigation/Menu.md +285 -92
- package/dist/components/navigation/MenuButton.md +448 -55
- package/dist/components/navigation/Pagination.md +338 -47
- package/dist/components/navigation/ProfileMenu.md +268 -45
- package/dist/components/navigation/Stepper.md +28 -160
- package/dist/components/navigation/Tabs.md +316 -57
- package/dist/components/surfaces/Sheet.md +334 -151
- package/dist/index.browser.js +15 -13
- package/dist/index.browser.js.map +4 -4
- package/dist/index.cjs +289 -288
- package/dist/index.d.ts +1 -1
- package/dist/index.js +426 -369
- package/dist/llms.txt +1 -8
- package/framer/index.js +1 -1
- package/package.json +16 -15
- package/dist/chunks/rehype-accent-FZRUD7VI.js +0 -39
- package/dist/components/feedback/CircularProgress.md +0 -257
- package/dist/components/feedback/Skeleton.md +0 -280
- package/dist/components/inputs/FormControl.md +0 -361
- package/dist/components/inputs/RadioList.md +0 -241
- package/dist/components/inputs/Slider.md +0 -334
- package/dist/guides/ThemeProvider.md +0 -116
- package/dist/guides/llms.txt +0 -9
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
# FormControl
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
FormControl is a wrapper component that provides context to form elements such as Input, Textarea, Select, and more. It manages shared states like `error`, `disabled`, `required`, and `size`, passing them down to its children automatically. Use it with FormLabel and FormHelperText to build accessible, consistent form fields.
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
<FormControl {...args}>
|
|
9
|
-
<FormLabel>Label</FormLabel>
|
|
10
|
-
<Input placeholder="Enter text…" />
|
|
11
|
-
<FormHelperText>This is helper text.</FormHelperText>
|
|
12
|
-
</FormControl>
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
| Field | Description | Default |
|
|
16
|
-
| ----------- | ----------- | ------- |
|
|
17
|
-
| size | — | — |
|
|
18
|
-
| error | — | — |
|
|
19
|
-
| disabled | — | — |
|
|
20
|
-
| required | — | — |
|
|
21
|
-
| orientation | — | — |
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { FormControl, FormLabel, FormHelperText, Input } from '@ceed/ads';
|
|
27
|
-
|
|
28
|
-
function MyForm() {
|
|
29
|
-
return (
|
|
30
|
-
<FormControl>
|
|
31
|
-
<FormLabel>Username</FormLabel>
|
|
32
|
-
<Input placeholder="Enter username" />
|
|
33
|
-
<FormHelperText>Choose a unique username.</FormHelperText>
|
|
34
|
-
</FormControl>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## With Input
|
|
40
|
-
|
|
41
|
-
The most common pattern — wrapping an Input with a label and helper text.
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
<FormControl>
|
|
45
|
-
<FormLabel>Username</FormLabel>
|
|
46
|
-
<Input placeholder="Enter username" />
|
|
47
|
-
<FormHelperText>Choose a unique username.</FormHelperText>
|
|
48
|
-
</FormControl>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## With Textarea
|
|
52
|
-
|
|
53
|
-
FormControl works equally well with Textarea components.
|
|
54
|
-
|
|
55
|
-
```tsx
|
|
56
|
-
<FormControl>
|
|
57
|
-
<FormLabel>Description</FormLabel>
|
|
58
|
-
<Textarea placeholder="Enter description…" minRows={3} />
|
|
59
|
-
<FormHelperText>Provide a detailed description.</FormHelperText>
|
|
60
|
-
</FormControl>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## With Select
|
|
64
|
-
|
|
65
|
-
Use FormControl with Select for dropdown fields.
|
|
66
|
-
|
|
67
|
-
```tsx
|
|
68
|
-
<FormControl>
|
|
69
|
-
<FormLabel>Role</FormLabel>
|
|
70
|
-
<Select placeholder="Select a role" options={roleOptions} />
|
|
71
|
-
<FormHelperText>Select the user role.</FormHelperText>
|
|
72
|
-
</FormControl>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Error State
|
|
76
|
-
|
|
77
|
-
Set `error` on FormControl to propagate the error state to all child components. FormHelperText automatically changes color to indicate the error.
|
|
78
|
-
|
|
79
|
-
```tsx
|
|
80
|
-
<FormControl error>
|
|
81
|
-
<FormLabel>Email</FormLabel>
|
|
82
|
-
<Input placeholder="email@example.com" defaultValue="invalid-email" />
|
|
83
|
-
<FormHelperText>Please enter a valid email address.</FormHelperText>
|
|
84
|
-
</FormControl>
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
```tsx
|
|
88
|
-
<FormControl error>
|
|
89
|
-
<FormLabel>Email</FormLabel>
|
|
90
|
-
<Input placeholder="email@example.com" value="invalid-email" />
|
|
91
|
-
<FormHelperText>Please enter a valid email address.</FormHelperText>
|
|
92
|
-
</FormControl>
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Disabled State
|
|
96
|
-
|
|
97
|
-
Set `disabled` to disable all child form elements at once.
|
|
98
|
-
|
|
99
|
-
```tsx
|
|
100
|
-
<FormControl disabled>
|
|
101
|
-
<FormLabel>Name</FormLabel>
|
|
102
|
-
<Input placeholder="Enter name" defaultValue="John Doe" />
|
|
103
|
-
<FormHelperText>This field is disabled.</FormHelperText>
|
|
104
|
-
</FormControl>
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
```tsx
|
|
108
|
-
<FormControl disabled>
|
|
109
|
-
<FormLabel>Name</FormLabel>
|
|
110
|
-
<Input placeholder="Enter name" value="John Doe" />
|
|
111
|
-
<FormHelperText>This field is disabled.</FormHelperText>
|
|
112
|
-
</FormControl>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## Required Field
|
|
116
|
-
|
|
117
|
-
Set `required` to add an asterisk (\*) to the label and mark the field as required.
|
|
118
|
-
|
|
119
|
-
```tsx
|
|
120
|
-
<FormControl required>
|
|
121
|
-
<FormLabel>Full Name</FormLabel>
|
|
122
|
-
<Input placeholder="Enter your full name" />
|
|
123
|
-
<FormHelperText>This field is required.</FormHelperText>
|
|
124
|
-
</FormControl>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
```tsx
|
|
128
|
-
<FormControl required>
|
|
129
|
-
<FormLabel>Full Name</FormLabel>
|
|
130
|
-
<Input placeholder="Enter your full name" />
|
|
131
|
-
</FormControl>
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Sizes
|
|
135
|
-
|
|
136
|
-
FormControl supports `sm`, `md`, and `lg` sizes. The size is inherited by child components.
|
|
137
|
-
|
|
138
|
-
```tsx
|
|
139
|
-
<Stack gap={3}>
|
|
140
|
-
<FormControl size="sm">
|
|
141
|
-
<FormLabel>Small</FormLabel>
|
|
142
|
-
<Input placeholder="Small input" />
|
|
143
|
-
</FormControl>
|
|
144
|
-
<FormControl size="md">
|
|
145
|
-
<FormLabel>Medium</FormLabel>
|
|
146
|
-
<Input placeholder="Medium input" />
|
|
147
|
-
</FormControl>
|
|
148
|
-
<FormControl size="lg">
|
|
149
|
-
<FormLabel>Large</FormLabel>
|
|
150
|
-
<Input placeholder="Large input" />
|
|
151
|
-
</FormControl>
|
|
152
|
-
</Stack>
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## Horizontal Layout
|
|
156
|
-
|
|
157
|
-
Use `orientation="horizontal"` for inline form controls, such as Switch or Checkbox toggles.
|
|
158
|
-
|
|
159
|
-
```tsx
|
|
160
|
-
<FormControl orientation="horizontal" sx={{
|
|
161
|
-
gap: 2
|
|
162
|
-
}}>
|
|
163
|
-
<FormLabel>Subscribe</FormLabel>
|
|
164
|
-
<Switch />
|
|
165
|
-
</FormControl>
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
```tsx
|
|
169
|
-
<FormControl orientation="horizontal" sx={{ gap: 2 }}>
|
|
170
|
-
<FormLabel>Subscribe</FormLabel>
|
|
171
|
-
<Switch />
|
|
172
|
-
</FormControl>
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Form Example
|
|
176
|
-
|
|
177
|
-
A complete form demonstrating FormControl with multiple input types.
|
|
178
|
-
|
|
179
|
-
```tsx
|
|
180
|
-
<Stack gap={2} sx={{
|
|
181
|
-
maxWidth: 400
|
|
182
|
-
}}>
|
|
183
|
-
<FormControl required>
|
|
184
|
-
<FormLabel>Name</FormLabel>
|
|
185
|
-
<Input placeholder="Enter your name" />
|
|
186
|
-
</FormControl>
|
|
187
|
-
<FormControl required>
|
|
188
|
-
<FormLabel>Email</FormLabel>
|
|
189
|
-
<Input type="email" placeholder="email@example.com" />
|
|
190
|
-
<FormHelperText>We will never share your email.</FormHelperText>
|
|
191
|
-
</FormControl>
|
|
192
|
-
<FormControl>
|
|
193
|
-
<FormLabel>Role</FormLabel>
|
|
194
|
-
<Select placeholder="Select a role" options={roleOptions} />
|
|
195
|
-
</FormControl>
|
|
196
|
-
<FormControl>
|
|
197
|
-
<FormLabel>Bio</FormLabel>
|
|
198
|
-
<Textarea placeholder="Tell us about yourself…" minRows={3} />
|
|
199
|
-
<FormHelperText>Maximum 500 characters.</FormHelperText>
|
|
200
|
-
</FormControl>
|
|
201
|
-
</Stack>
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## FormLabel
|
|
205
|
-
|
|
206
|
-
FormLabel renders a `<label>` element associated with its sibling input. It automatically displays an asterisk when the parent FormControl has `required` set.
|
|
207
|
-
|
|
208
|
-
```tsx
|
|
209
|
-
<FormControl required>
|
|
210
|
-
<FormLabel>Email</FormLabel>
|
|
211
|
-
<Input />
|
|
212
|
-
</FormControl>
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## FormHelperText
|
|
216
|
-
|
|
217
|
-
FormHelperText provides supplementary guidance below the input. It automatically switches to the error color when the parent FormControl has `error` set.
|
|
218
|
-
|
|
219
|
-
```tsx
|
|
220
|
-
<FormControl error>
|
|
221
|
-
<FormLabel>Password</FormLabel>
|
|
222
|
-
<Input type="password" />
|
|
223
|
-
<FormHelperText>Password must be at least 8 characters.</FormHelperText>
|
|
224
|
-
</FormControl>
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## Common Use Cases
|
|
228
|
-
|
|
229
|
-
### Registration Form
|
|
230
|
-
|
|
231
|
-
```tsx
|
|
232
|
-
function RegistrationForm() {
|
|
233
|
-
const [errors, setErrors] = React.useState({});
|
|
234
|
-
|
|
235
|
-
return (
|
|
236
|
-
<Stack gap={2} component="form">
|
|
237
|
-
<FormControl required error={!!errors.name}>
|
|
238
|
-
<FormLabel>Name</FormLabel>
|
|
239
|
-
<Input placeholder="Enter your name" />
|
|
240
|
-
{errors.name && <FormHelperText>{errors.name}</FormHelperText>}
|
|
241
|
-
</FormControl>
|
|
242
|
-
|
|
243
|
-
<FormControl required error={!!errors.email}>
|
|
244
|
-
<FormLabel>Email</FormLabel>
|
|
245
|
-
<Input type="email" placeholder="email@example.com" />
|
|
246
|
-
{errors.email && <FormHelperText>{errors.email}</FormHelperText>}
|
|
247
|
-
</FormControl>
|
|
248
|
-
|
|
249
|
-
<FormControl required error={!!errors.password}>
|
|
250
|
-
<FormLabel>Password</FormLabel>
|
|
251
|
-
<Input type="password" placeholder="Enter password" />
|
|
252
|
-
<FormHelperText>{errors.password || 'Must be at least 8 characters.'}</FormHelperText>
|
|
253
|
-
</FormControl>
|
|
254
|
-
|
|
255
|
-
<FormControl orientation="horizontal">
|
|
256
|
-
<Checkbox label="I agree to the terms and conditions" />
|
|
257
|
-
</FormControl>
|
|
258
|
-
</Stack>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
### Settings Form with Mixed Controls
|
|
264
|
-
|
|
265
|
-
```tsx
|
|
266
|
-
function SettingsForm() {
|
|
267
|
-
return (
|
|
268
|
-
<Stack gap={2}>
|
|
269
|
-
<FormControl orientation="horizontal" sx={{ justifyContent: 'space-between' }}>
|
|
270
|
-
<FormLabel>Email notifications</FormLabel>
|
|
271
|
-
<Switch />
|
|
272
|
-
</FormControl>
|
|
273
|
-
|
|
274
|
-
<FormControl>
|
|
275
|
-
<FormLabel>Language</FormLabel>
|
|
276
|
-
<Select
|
|
277
|
-
defaultValue="en"
|
|
278
|
-
options={[
|
|
279
|
-
{ value: 'en', label: 'English' },
|
|
280
|
-
{ value: 'ko', label: 'Korean' },
|
|
281
|
-
]}
|
|
282
|
-
/>
|
|
283
|
-
</FormControl>
|
|
284
|
-
|
|
285
|
-
<FormControl>
|
|
286
|
-
<FormLabel>Notes</FormLabel>
|
|
287
|
-
<Textarea minRows={3} placeholder="Additional notes…" />
|
|
288
|
-
<FormHelperText>Optional</FormHelperText>
|
|
289
|
-
</FormControl>
|
|
290
|
-
</Stack>
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
> **Tip: Use built-in form props instead**
|
|
296
|
-
>
|
|
297
|
-
> Input, Select, Textarea, DatePicker 등 Input 계열 컴포넌트는 `label`, `helperText` prop을 자체적으로 지원합니다.
|
|
298
|
-
> 간단한 form 필드에는 각 컴포넌트의 내장 prop을 사용하는 것이 더 간결합니다.
|
|
299
|
-
>
|
|
300
|
-
> ```tsx
|
|
301
|
-
> // ✅ Simpler: built-in props
|
|
302
|
-
> <Input label="Username" helperText="Choose a unique username." />
|
|
303
|
-
>
|
|
304
|
-
> // ⬆️ Equivalent to:
|
|
305
|
-
> <FormControl>
|
|
306
|
-
> <FormLabel>Username</FormLabel>
|
|
307
|
-
> <Input placeholder="Enter username" />
|
|
308
|
-
> <FormHelperText>Choose a unique username.</FormHelperText>
|
|
309
|
-
> </FormControl>
|
|
310
|
-
> ```
|
|
311
|
-
>
|
|
312
|
-
> FormControl is most useful when you need to compose multiple elements, share state across siblings, or use horizontal orientation.
|
|
313
|
-
|
|
314
|
-
## Best Practices
|
|
315
|
-
|
|
316
|
-
1. **Always pair with FormLabel**: Every form field should have a label for accessibility. Use FormLabel inside FormControl.
|
|
317
|
-
|
|
318
|
-
```tsx
|
|
319
|
-
// ✅ Accessible — label is associated with input
|
|
320
|
-
<FormControl>
|
|
321
|
-
<FormLabel>Email</FormLabel>
|
|
322
|
-
<Input />
|
|
323
|
-
</FormControl>
|
|
324
|
-
|
|
325
|
-
// ❌ No label — screen readers cannot identify the input
|
|
326
|
-
<FormControl>
|
|
327
|
-
<Input placeholder="Email" />
|
|
328
|
-
</FormControl>
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
2. **Use `error` prop on FormControl, not children**: Set error state on FormControl so all children react consistently.
|
|
332
|
-
|
|
333
|
-
```tsx
|
|
334
|
-
// ✅ Error propagated from FormControl
|
|
335
|
-
<FormControl error>
|
|
336
|
-
<FormLabel>Email</FormLabel>
|
|
337
|
-
<Input />
|
|
338
|
-
<FormHelperText>Invalid email</FormHelperText>
|
|
339
|
-
</FormControl>
|
|
340
|
-
|
|
341
|
-
// ❌ Inconsistent — only Input shows error
|
|
342
|
-
<FormControl>
|
|
343
|
-
<FormLabel>Email</FormLabel>
|
|
344
|
-
<Input error />
|
|
345
|
-
<FormHelperText>Invalid email</FormHelperText>
|
|
346
|
-
</FormControl>
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
3. **Use consistent sizing**: Set `size` on FormControl to ensure all children (label, input, helper text) are proportionally sized.
|
|
350
|
-
|
|
351
|
-
4. **Mark required fields**: Use the `required` prop to automatically add visual indicators and `aria-required` attributes.
|
|
352
|
-
|
|
353
|
-
5. **Provide helpful error messages**: When using the error state, always include a FormHelperText explaining what went wrong and how to fix it.
|
|
354
|
-
|
|
355
|
-
## Accessibility
|
|
356
|
-
|
|
357
|
-
- FormControl automatically associates FormLabel with the input using `htmlFor` and `id`.
|
|
358
|
-
- The `required` prop adds `aria-required="true"` to the input and an asterisk to the label.
|
|
359
|
-
- The `error` prop adds `aria-invalid="true"` to the input.
|
|
360
|
-
- FormHelperText is linked to the input via `aria-describedby` so screen readers announce it.
|
|
361
|
-
- Use the `disabled` prop on FormControl to set `aria-disabled` on child elements.
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
# RadioList
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
4
|
-
|
|
5
|
-
RadioList is a convenience component that renders a group of radio buttons from a data array. It wraps RadioGroup and Radio internally, providing a simpler API for the common pattern of rendering a list of options. Pass an array of `{ label, value }` items and the component handles the rest.
|
|
6
|
-
|
|
7
|
-
```tsx
|
|
8
|
-
<RadioList
|
|
9
|
-
items={defaultItems}
|
|
10
|
-
defaultValue="option1"
|
|
11
|
-
/>
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
| Field | Description | Default |
|
|
15
|
-
| ----------- | ----------- | ------- |
|
|
16
|
-
| size | — | — |
|
|
17
|
-
| color | — | — |
|
|
18
|
-
| orientation | — | — |
|
|
19
|
-
| disabled | — | — |
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
```tsx
|
|
24
|
-
import { RadioList } from '@ceed/ads';
|
|
25
|
-
|
|
26
|
-
function MyComponent() {
|
|
27
|
-
return (
|
|
28
|
-
<RadioList
|
|
29
|
-
items={[
|
|
30
|
-
{ label: 'Small', value: 'sm' },
|
|
31
|
-
{ label: 'Medium', value: 'md' },
|
|
32
|
-
{ label: 'Large', value: 'lg' },
|
|
33
|
-
]}
|
|
34
|
-
defaultValue="md"
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Basic List
|
|
41
|
-
|
|
42
|
-
A simple radio list with three options and a default selection.
|
|
43
|
-
|
|
44
|
-
```tsx
|
|
45
|
-
<RadioList items={[{
|
|
46
|
-
label: 'Small',
|
|
47
|
-
value: 'sm'
|
|
48
|
-
}, {
|
|
49
|
-
label: 'Medium',
|
|
50
|
-
value: 'md'
|
|
51
|
-
}, {
|
|
52
|
-
label: 'Large',
|
|
53
|
-
value: 'lg'
|
|
54
|
-
}]} defaultValue="md" />
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Controlled
|
|
58
|
-
|
|
59
|
-
Use `value` and `onChange` for controlled state management.
|
|
60
|
-
|
|
61
|
-
```tsx
|
|
62
|
-
<Stack gap={2}>
|
|
63
|
-
<Typography level="body-sm">Selected: {value}</Typography>
|
|
64
|
-
<RadioList items={defaultItems} value={value} onChange={e => setValue((e.target as HTMLInputElement).value)} />
|
|
65
|
-
</Stack>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
```tsx
|
|
69
|
-
function ControlledExample() {
|
|
70
|
-
const [value, setValue] = React.useState('option1');
|
|
71
|
-
return (
|
|
72
|
-
<RadioList
|
|
73
|
-
items={items}
|
|
74
|
-
value={value}
|
|
75
|
-
onChange={(e) => setValue((e.target as HTMLInputElement).value)}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## With Default Value
|
|
82
|
-
|
|
83
|
-
Use `defaultValue` for uncontrolled usage with an initial selection.
|
|
84
|
-
|
|
85
|
-
```tsx
|
|
86
|
-
<RadioList items={defaultItems} defaultValue="option2" />
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
## Disabled
|
|
90
|
-
|
|
91
|
-
Set `disabled` to prevent all radio buttons from being interacted with.
|
|
92
|
-
|
|
93
|
-
```tsx
|
|
94
|
-
<RadioList items={defaultItems} defaultValue="option1" disabled />
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Horizontal Layout
|
|
98
|
-
|
|
99
|
-
Set `orientation="horizontal"` to display options in a row.
|
|
100
|
-
|
|
101
|
-
```tsx
|
|
102
|
-
<RadioList items={defaultItems} defaultValue="option1" orientation="horizontal" />
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
<RadioList
|
|
107
|
-
items={items}
|
|
108
|
-
defaultValue="option1"
|
|
109
|
-
orientation="horizontal"
|
|
110
|
-
/>
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Sizes
|
|
114
|
-
|
|
115
|
-
RadioList supports `sm`, `md` (default), and `lg` sizes. The size is applied to all radio buttons in the group.
|
|
116
|
-
|
|
117
|
-
```tsx
|
|
118
|
-
<Stack gap={3}>
|
|
119
|
-
<Box>
|
|
120
|
-
<Typography level="body-sm" sx={{
|
|
121
|
-
mb: 1
|
|
122
|
-
}}>Small</Typography>
|
|
123
|
-
<RadioList items={defaultItems} defaultValue="option1" size="sm" />
|
|
124
|
-
</Box>
|
|
125
|
-
<Box>
|
|
126
|
-
<Typography level="body-sm" sx={{
|
|
127
|
-
mb: 1
|
|
128
|
-
}}>Medium</Typography>
|
|
129
|
-
<RadioList items={defaultItems} defaultValue="option1" size="md" />
|
|
130
|
-
</Box>
|
|
131
|
-
<Box>
|
|
132
|
-
<Typography level="body-sm" sx={{
|
|
133
|
-
mb: 1
|
|
134
|
-
}}>Large</Typography>
|
|
135
|
-
<RadioList items={defaultItems} defaultValue="option1" size="lg" />
|
|
136
|
-
</Box>
|
|
137
|
-
</Stack>
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Colors
|
|
141
|
-
|
|
142
|
-
Five semantic colors are available via the `color` prop.
|
|
143
|
-
|
|
144
|
-
```tsx
|
|
145
|
-
<Stack gap={3}>
|
|
146
|
-
<RadioList items={defaultItems} defaultValue="option1" color="primary" />
|
|
147
|
-
<RadioList items={defaultItems} defaultValue="option1" color="neutral" />
|
|
148
|
-
<RadioList items={defaultItems} defaultValue="option1" color="danger" />
|
|
149
|
-
<RadioList items={defaultItems} defaultValue="option1" color="success" />
|
|
150
|
-
<RadioList items={defaultItems} defaultValue="option1" color="warning" />
|
|
151
|
-
</Stack>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Common Use Cases
|
|
155
|
-
|
|
156
|
-
### Settings Selection
|
|
157
|
-
|
|
158
|
-
```tsx
|
|
159
|
-
function LanguageSetting() {
|
|
160
|
-
const [language, setLanguage] = React.useState('en');
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<FormControl>
|
|
164
|
-
<FormLabel>Language</FormLabel>
|
|
165
|
-
<RadioList
|
|
166
|
-
items={[
|
|
167
|
-
{ label: 'English', value: 'en' },
|
|
168
|
-
{ label: '한국어', value: 'ko' },
|
|
169
|
-
{ label: '日本語', value: 'ja' },
|
|
170
|
-
]}
|
|
171
|
-
value={language}
|
|
172
|
-
onChange={(e) => setLanguage((e.target as HTMLInputElement).value)}
|
|
173
|
-
/>
|
|
174
|
-
</FormControl>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
### Survey Options
|
|
180
|
-
|
|
181
|
-
```tsx
|
|
182
|
-
function SatisfactionSurvey() {
|
|
183
|
-
return (
|
|
184
|
-
<FormControl>
|
|
185
|
-
<FormLabel>How satisfied are you?</FormLabel>
|
|
186
|
-
<RadioList
|
|
187
|
-
orientation="horizontal"
|
|
188
|
-
items={[
|
|
189
|
-
{ label: 'Very Unsatisfied', value: '1' },
|
|
190
|
-
{ label: 'Unsatisfied', value: '2' },
|
|
191
|
-
{ label: 'Neutral', value: '3' },
|
|
192
|
-
{ label: 'Satisfied', value: '4' },
|
|
193
|
-
{ label: 'Very Satisfied', value: '5' },
|
|
194
|
-
]}
|
|
195
|
-
/>
|
|
196
|
-
</FormControl>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### Dynamic Options from API
|
|
202
|
-
|
|
203
|
-
```tsx
|
|
204
|
-
function RoleSelector({ roles }: { roles: { id: string; name: string }[] }) {
|
|
205
|
-
return (
|
|
206
|
-
<RadioList
|
|
207
|
-
items={roles.map((role) => ({
|
|
208
|
-
label: role.name,
|
|
209
|
-
value: role.id,
|
|
210
|
-
}))}
|
|
211
|
-
/>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
## Best Practices
|
|
217
|
-
|
|
218
|
-
1. **Use for mutually exclusive choices**: RadioList is for selecting exactly one option from a set. For multiple selections, use Checkbox or FilterableCheckboxGroup.
|
|
219
|
-
|
|
220
|
-
```tsx
|
|
221
|
-
// ✅ Mutually exclusive — only one role allowed
|
|
222
|
-
<RadioList items={roles} />
|
|
223
|
-
|
|
224
|
-
// ❌ Multiple selections needed — use Checkbox instead
|
|
225
|
-
<RadioList items={permissions} />
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
2. **Provide a default value**: Pre-select the most common or recommended option to reduce user effort.
|
|
229
|
-
|
|
230
|
-
3. **Keep labels concise**: Radio button labels should be short and scannable. Use descriptions elsewhere if more context is needed.
|
|
231
|
-
|
|
232
|
-
4. **Limit visible options**: For more than 7 options, consider using a Select dropdown instead to save space.
|
|
233
|
-
|
|
234
|
-
5. **Use horizontal layout sparingly**: Horizontal orientation works well for 2–4 short options. For longer lists, vertical is more readable.
|
|
235
|
-
|
|
236
|
-
## Accessibility
|
|
237
|
-
|
|
238
|
-
- RadioList renders a `<RadioGroup>` with `role="radiogroup"`, and each option is a `<Radio>` with `role="radio"`.
|
|
239
|
-
- Keyboard navigation: Arrow keys move between options, Space selects the focused option.
|
|
240
|
-
- Wrap in a FormControl with FormLabel to provide an accessible group label.
|
|
241
|
-
- The `disabled` prop sets `aria-disabled` on all radio buttons in the group.
|