@ceed/cds 1.22.3 → 1.22.5
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/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 +361 -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
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
ButtonGroup
|
|
5
|
+
ButtonGroup is a layout component that visually and semantically groups related buttons into a single cohesive unit. It automatically handles border merging, spacing, and consistent styling across all child buttons, making it ideal for toolbars, action sets, and segmented controls.
|
|
6
|
+
|
|
7
|
+
By applying shared props like `color`, `variant`, `size`, and `orientation` at the group level, you ensure visual consistency without having to repeat props on every individual button. ButtonGroup is built on top of Joy UI's ButtonGroup and inherits all of its capabilities.
|
|
6
8
|
|
|
7
9
|
```tsx
|
|
8
10
|
<ButtonGroup {...args}>
|
|
@@ -28,37 +30,17 @@ import { ButtonGroup, Button } from '@ceed/cds';
|
|
|
28
30
|
function MyComponent() {
|
|
29
31
|
return (
|
|
30
32
|
<ButtonGroup>
|
|
31
|
-
<Button
|
|
32
|
-
<Button
|
|
33
|
-
<Button
|
|
33
|
+
<Button>First</Button>
|
|
34
|
+
<Button>Second</Button>
|
|
35
|
+
<Button>Third</Button>
|
|
34
36
|
</ButtonGroup>
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
```
|
|
38
40
|
|
|
39
|
-
##
|
|
40
|
-
|
|
41
|
-
### Basic Usage
|
|
42
|
-
|
|
43
|
-
기본적인 ButtonGroup 사용법입니다.
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
<div style={{
|
|
47
|
-
display: 'flex',
|
|
48
|
-
gap: '2rem',
|
|
49
|
-
flexDirection: 'column'
|
|
50
|
-
}}>
|
|
51
|
-
<ButtonGroup>
|
|
52
|
-
<Button>첫번째</Button>
|
|
53
|
-
<Button>두번째</Button>
|
|
54
|
-
<Button>세번째</Button>
|
|
55
|
-
</ButtonGroup>
|
|
56
|
-
</div>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Colors
|
|
41
|
+
## Colors
|
|
60
42
|
|
|
61
|
-
|
|
43
|
+
Apply a unified color theme to all buttons in the group using the `color` prop. Available colors are `primary`, `neutral`, `danger`, `success`, and `warning`.
|
|
62
44
|
|
|
63
45
|
```tsx
|
|
64
46
|
<div style={{
|
|
@@ -98,9 +80,9 @@ function MyComponent() {
|
|
|
98
80
|
</div>
|
|
99
81
|
```
|
|
100
82
|
|
|
101
|
-
|
|
83
|
+
## Variants
|
|
102
84
|
|
|
103
|
-
|
|
85
|
+
ButtonGroup supports four visual variants: `solid`, `soft`, `outlined`, and `plain`. The variant prop propagates to all child buttons, ensuring a consistent look.
|
|
104
86
|
|
|
105
87
|
```tsx
|
|
106
88
|
<div style={{
|
|
@@ -134,9 +116,9 @@ function MyComponent() {
|
|
|
134
116
|
</div>
|
|
135
117
|
```
|
|
136
118
|
|
|
137
|
-
|
|
119
|
+
## Sizes
|
|
138
120
|
|
|
139
|
-
|
|
121
|
+
Control the size of all buttons in the group with the `size` prop. Available sizes are `sm`, `md` (default), and `lg`.
|
|
140
122
|
|
|
141
123
|
```tsx
|
|
142
124
|
<div style={{
|
|
@@ -165,9 +147,9 @@ function MyComponent() {
|
|
|
165
147
|
</div>
|
|
166
148
|
```
|
|
167
149
|
|
|
168
|
-
|
|
150
|
+
## Orientations
|
|
169
151
|
|
|
170
|
-
|
|
152
|
+
Buttons can be arranged horizontally (default) or vertically. Use `orientation="vertical"` for stacked layouts such as side panels or narrow containers.
|
|
171
153
|
|
|
172
154
|
```tsx
|
|
173
155
|
<div style={{
|
|
@@ -195,9 +177,9 @@ function MyComponent() {
|
|
|
195
177
|
</div>
|
|
196
178
|
```
|
|
197
179
|
|
|
198
|
-
|
|
180
|
+
## With Icons
|
|
199
181
|
|
|
200
|
-
|
|
182
|
+
Combine text labels with icons using the `startDecorator` prop on individual buttons for a richer, more descriptive interface.
|
|
201
183
|
|
|
202
184
|
```tsx
|
|
203
185
|
<div style={{
|
|
@@ -219,49 +201,9 @@ function MyComponent() {
|
|
|
219
201
|
</div>
|
|
220
202
|
```
|
|
221
203
|
|
|
222
|
-
|
|
204
|
+
## States
|
|
223
205
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
```tsx
|
|
227
|
-
<div style={{
|
|
228
|
-
display: 'flex',
|
|
229
|
-
gap: '2rem',
|
|
230
|
-
flexDirection: 'column'
|
|
231
|
-
}}>
|
|
232
|
-
<div>
|
|
233
|
-
<h4>File Actions</h4>
|
|
234
|
-
<ButtonGroup variant="outlined">
|
|
235
|
-
<Button onClick={() => alert('Save')}>저장</Button>
|
|
236
|
-
<Button onClick={() => alert('Save As')}>다른 이름으로 저장</Button>
|
|
237
|
-
<Button onClick={() => alert('Export')}>내보내기</Button>
|
|
238
|
-
</ButtonGroup>
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
<div>
|
|
242
|
-
<h4>Text Formatting</h4>
|
|
243
|
-
<ButtonGroup size="sm" variant="soft">
|
|
244
|
-
<Button>B</Button>
|
|
245
|
-
<Button>I</Button>
|
|
246
|
-
<Button>U</Button>
|
|
247
|
-
<Button>S</Button>
|
|
248
|
-
</ButtonGroup>
|
|
249
|
-
</div>
|
|
250
|
-
|
|
251
|
-
<div>
|
|
252
|
-
<h4>View Options</h4>
|
|
253
|
-
<ButtonGroup color="neutral" variant="outlined">
|
|
254
|
-
<Button>목록</Button>
|
|
255
|
-
<Button>격자</Button>
|
|
256
|
-
<Button>타일</Button>
|
|
257
|
-
</ButtonGroup>
|
|
258
|
-
</div>
|
|
259
|
-
</div>
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
### States
|
|
263
|
-
|
|
264
|
-
다양한 상태를 표현할 수 있습니다.
|
|
206
|
+
ButtonGroup supports disabled states at the group level (affecting all children) or on individual buttons for mixed-state scenarios.
|
|
265
207
|
|
|
266
208
|
```tsx
|
|
267
209
|
<div style={{
|
|
@@ -298,9 +240,9 @@ function MyComponent() {
|
|
|
298
240
|
</div>
|
|
299
241
|
```
|
|
300
242
|
|
|
301
|
-
|
|
243
|
+
## Toggle Group
|
|
302
244
|
|
|
303
|
-
|
|
245
|
+
By dynamically switching the `variant` prop on individual buttons based on selection state, you can create a segmented toggle control for exclusive selection patterns.
|
|
304
246
|
|
|
305
247
|
```tsx
|
|
306
248
|
<div>
|
|
@@ -325,56 +267,125 @@ function MyComponent() {
|
|
|
325
267
|
### Toolbar Actions
|
|
326
268
|
|
|
327
269
|
```tsx
|
|
270
|
+
import { ButtonGroup, Button } from '@ceed/cds';
|
|
271
|
+
import SaveIcon from '@mui/icons-material/Save';
|
|
272
|
+
import UndoIcon from '@mui/icons-material/Undo';
|
|
273
|
+
import RedoIcon from '@mui/icons-material/Redo';
|
|
274
|
+
|
|
328
275
|
<ButtonGroup variant="outlined">
|
|
329
|
-
<Button startDecorator={<SaveIcon />}
|
|
330
|
-
<Button startDecorator={<UndoIcon />}
|
|
331
|
-
<Button startDecorator={<RedoIcon />}
|
|
276
|
+
<Button startDecorator={<SaveIcon />}>Save</Button>
|
|
277
|
+
<Button startDecorator={<UndoIcon />}>Undo</Button>
|
|
278
|
+
<Button startDecorator={<RedoIcon />}>Redo</Button>
|
|
332
279
|
</ButtonGroup>
|
|
333
280
|
```
|
|
334
281
|
|
|
335
|
-
###
|
|
282
|
+
### View Switcher
|
|
336
283
|
|
|
337
284
|
```tsx
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
<Button
|
|
285
|
+
const [view, setView] = useState('list');
|
|
286
|
+
|
|
287
|
+
<ButtonGroup variant="outlined" color="neutral">
|
|
288
|
+
<Button
|
|
289
|
+
variant={view === 'list' ? 'solid' : 'outlined'}
|
|
290
|
+
onClick={() => setView('list')}
|
|
291
|
+
>
|
|
292
|
+
List
|
|
293
|
+
</Button>
|
|
294
|
+
<Button
|
|
295
|
+
variant={view === 'grid' ? 'solid' : 'outlined'}
|
|
296
|
+
onClick={() => setView('grid')}
|
|
297
|
+
>
|
|
298
|
+
Grid
|
|
299
|
+
</Button>
|
|
300
|
+
<Button
|
|
301
|
+
variant={view === 'card' ? 'solid' : 'outlined'}
|
|
302
|
+
onClick={() => setView('card')}
|
|
303
|
+
>
|
|
304
|
+
Card
|
|
305
|
+
</Button>
|
|
342
306
|
</ButtonGroup>
|
|
343
307
|
```
|
|
344
308
|
|
|
345
|
-
###
|
|
309
|
+
### Pagination Controls
|
|
346
310
|
|
|
347
311
|
```tsx
|
|
348
|
-
<ButtonGroup
|
|
349
|
-
<Button onClick={() =>
|
|
350
|
-
|
|
351
|
-
|
|
312
|
+
<ButtonGroup variant="outlined" size="sm">
|
|
313
|
+
<Button disabled={page === 1} onClick={() => setPage(page - 1)}>
|
|
314
|
+
Previous
|
|
315
|
+
</Button>
|
|
316
|
+
<Button disabled>{page}</Button>
|
|
317
|
+
<Button onClick={() => setPage(page + 1)}>
|
|
318
|
+
Next
|
|
319
|
+
</Button>
|
|
352
320
|
</ButtonGroup>
|
|
353
321
|
```
|
|
354
322
|
|
|
355
|
-
|
|
323
|
+
## Best Practices
|
|
324
|
+
|
|
325
|
+
1. **Group only related actions together.** Each ButtonGroup should represent a logically connected set of operations.
|
|
356
326
|
|
|
357
327
|
```tsx
|
|
328
|
+
// ✅ Related file operations grouped together
|
|
358
329
|
<ButtonGroup variant="outlined">
|
|
359
|
-
<Button
|
|
360
|
-
|
|
361
|
-
</Button>
|
|
362
|
-
|
|
330
|
+
<Button>Save</Button>
|
|
331
|
+
<Button>Save As</Button>
|
|
332
|
+
<Button>Export</Button>
|
|
333
|
+
</ButtonGroup>
|
|
334
|
+
|
|
335
|
+
// ❌ Unrelated actions mixed in one group
|
|
336
|
+
<ButtonGroup>
|
|
337
|
+
<Button>Save</Button>
|
|
338
|
+
<Button>Delete Account</Button>
|
|
339
|
+
<Button>Help</Button>
|
|
363
340
|
</ButtonGroup>
|
|
364
341
|
```
|
|
365
342
|
|
|
366
|
-
|
|
343
|
+
2. **Keep the button count between 2 and 5.** Too many buttons reduce clarity and overwhelm users.
|
|
367
344
|
|
|
368
|
-
|
|
345
|
+
```tsx
|
|
346
|
+
// ✅ Concise group
|
|
347
|
+
<ButtonGroup>
|
|
348
|
+
<Button>Bold</Button>
|
|
349
|
+
<Button>Italic</Button>
|
|
350
|
+
<Button>Underline</Button>
|
|
351
|
+
</ButtonGroup>
|
|
369
352
|
|
|
370
|
-
|
|
353
|
+
// ❌ Too many options in a single group
|
|
354
|
+
<ButtonGroup>
|
|
355
|
+
<Button>Bold</Button>
|
|
356
|
+
<Button>Italic</Button>
|
|
357
|
+
<Button>Underline</Button>
|
|
358
|
+
<Button>Strikethrough</Button>
|
|
359
|
+
<Button>Superscript</Button>
|
|
360
|
+
<Button>Subscript</Button>
|
|
361
|
+
<Button>Code</Button>
|
|
362
|
+
</ButtonGroup>
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
3. **Use consistent variant and color across the group.** Avoid overriding individual button styles unless implementing toggle selection.
|
|
366
|
+
|
|
367
|
+
```tsx
|
|
368
|
+
// ✅ Consistent styling via group props
|
|
369
|
+
<ButtonGroup variant="outlined" color="neutral">
|
|
370
|
+
<Button>A</Button>
|
|
371
|
+
<Button>B</Button>
|
|
372
|
+
</ButtonGroup>
|
|
371
373
|
|
|
372
|
-
|
|
374
|
+
// ❌ Mixed styles with no semantic reason
|
|
375
|
+
<ButtonGroup>
|
|
376
|
+
<Button variant="solid">A</Button>
|
|
377
|
+
<Button variant="outlined">B</Button>
|
|
378
|
+
<Button variant="plain">C</Button>
|
|
379
|
+
</ButtonGroup>
|
|
380
|
+
```
|
|
373
381
|
|
|
374
|
-
4.
|
|
382
|
+
4. **Clearly indicate the active state in toggle groups.** Use a distinct variant (e.g., `solid` vs `outlined`) so users can immediately see which option is selected.
|
|
375
383
|
|
|
376
|
-
5.
|
|
384
|
+
5. **Consider vertical orientation for narrow layouts.** On mobile or in sidebars, `orientation="vertical"` prevents horizontal overflow and improves usability.
|
|
377
385
|
|
|
378
|
-
|
|
386
|
+
## Accessibility
|
|
379
387
|
|
|
380
|
-
|
|
388
|
+
- **Keyboard navigation**: All buttons within the group are focusable and navigable using the `Tab` key. Each button is a standard focusable element that responds to `Enter` and `Space`.
|
|
389
|
+
- **ARIA grouping**: Wrap the ButtonGroup in a container with `role="group"` and an `aria-label` when the group represents a distinct set of controls (e.g., text formatting toolbar).
|
|
390
|
+
- **Disabled state**: When the entire group is disabled, all child buttons receive `aria-disabled="true"` automatically, preventing interaction and communicating the state to assistive technologies.
|
|
391
|
+
- **Toggle groups**: When using ButtonGroup as a toggle, consider adding `aria-pressed` to each button to communicate the selection state to screen readers.
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
CurrencyInput is a specialized numeric input for entering monetary values. It automatically formats numbers with the appropriate currency symbol, thousand separators, and decimal places based on the selected currency (USD or KRW). It supports features like maximum value validation, minor unit conversion, and controlled/uncontrolled modes.
|
|
6
|
+
|
|
7
|
+
> **Tip: Use built-in form props**
|
|
6
8
|
>
|
|
7
|
-
>
|
|
8
|
-
> Form을 구성할 때 Typography로 별도의 label이나 helperText를 만드는 대신, 컴포넌트의 내장 prop을 사용하세요.
|
|
9
|
+
> This component supports `label` and `helperText` props directly. Use these instead of wrapping with FormControl + FormLabel + FormHelperText for simpler forms.
|
|
9
10
|
|
|
10
11
|
```tsx
|
|
11
12
|
<CurrencyInput
|
|
@@ -30,8 +31,42 @@
|
|
|
30
31
|
| useMinorUnit | — | — |
|
|
31
32
|
| onChange | — | — |
|
|
32
33
|
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import { CurrencyInput } from '@ceed/cds';
|
|
38
|
+
|
|
39
|
+
function MyComponent() {
|
|
40
|
+
const [amount, setAmount] = React.useState(0);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<CurrencyInput
|
|
44
|
+
label="Price"
|
|
45
|
+
currency="USD"
|
|
46
|
+
value={amount}
|
|
47
|
+
onChange={(e) => setAmount(e.target.value)}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Currency Formats
|
|
54
|
+
|
|
55
|
+
### USD (Default)
|
|
56
|
+
|
|
57
|
+
US Dollar format with `$` symbol, comma thousand separators, and 2 decimal places.
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
<CurrencyInput
|
|
61
|
+
name="currency-input"
|
|
62
|
+
defaultValue={1000}
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
33
66
|
### KRW
|
|
34
67
|
|
|
68
|
+
Korean Won format with `₩` symbol, comma thousand separators, and no decimal places.
|
|
69
|
+
|
|
35
70
|
```tsx
|
|
36
71
|
<CurrencyInput
|
|
37
72
|
name="currency-input"
|
|
@@ -40,7 +75,13 @@
|
|
|
40
75
|
/>
|
|
41
76
|
```
|
|
42
77
|
|
|
43
|
-
|
|
78
|
+
```tsx
|
|
79
|
+
<CurrencyInput currency="KRW" value={50000} />
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Sizes
|
|
83
|
+
|
|
84
|
+
CurrencyInput supports three sizes: `sm`, `md` (default), and `lg`.
|
|
44
85
|
|
|
45
86
|
```tsx
|
|
46
87
|
<Stack gap={2}>
|
|
@@ -50,7 +91,9 @@
|
|
|
50
91
|
</Stack>
|
|
51
92
|
```
|
|
52
93
|
|
|
53
|
-
|
|
94
|
+
## Form Features
|
|
95
|
+
|
|
96
|
+
### With Label
|
|
54
97
|
|
|
55
98
|
```tsx
|
|
56
99
|
<CurrencyInput
|
|
@@ -60,7 +103,11 @@
|
|
|
60
103
|
/>
|
|
61
104
|
```
|
|
62
105
|
|
|
63
|
-
|
|
106
|
+
```tsx
|
|
107
|
+
<CurrencyInput label="Total Amount" />
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### With Helper Text
|
|
64
111
|
|
|
65
112
|
```tsx
|
|
66
113
|
<CurrencyInput
|
|
@@ -71,7 +118,11 @@
|
|
|
71
118
|
/>
|
|
72
119
|
```
|
|
73
120
|
|
|
74
|
-
|
|
121
|
+
```tsx
|
|
122
|
+
<CurrencyInput label="Price" helperText="Enter the item price in USD." />
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Error State
|
|
75
126
|
|
|
76
127
|
```tsx
|
|
77
128
|
<CurrencyInput
|
|
@@ -83,7 +134,13 @@
|
|
|
83
134
|
/>
|
|
84
135
|
```
|
|
85
136
|
|
|
86
|
-
|
|
137
|
+
```tsx
|
|
138
|
+
<CurrencyInput label="Amount" error helperText="Amount is required." />
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Price Limit
|
|
142
|
+
|
|
143
|
+
Set the `max` prop to enforce a maximum value. When the entered value exceeds the limit, the input automatically displays an error state with a formatted limit message.
|
|
87
144
|
|
|
88
145
|
```tsx
|
|
89
146
|
<CurrencyInput
|
|
@@ -94,3 +151,119 @@
|
|
|
94
151
|
max={1000000}
|
|
95
152
|
/>
|
|
96
153
|
```
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
<CurrencyInput
|
|
157
|
+
currency="USD"
|
|
158
|
+
max={1000000}
|
|
159
|
+
value={10000000}
|
|
160
|
+
/>
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Minor Unit Mode
|
|
164
|
+
|
|
165
|
+
When `useMinorUnit` is true, the component converts between display values and minor units (e.g., cents for USD). This is useful when your API stores amounts in the smallest currency unit.
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
// Display shows "$10.00", but onChange returns 1000 (cents)
|
|
169
|
+
<CurrencyInput currency="USD" useMinorUnit value={1000} />
|
|
170
|
+
|
|
171
|
+
// Display shows "₩10,000", onChange returns 10000 (no conversion for KRW)
|
|
172
|
+
<CurrencyInput currency="KRW" useMinorUnit value={10000} />
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Common Use Cases
|
|
176
|
+
|
|
177
|
+
### Product Price Editor
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
function ProductPriceEditor() {
|
|
181
|
+
const [priceUSD, setPriceUSD] = React.useState(0);
|
|
182
|
+
const [priceKRW, setPriceKRW] = React.useState(0);
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<Stack gap={2}>
|
|
186
|
+
<CurrencyInput
|
|
187
|
+
label="USD Price"
|
|
188
|
+
currency="USD"
|
|
189
|
+
value={priceUSD}
|
|
190
|
+
onChange={(e) => setPriceUSD(e.target.value)}
|
|
191
|
+
max={99999.99}
|
|
192
|
+
/>
|
|
193
|
+
<CurrencyInput
|
|
194
|
+
label="KRW Price"
|
|
195
|
+
currency="KRW"
|
|
196
|
+
value={priceKRW}
|
|
197
|
+
onChange={(e) => setPriceKRW(e.target.value)}
|
|
198
|
+
max={99999999}
|
|
199
|
+
/>
|
|
200
|
+
</Stack>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Invoice Line Item
|
|
206
|
+
|
|
207
|
+
```tsx
|
|
208
|
+
function InvoiceLineItem({ item, onChange }) {
|
|
209
|
+
return (
|
|
210
|
+
<Stack direction="row" gap={2} alignItems="flex-end">
|
|
211
|
+
<Input label="Description" value={item.description} />
|
|
212
|
+
<CurrencyInput
|
|
213
|
+
label="Unit Price"
|
|
214
|
+
currency="USD"
|
|
215
|
+
value={item.unitPrice}
|
|
216
|
+
onChange={(e) => onChange({ ...item, unitPrice: e.target.value })}
|
|
217
|
+
/>
|
|
218
|
+
<Input label="Qty" type="number" value={item.quantity} sx={{ width: 80 }} />
|
|
219
|
+
</Stack>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Budget Limit Input
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
function BudgetSetting() {
|
|
228
|
+
const [budget, setBudget] = React.useState(50000);
|
|
229
|
+
|
|
230
|
+
return (
|
|
231
|
+
<CurrencyInput
|
|
232
|
+
label="Monthly Budget"
|
|
233
|
+
helperText="Set the maximum monthly spending limit."
|
|
234
|
+
currency="USD"
|
|
235
|
+
value={budget}
|
|
236
|
+
onChange={(e) => setBudget(e.target.value)}
|
|
237
|
+
max={1000000}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Best Practices
|
|
244
|
+
|
|
245
|
+
1. **Choose the right currency**: Always set the `currency` prop explicitly. USD uses 2 decimal places while KRW uses none.
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
// ✅ Explicit currency
|
|
249
|
+
<CurrencyInput currency="USD" />
|
|
250
|
+
<CurrencyInput currency="KRW" />
|
|
251
|
+
|
|
252
|
+
// ❌ Relying on default — may confuse users expecting KRW
|
|
253
|
+
<CurrencyInput />
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
2. **Set max limits**: Use `max` to prevent unreasonable values. The component displays a helpful error message when the limit is exceeded.
|
|
257
|
+
|
|
258
|
+
3. **Use `useMinorUnit` for API integration**: When your backend stores amounts in minor units (cents, etc.), enable `useMinorUnit` to avoid manual conversion.
|
|
259
|
+
|
|
260
|
+
4. **Use built-in label and helperText**: Prefer the component's own `label` and `helperText` props over wrapping with FormControl.
|
|
261
|
+
|
|
262
|
+
5. **Handle negative values carefully**: CurrencyInput supports negative values. If negatives are not valid for your use case, validate in `onChange`.
|
|
263
|
+
|
|
264
|
+
## Accessibility
|
|
265
|
+
|
|
266
|
+
- The input has `role="textbox"` with proper labeling via the `label` prop.
|
|
267
|
+
- Error states are communicated via `aria-invalid` and associated error messages.
|
|
268
|
+
- The currency symbol serves as a visual indicator; ensure labels also mention the currency for screen readers.
|
|
269
|
+
- Keyboard input is fully supported — users can type numbers, and formatting is applied automatically.
|