@ceed/cds 1.22.2 → 1.22.4
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/data-display/InfoSign.md +74 -91
- package/dist/components/data-display/Typography.md +363 -63
- package/dist/components/feedback/CircularProgress.md +257 -0
- package/dist/components/feedback/Dialog.md +8 -4
- package/dist/components/feedback/Modal.md +7 -3
- package/dist/components/feedback/Skeleton.md +280 -0
- package/dist/components/feedback/llms.txt +2 -0
- package/dist/components/inputs/ButtonGroup.md +115 -104
- package/dist/components/inputs/CurrencyInput.md +181 -8
- package/dist/components/inputs/DatePicker.md +108 -436
- package/dist/components/inputs/DateRangePicker.md +130 -496
- package/dist/components/inputs/FilterableCheckboxGroup.md +141 -20
- package/dist/components/inputs/FormControl.md +368 -0
- package/dist/components/inputs/IconButton.md +137 -88
- package/dist/components/inputs/Input.md +203 -77
- package/dist/components/inputs/MonthPicker.md +95 -427
- package/dist/components/inputs/MonthRangePicker.md +89 -471
- package/dist/components/inputs/PercentageInput.md +183 -19
- package/dist/components/inputs/RadioButton.md +163 -35
- package/dist/components/inputs/RadioList.md +241 -0
- package/dist/components/inputs/RadioTileGroup.md +146 -62
- package/dist/components/inputs/Select.md +219 -328
- package/dist/components/inputs/Slider.md +334 -0
- package/dist/components/inputs/Switch.md +143 -376
- package/dist/components/inputs/Textarea.md +209 -11
- package/dist/components/inputs/Uploader/Uploader.md +145 -66
- package/dist/components/inputs/llms.txt +3 -0
- package/dist/components/navigation/Breadcrumbs.md +57 -308
- package/dist/components/navigation/Drawer.md +180 -0
- package/dist/components/navigation/Dropdown.md +98 -215
- package/dist/components/navigation/IconMenuButton.md +40 -502
- package/dist/components/navigation/InsetDrawer.md +281 -650
- package/dist/components/navigation/Link.md +31 -348
- package/dist/components/navigation/Menu.md +92 -285
- package/dist/components/navigation/MenuButton.md +55 -448
- package/dist/components/navigation/Pagination.md +47 -338
- package/dist/components/navigation/Stepper.md +160 -28
- package/dist/components/navigation/Tabs.md +57 -316
- package/dist/components/surfaces/Accordions.md +49 -804
- package/dist/components/surfaces/Card.md +97 -157
- package/dist/components/surfaces/Divider.md +83 -234
- package/dist/components/surfaces/Sheet.md +152 -327
- package/dist/guides/ThemeProvider.md +89 -0
- package/dist/guides/llms.txt +9 -0
- package/dist/llms.txt +8 -0
- package/package.json +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
# Input
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Introduction
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
> Form을 구성할 때 Typography로 별도의 label이나 helperText를 만드는 대신, 컴포넌트의 내장 prop을 사용하세요.
|
|
5
|
+
The Input component is a fundamental form element for capturing text input from users. It supports various visual styles, sizes, and states to accommodate different use cases across forms, search fields, and data entry interfaces.
|
|
6
|
+
|
|
7
|
+
Input comes with built-in form integration features such as labels, helper text, error states, and clearable functionality. It also provides specialized behavior for password fields with an automatic visibility toggle.
|
|
9
8
|
|
|
10
9
|
```tsx
|
|
11
10
|
<Input />
|
|
@@ -34,17 +33,52 @@ Input 컴포넌트는 사용자로부터 텍스트 입력을 받기 위한 기
|
|
|
34
33
|
| sx | — | — |
|
|
35
34
|
| className | — | — |
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
> **Use built-in form props**
|
|
37
|
+
>
|
|
38
|
+
> This component natively supports `label`, `helperText`, `error`, and `required` props.
|
|
39
|
+
> When building forms, use these built-in props instead of manually composing labels and helper text with Typography or FormControl.
|
|
40
|
+
>
|
|
41
|
+
> ```tsx
|
|
42
|
+
> // Recommended: use built-in props
|
|
43
|
+
> <Input label="Email" helperText="We'll never share your email." error={!isValid} />
|
|
44
|
+
>
|
|
45
|
+
> // Not recommended: manual composition with Typography
|
|
46
|
+
> <FormControl>
|
|
47
|
+
> <Typography component="label">Email</Typography>
|
|
48
|
+
> <Input />
|
|
49
|
+
> <Typography level="body-xs">We'll never share your email.</Typography>
|
|
50
|
+
> </FormControl>
|
|
51
|
+
> ```
|
|
38
52
|
|
|
39
|
-
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Input } from '@ceed/cds';
|
|
57
|
+
|
|
58
|
+
function MyComponent() {
|
|
59
|
+
return (
|
|
60
|
+
<Input
|
|
61
|
+
label="Username"
|
|
62
|
+
placeholder="Enter your username"
|
|
63
|
+
helperText="Must be at least 3 characters"
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
### Basic Input
|
|
72
|
+
|
|
73
|
+
The default Input renders a single-line text field. Without any additional props, it uses the `outlined` variant at `md` size.
|
|
40
74
|
|
|
41
75
|
```tsx
|
|
42
76
|
<Input />
|
|
43
77
|
```
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
### Variants
|
|
46
80
|
|
|
47
|
-
Input
|
|
81
|
+
Input supports four visual variants: `solid`, `soft`, `outlined`, and `plain`. Use `outlined` (default) for most form contexts, and `soft` or `plain` for inline or subtle placements.
|
|
48
82
|
|
|
49
83
|
```tsx
|
|
50
84
|
<>
|
|
@@ -55,9 +89,9 @@ Input은 네 가지 변형을 지원합니다: `solid`, `soft`, `outlined`, `pla
|
|
|
55
89
|
</>
|
|
56
90
|
```
|
|
57
91
|
|
|
58
|
-
|
|
92
|
+
### Sizes
|
|
59
93
|
|
|
60
|
-
Input
|
|
94
|
+
Input comes in three sizes: `sm`, `md`, and `lg`. Choose a size that fits the surrounding UI density.
|
|
61
95
|
|
|
62
96
|
```tsx
|
|
63
97
|
<>
|
|
@@ -67,13 +101,11 @@ Input은 세 가지 크기를 지원합니다: `sm`, `md`, `lg`
|
|
|
67
101
|
</>
|
|
68
102
|
```
|
|
69
103
|
|
|
70
|
-
##
|
|
104
|
+
## Label and Helper Text
|
|
71
105
|
|
|
72
|
-
|
|
106
|
+
### Label
|
|
73
107
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`label` 속성을 사용하여 Input 위에 레이블을 표시할 수 있습니다.
|
|
108
|
+
Use the `label` prop to display a label above the Input. This is the recommended way to associate a label with the input field.
|
|
77
109
|
|
|
78
110
|
```tsx
|
|
79
111
|
<>
|
|
@@ -81,9 +113,9 @@ Input 컴포넌트에 `label`과 `helperText` 속성을 추가하여 사용자
|
|
|
81
113
|
</>
|
|
82
114
|
```
|
|
83
115
|
|
|
84
|
-
###
|
|
116
|
+
### Helper Text
|
|
85
117
|
|
|
86
|
-
`helperText`
|
|
118
|
+
Use the `helperText` prop to provide additional guidance below the Input.
|
|
87
119
|
|
|
88
120
|
```tsx
|
|
89
121
|
<>
|
|
@@ -91,19 +123,19 @@ Input 컴포넌트에 `label`과 `helperText` 속성을 추가하여 사용자
|
|
|
91
123
|
</>
|
|
92
124
|
```
|
|
93
125
|
|
|
94
|
-
##
|
|
126
|
+
## States
|
|
95
127
|
|
|
96
|
-
###
|
|
128
|
+
### Disabled
|
|
97
129
|
|
|
98
|
-
`disabled`
|
|
130
|
+
Set `disabled` to prevent user interaction. Disabled inputs are visually dimmed and do not receive focus.
|
|
99
131
|
|
|
100
132
|
```tsx
|
|
101
133
|
<Input disabled />
|
|
102
134
|
```
|
|
103
135
|
|
|
104
|
-
###
|
|
136
|
+
### Error
|
|
105
137
|
|
|
106
|
-
`error`
|
|
138
|
+
Set `error` to indicate a validation failure. Combine with `helperText` to explain the error.
|
|
107
139
|
|
|
108
140
|
```tsx
|
|
109
141
|
<>
|
|
@@ -111,9 +143,9 @@ Input 컴포넌트에 `label`과 `helperText` 속성을 추가하여 사용자
|
|
|
111
143
|
</>
|
|
112
144
|
```
|
|
113
145
|
|
|
114
|
-
###
|
|
146
|
+
### Required
|
|
115
147
|
|
|
116
|
-
`required`
|
|
148
|
+
Set `required` to mark the field as mandatory. This adds a visual indicator to the label.
|
|
117
149
|
|
|
118
150
|
```tsx
|
|
119
151
|
<Input
|
|
@@ -124,9 +156,20 @@ Input 컴포넌트에 `label`과 `helperText` 속성을 추가하여 사용자
|
|
|
124
156
|
/>
|
|
125
157
|
```
|
|
126
158
|
|
|
127
|
-
##
|
|
159
|
+
## Form Control
|
|
160
|
+
|
|
161
|
+
Combine `label`, `helperText`, and `error` props to build a complete form control. This is the recommended pattern for form fields.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
<>
|
|
165
|
+
<Input placeholder="Type in here..." helperText="I'm helper text" label="Label" />
|
|
166
|
+
<Input placeholder="Invalid input" helperText="I'm helper text" label="Label" error />
|
|
167
|
+
</>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Decorators
|
|
128
171
|
|
|
129
|
-
|
|
172
|
+
Use `startDecorator` and `endDecorator` to place icons, buttons, or other elements at the start and end of the input field.
|
|
130
173
|
|
|
131
174
|
```tsx
|
|
132
175
|
<Stack spacing={3}>
|
|
@@ -166,7 +209,7 @@ width: 300
|
|
|
166
209
|
</Stack>
|
|
167
210
|
```
|
|
168
211
|
|
|
169
|
-
`endDecorator
|
|
212
|
+
When using `endDecorator` together with `enableClearable`, the clear button is placed before the end decorator:
|
|
170
213
|
|
|
171
214
|
```tsx
|
|
172
215
|
<Input
|
|
@@ -177,9 +220,9 @@ width: 300
|
|
|
177
220
|
/>
|
|
178
221
|
```
|
|
179
222
|
|
|
180
|
-
##
|
|
223
|
+
## Clearable Input
|
|
181
224
|
|
|
182
|
-
`enableClearable`
|
|
225
|
+
Set `enableClearable` to show a clear button when the input has a value. Clicking the button clears the input and returns focus to the field.
|
|
183
226
|
|
|
184
227
|
```tsx
|
|
185
228
|
<>
|
|
@@ -187,9 +230,9 @@ width: 300
|
|
|
187
230
|
</>
|
|
188
231
|
```
|
|
189
232
|
|
|
190
|
-
##
|
|
233
|
+
## Password Input
|
|
191
234
|
|
|
192
|
-
`type="password"`
|
|
235
|
+
Setting `type="password"` automatically adds a visibility toggle button, allowing users to reveal or hide their password.
|
|
193
236
|
|
|
194
237
|
```tsx
|
|
195
238
|
<Stack spacing={3}>
|
|
@@ -204,26 +247,9 @@ width: 300
|
|
|
204
247
|
</Stack>
|
|
205
248
|
```
|
|
206
249
|
|
|
207
|
-
###
|
|
250
|
+
### Password Limitations
|
|
208
251
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
```tsx
|
|
212
|
-
<Stack spacing={3}>
|
|
213
|
-
<Typography level="body-md">Default password input with toggle button:</Typography>
|
|
214
|
-
<Input {...args} placeholder="Enter password" type="password" label="Password" />
|
|
215
|
-
|
|
216
|
-
<Typography level="body-md">Disabled password input:</Typography>
|
|
217
|
-
<Input {...args} placeholder="Enter password" type="password" label="Disabled Password" disabled />
|
|
218
|
-
|
|
219
|
-
<Typography level="body-md">Password input with toggle button disabled:</Typography>
|
|
220
|
-
<Input {...args} placeholder="Enter password" type="password" label="No Toggle" disableTogglePasswordButton />
|
|
221
|
-
</Stack>
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### 비밀번호 입력의 제한 사항
|
|
225
|
-
|
|
226
|
-
비밀번호 입력 필드(`type="password"`)에서는 `endDecorator`를 사용할 수 없습니다. 이는 비밀번호 토글 버튼이 해당 위치를 차지하기 때문입니다.
|
|
252
|
+
When `type="password"` is used, the `endDecorator` prop is not supported because the password toggle button occupies that position.
|
|
227
253
|
|
|
228
254
|
```tsx
|
|
229
255
|
<Stack spacing={3}>
|
|
@@ -235,54 +261,154 @@ width: 300
|
|
|
235
261
|
</Stack>
|
|
236
262
|
```
|
|
237
263
|
|
|
238
|
-
##
|
|
264
|
+
## State Management
|
|
265
|
+
|
|
266
|
+
### Controlled Component
|
|
239
267
|
|
|
240
|
-
|
|
268
|
+
Use `value` and `onChange` to manage the input state externally. This is useful when you need to synchronize the value with other components or perform validation on change.
|
|
241
269
|
|
|
242
270
|
```tsx
|
|
243
271
|
<>
|
|
244
|
-
<Input placeholder="Type in here
|
|
245
|
-
<Input placeholder="Invalid input" helperText="I'm helper text" label="Label" error />
|
|
272
|
+
<Input placeholder="Type in here…" label="Label" enableClearable value={value} onChange={handleChange} />
|
|
246
273
|
</>
|
|
247
274
|
```
|
|
248
275
|
|
|
249
|
-
|
|
276
|
+
### Uncontrolled Component
|
|
277
|
+
|
|
278
|
+
Use `defaultValue` for simpler cases where you do not need to track the value in state. The input manages its own value internally.
|
|
250
279
|
|
|
251
|
-
|
|
280
|
+
```tsx
|
|
281
|
+
<Input defaultValue="Initial text" placeholder="Type in here..." />
|
|
282
|
+
```
|
|
252
283
|
|
|
253
|
-
|
|
284
|
+
## Common Use Cases
|
|
285
|
+
|
|
286
|
+
### Login Form
|
|
254
287
|
|
|
255
288
|
```tsx
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
289
|
+
function LoginForm() {
|
|
290
|
+
const [email, setEmail] = useState('');
|
|
291
|
+
const [password, setPassword] = useState('');
|
|
292
|
+
|
|
293
|
+
return (
|
|
294
|
+
<Stack spacing={2}>
|
|
295
|
+
<Input
|
|
296
|
+
label="Email"
|
|
297
|
+
type="email"
|
|
298
|
+
placeholder="you@example.com"
|
|
299
|
+
required
|
|
300
|
+
value={email}
|
|
301
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
302
|
+
/>
|
|
303
|
+
<Input
|
|
304
|
+
label="Password"
|
|
305
|
+
type="password"
|
|
306
|
+
placeholder="Enter your password"
|
|
307
|
+
required
|
|
308
|
+
value={password}
|
|
309
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
310
|
+
/>
|
|
311
|
+
<Button type="submit">Sign In</Button>
|
|
312
|
+
</Stack>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
259
315
|
```
|
|
260
316
|
|
|
261
|
-
###
|
|
317
|
+
### Search Field with Clear
|
|
262
318
|
|
|
263
|
-
|
|
319
|
+
```tsx
|
|
320
|
+
function SearchField({ onSearch }) {
|
|
321
|
+
const [query, setQuery] = useState('');
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<Input
|
|
325
|
+
placeholder="Search..."
|
|
326
|
+
startDecorator={<SearchIcon />}
|
|
327
|
+
enableClearable
|
|
328
|
+
value={query}
|
|
329
|
+
onChange={(e) => {
|
|
330
|
+
setQuery(e.target.value);
|
|
331
|
+
onSearch(e.target.value);
|
|
332
|
+
}}
|
|
333
|
+
/>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
```
|
|
264
337
|
|
|
265
|
-
|
|
338
|
+
### Form with Validation
|
|
266
339
|
|
|
267
|
-
|
|
340
|
+
```tsx
|
|
341
|
+
function ProfileForm() {
|
|
342
|
+
const [name, setName] = useState('');
|
|
343
|
+
const [submitted, setSubmitted] = useState(false);
|
|
344
|
+
const hasError = submitted && name.trim().length === 0;
|
|
345
|
+
|
|
346
|
+
return (
|
|
347
|
+
<Stack spacing={2}>
|
|
348
|
+
<Input
|
|
349
|
+
label="Full Name"
|
|
350
|
+
required
|
|
351
|
+
placeholder="John Doe"
|
|
352
|
+
value={name}
|
|
353
|
+
onChange={(e) => setName(e.target.value)}
|
|
354
|
+
error={hasError}
|
|
355
|
+
helperText={hasError ? 'Name is required' : 'Enter your legal name'}
|
|
356
|
+
/>
|
|
357
|
+
<Button onClick={() => setSubmitted(true)}>Save</Button>
|
|
358
|
+
</Stack>
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
```
|
|
268
362
|
|
|
269
|
-
|
|
270
|
-
- 키보드 탐색이 가능합니다.
|
|
271
|
-
- 오류 상태는 시각적으로 명확하게 표시됩니다.
|
|
363
|
+
## Best Practices
|
|
272
364
|
|
|
273
|
-
|
|
365
|
+
1. **Always provide a label**: Every input should have a visible label so users understand what to enter.
|
|
274
366
|
|
|
275
|
-
|
|
367
|
+
```tsx
|
|
368
|
+
// ✅ Good: clear label
|
|
369
|
+
<Input label="Email address" placeholder="you@example.com" />
|
|
370
|
+
|
|
371
|
+
// ❌ Bad: placeholder only, no label
|
|
372
|
+
<Input placeholder="Email address" />
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
2. **Use helper text for guidance, error text for problems**: Provide contextual help via `helperText`, and switch to error messaging when validation fails.
|
|
376
|
+
|
|
377
|
+
```tsx
|
|
378
|
+
// ✅ Good: helpful context + error state
|
|
379
|
+
<Input
|
|
380
|
+
label="Password"
|
|
381
|
+
type="password"
|
|
382
|
+
helperText={hasError ? 'Must be at least 8 characters' : 'Choose a strong password'}
|
|
383
|
+
error={hasError}
|
|
384
|
+
/>
|
|
276
385
|
|
|
277
|
-
|
|
278
|
-
|
|
386
|
+
// ❌ Bad: no guidance at all
|
|
387
|
+
<Input label="Password" type="password" />
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
3. **Choose the right input type**: Use `type` to match the expected data (e.g., `email`, `tel`, `password`, `number`). This enables appropriate browser behavior and mobile keyboards.
|
|
279
391
|
|
|
280
392
|
```tsx
|
|
281
|
-
//
|
|
282
|
-
|
|
393
|
+
// ✅ Good: appropriate type for email
|
|
394
|
+
<Input label="Email" type="email" />
|
|
395
|
+
|
|
396
|
+
// ❌ Bad: generic text type for email
|
|
397
|
+
<Input label="Email" type="text" />
|
|
283
398
|
```
|
|
284
399
|
|
|
285
|
-
|
|
400
|
+
4. **Use `enableClearable` for search and filter inputs**: Allow users to quickly reset their input in search and filter contexts.
|
|
401
|
+
|
|
402
|
+
5. **Use built-in form props instead of manual composition**: Prefer `label`, `helperText`, `error`, and `required` props over wrapping with FormControl and Typography. This ensures consistent spacing, accessibility, and error handling.
|
|
286
403
|
|
|
287
|
-
|
|
288
|
-
|
|
404
|
+
## Accessibility
|
|
405
|
+
|
|
406
|
+
- **Label association**: The `label` prop automatically creates a properly associated `<label>` element. If you cannot use the `label` prop, provide an `aria-label` or `aria-labelledby` attribute.
|
|
407
|
+
- **Error announcement**: When `error` is set, the error state is conveyed to assistive technologies via `aria-invalid`. Combine with descriptive `helperText` so screen readers can announce the error message.
|
|
408
|
+
- **Keyboard interaction**: Input supports standard keyboard behavior. The clear button and password toggle are focusable and can be activated with Enter or Space.
|
|
409
|
+
- **Testing note**: When using Testing Library, find a `type="password"` input using the `textbox` role, as ARIA does not define a separate `password` role.
|
|
410
|
+
|
|
411
|
+
```tsx
|
|
412
|
+
// Finding a password input in tests
|
|
413
|
+
const passwordInput = screen.getByRole('textbox', { name: /password/i });
|
|
414
|
+
```
|