@ceed/cds 1.29.0 → 1.29.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/Overview.md +5 -5
- package/dist/components/data-display/Avatar.md +110 -69
- package/dist/components/data-display/Badge.md +91 -39
- package/dist/components/data-display/Chip.md +49 -20
- package/dist/components/data-display/DataTable.md +93 -0
- package/dist/components/data-display/InfoSign.md +12 -0
- package/dist/components/data-display/Table.md +72 -55
- package/dist/components/data-display/Tooltip.md +40 -40
- package/dist/components/data-display/Typography.md +53 -70
- package/dist/components/feedback/Alert.md +88 -72
- package/dist/components/feedback/CircularProgress.md +17 -0
- package/dist/components/feedback/Skeleton.md +17 -0
- package/dist/components/inputs/Button.md +94 -68
- package/dist/components/inputs/ButtonGroup.md +17 -0
- package/dist/components/inputs/Calendar.md +118 -457
- package/dist/components/inputs/Checkbox.md +185 -430
- package/dist/components/inputs/CurrencyInput.md +22 -0
- package/dist/components/inputs/DatePicker.md +36 -0
- package/dist/components/inputs/DateRangePicker.md +26 -0
- package/dist/components/inputs/FilterableCheckboxGroup.md +20 -3
- package/dist/components/inputs/FormControl.md +32 -2
- package/dist/components/inputs/IconButton.md +18 -0
- package/dist/components/inputs/Input.md +198 -136
- package/dist/components/inputs/MonthPicker.md +25 -0
- package/dist/components/inputs/MonthRangePicker.md +23 -0
- package/dist/components/inputs/PercentageInput.md +25 -0
- package/dist/components/inputs/RadioButton.md +23 -0
- package/dist/components/inputs/RadioList.md +20 -1
- package/dist/components/inputs/RadioTileGroup.md +37 -3
- package/dist/components/inputs/Select.md +56 -0
- package/dist/components/inputs/Slider.md +23 -0
- package/dist/components/inputs/Switch.md +20 -0
- package/dist/components/inputs/Textarea.md +32 -8
- package/dist/components/inputs/Uploader/Uploader.md +21 -0
- package/dist/components/layout/Box.md +52 -41
- package/dist/components/layout/Grid.md +87 -81
- package/dist/components/layout/Stack.md +88 -68
- package/dist/components/navigation/Breadcrumbs.md +57 -46
- package/dist/components/navigation/Drawer.md +17 -0
- package/dist/components/navigation/Dropdown.md +13 -0
- package/dist/components/navigation/IconMenuButton.md +17 -0
- package/dist/components/navigation/InsetDrawer.md +130 -292
- package/dist/components/navigation/Link.md +78 -0
- package/dist/components/navigation/Menu.md +17 -0
- package/dist/components/navigation/MenuButton.md +18 -0
- package/dist/components/navigation/Pagination.md +13 -0
- package/dist/components/navigation/Stepper.md +15 -0
- package/dist/components/navigation/Tabs.md +27 -0
- package/dist/components/surfaces/Accordions.md +804 -49
- package/dist/components/surfaces/Card.md +173 -97
- package/dist/components/surfaces/Divider.md +246 -82
- package/dist/components/surfaces/Sheet.md +15 -0
- package/package.json +1 -1
package/dist/Overview.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# CDS (Customer Design System)
|
|
2
2
|
|
|
3
|
-
CDS
|
|
3
|
+
CDS stands for Customer Design System, and it was developed as a system centered around polished UI. It was created to provide a user-friendly experience and streamline development and design processes.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This design system is built on [JoyUI](https://mui.com/joy-ui/getting-started/), so you can refer to the [JoyUI](https://mui.com/joy-ui/getting-started/) documentation for most cases, although some components may have different interfaces due to added abstraction layers.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
It is named for UIs that prioritize visual and intuitive experiences over data-centric interfaces, and it is mainly applied to customer-facing UI.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Documentation and Guides
|
|
10
10
|
|
|
11
|
-
CDS
|
|
11
|
+
For more information about CDS, refer to the [Design System documentation](https://ecubelabs.atlassian.net/wiki/spaces/HP/pages/3256123430/Design+System).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
Avatar
|
|
5
|
+
The Avatar component displays a user's profile image, initials, or icon. It is based on Joy UI Avatar and supports various sizes, colors, and variants. It is used to visually represent individuals, groups, or brands in a user interface.
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
<Avatar alt="User avatar" />
|
|
@@ -25,13 +25,13 @@ import { Avatar } from '@ceed/cds';
|
|
|
25
25
|
function MyComponent() {
|
|
26
26
|
return (
|
|
27
27
|
<div>
|
|
28
|
-
{/*
|
|
28
|
+
{/* Avatar with an image */}
|
|
29
29
|
<Avatar src="/path/to/image.jpg" alt="사용자 이름" />
|
|
30
30
|
|
|
31
|
-
{/*
|
|
31
|
+
{/* Initials avatar */}
|
|
32
32
|
<Avatar>김철수</Avatar>
|
|
33
33
|
|
|
34
|
-
{/*
|
|
34
|
+
{/* Single-character avatar */}
|
|
35
35
|
<Avatar>김</Avatar>
|
|
36
36
|
</div>
|
|
37
37
|
);
|
|
@@ -42,7 +42,7 @@ function MyComponent() {
|
|
|
42
42
|
|
|
43
43
|
### Basic Usage
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
The most basic Avatar usage.
|
|
46
46
|
|
|
47
47
|
```tsx
|
|
48
48
|
<Avatar alt="User avatar" />
|
|
@@ -50,7 +50,7 @@ function MyComponent() {
|
|
|
50
50
|
|
|
51
51
|
### With Image
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
An avatar that uses an image.
|
|
54
54
|
|
|
55
55
|
```tsx
|
|
56
56
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
@@ -60,7 +60,7 @@ function MyComponent() {
|
|
|
60
60
|
|
|
61
61
|
### With Text
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
An avatar that uses text or initials.
|
|
64
64
|
|
|
65
65
|
```tsx
|
|
66
66
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
@@ -72,7 +72,7 @@ function MyComponent() {
|
|
|
72
72
|
|
|
73
73
|
### Variants
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
You can apply various visual styles.
|
|
76
76
|
|
|
77
77
|
```tsx
|
|
78
78
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
@@ -80,14 +80,14 @@ function MyComponent() {
|
|
|
80
80
|
</Stack>
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
- **solid**:
|
|
84
|
-
- **soft**:
|
|
85
|
-
- **outlined**:
|
|
86
|
-
- **plain**:
|
|
83
|
+
- **solid**: A style with a filled background color
|
|
84
|
+
- **soft**: A style with a soft background color
|
|
85
|
+
- **outlined**: A style with only a border
|
|
86
|
+
- **plain**: A minimal style
|
|
87
87
|
|
|
88
88
|
### Sizes
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
You can use avatars in various sizes.
|
|
91
91
|
|
|
92
92
|
```tsx
|
|
93
93
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
@@ -97,14 +97,14 @@ function MyComponent() {
|
|
|
97
97
|
</Stack>
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
-
- **xs**:
|
|
101
|
-
- **sm**:
|
|
102
|
-
- **md**:
|
|
103
|
-
- **lg**:
|
|
100
|
+
- **xs**: Extra small size (16px)
|
|
101
|
+
- **sm**: Small size (24px)
|
|
102
|
+
- **md**: Medium size (32px, default)
|
|
103
|
+
- **lg**: Large size (40px)
|
|
104
104
|
|
|
105
105
|
### Colors
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
You can apply various color themes.
|
|
108
108
|
|
|
109
109
|
```tsx
|
|
110
110
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
@@ -112,15 +112,15 @@ function MyComponent() {
|
|
|
112
112
|
</Stack>
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
- **primary**:
|
|
116
|
-
- **neutral**:
|
|
117
|
-
- **danger**:
|
|
118
|
-
- **success**:
|
|
119
|
-
- **warning**:
|
|
115
|
+
- **primary**: Primary brand color
|
|
116
|
+
- **neutral**: Neutral gray tone
|
|
117
|
+
- **danger**: Red for warnings or errors
|
|
118
|
+
- **success**: Green for success
|
|
119
|
+
- **warning**: Orange for caution
|
|
120
120
|
|
|
121
121
|
### All Combinations
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
You can review all variant, size, and color combinations.
|
|
124
124
|
|
|
125
125
|
```tsx
|
|
126
126
|
<Stack gap={8}>
|
|
@@ -150,11 +150,15 @@ function MyComponent() {
|
|
|
150
150
|
|
|
151
151
|
### User Profile
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
An example of using an avatar in a user profile.
|
|
154
154
|
|
|
155
155
|
```tsx
|
|
156
156
|
<Stack direction="row" spacing={2} alignItems="center">
|
|
157
|
-
<Avatar
|
|
157
|
+
<Avatar
|
|
158
|
+
src="/user-profile.jpg"
|
|
159
|
+
alt="김철수"
|
|
160
|
+
size="lg"
|
|
161
|
+
/>
|
|
158
162
|
<Stack>
|
|
159
163
|
<Typography level="title-md">김철수</Typography>
|
|
160
164
|
<Typography level="body-sm" color="neutral">
|
|
@@ -166,7 +170,7 @@ function MyComponent() {
|
|
|
166
170
|
|
|
167
171
|
### Navigation Bar
|
|
168
172
|
|
|
169
|
-
|
|
173
|
+
Used to display the current user in a navigation bar.
|
|
170
174
|
|
|
171
175
|
```tsx
|
|
172
176
|
<Stack direction="row" spacing={2} alignItems="center" sx={{ ml: 'auto' }}>
|
|
@@ -182,7 +186,7 @@ function MyComponent() {
|
|
|
182
186
|
|
|
183
187
|
### Comment System
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
Used to represent a user in comments or feeds.
|
|
186
190
|
|
|
187
191
|
```tsx
|
|
188
192
|
<Stack direction="row" spacing={2}>
|
|
@@ -196,14 +200,16 @@ function MyComponent() {
|
|
|
196
200
|
2시간 전
|
|
197
201
|
</Typography>
|
|
198
202
|
</Stack>
|
|
199
|
-
<Typography level="body-md"
|
|
203
|
+
<Typography level="body-md">
|
|
204
|
+
이것은 사용자의 댓글 내용입니다.
|
|
205
|
+
</Typography>
|
|
200
206
|
</Stack>
|
|
201
207
|
</Stack>
|
|
202
208
|
```
|
|
203
209
|
|
|
204
210
|
### Team Members
|
|
205
211
|
|
|
206
|
-
|
|
212
|
+
Used to display a list of team members.
|
|
207
213
|
|
|
208
214
|
```tsx
|
|
209
215
|
<Stack spacing={3}>
|
|
@@ -211,7 +217,13 @@ function MyComponent() {
|
|
|
211
217
|
|
|
212
218
|
{teamMembers.map((member) => (
|
|
213
219
|
<Stack key={member.id} direction="row" spacing={2} alignItems="center">
|
|
214
|
-
<Avatar
|
|
220
|
+
<Avatar
|
|
221
|
+
src={member.avatar}
|
|
222
|
+
alt={member.name}
|
|
223
|
+
size="md"
|
|
224
|
+
variant="soft"
|
|
225
|
+
color="primary"
|
|
226
|
+
>
|
|
215
227
|
{member.name.charAt(0)}
|
|
216
228
|
</Avatar>
|
|
217
229
|
<Stack flex={1}>
|
|
@@ -230,19 +242,13 @@ function MyComponent() {
|
|
|
230
242
|
|
|
231
243
|
### Avatar Groups
|
|
232
244
|
|
|
233
|
-
|
|
245
|
+
Used to display multiple users as a group.
|
|
234
246
|
|
|
235
247
|
```tsx
|
|
236
248
|
<Stack direction="row" spacing={-1}>
|
|
237
|
-
<Avatar size="sm" variant="solid" color="primary">
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
<Avatar size="sm" variant="solid" color="success">
|
|
241
|
-
이
|
|
242
|
-
</Avatar>
|
|
243
|
-
<Avatar size="sm" variant="solid" color="warning">
|
|
244
|
-
박
|
|
245
|
-
</Avatar>
|
|
249
|
+
<Avatar size="sm" variant="solid" color="primary">김</Avatar>
|
|
250
|
+
<Avatar size="sm" variant="solid" color="success">이</Avatar>
|
|
251
|
+
<Avatar size="sm" variant="solid" color="warning">박</Avatar>
|
|
246
252
|
<Avatar size="sm" variant="outlined" color="neutral">
|
|
247
253
|
<Typography level="body-xs">+3</Typography>
|
|
248
254
|
</Avatar>
|
|
@@ -251,7 +257,7 @@ function MyComponent() {
|
|
|
251
257
|
|
|
252
258
|
### Status Indicators
|
|
253
259
|
|
|
254
|
-
|
|
260
|
+
Used to display user status alongside the avatar.
|
|
255
261
|
|
|
256
262
|
```tsx
|
|
257
263
|
<Box sx={{ position: 'relative', display: 'inline-block' }}>
|
|
@@ -274,7 +280,7 @@ function MyComponent() {
|
|
|
274
280
|
|
|
275
281
|
### Empty State
|
|
276
282
|
|
|
277
|
-
|
|
283
|
+
Used as a placeholder when no data is available.
|
|
278
284
|
|
|
279
285
|
```tsx
|
|
280
286
|
<Stack alignItems="center" spacing={2}>
|
|
@@ -292,7 +298,7 @@ function MyComponent() {
|
|
|
292
298
|
|
|
293
299
|
### List Items
|
|
294
300
|
|
|
295
|
-
|
|
301
|
+
Used to represent users or items in list items.
|
|
296
302
|
|
|
297
303
|
```tsx
|
|
298
304
|
<List>
|
|
@@ -318,72 +324,107 @@ function MyComponent() {
|
|
|
318
324
|
|
|
319
325
|
### Fallback Behavior
|
|
320
326
|
|
|
321
|
-
|
|
327
|
+
If image loading fails, it automatically falls back to initials or an icon.
|
|
322
328
|
|
|
323
329
|
```tsx
|
|
324
|
-
<Avatar
|
|
330
|
+
<Avatar
|
|
331
|
+
src="/broken-image-url.jpg"
|
|
332
|
+
alt="김철수"
|
|
333
|
+
color="primary"
|
|
334
|
+
variant="soft"
|
|
335
|
+
>
|
|
325
336
|
김
|
|
326
337
|
</Avatar>
|
|
327
338
|
```
|
|
328
339
|
|
|
329
340
|
### Loading States
|
|
330
341
|
|
|
331
|
-
|
|
342
|
+
While the image is loading, `children` are shown first, then the image is displayed once loading completes.
|
|
332
343
|
|
|
333
344
|
```tsx
|
|
334
|
-
<Avatar
|
|
345
|
+
<Avatar
|
|
346
|
+
src="/slow-loading-image.jpg"
|
|
347
|
+
alt="사용자"
|
|
348
|
+
color="neutral"
|
|
349
|
+
variant="soft"
|
|
350
|
+
>
|
|
335
351
|
<PersonIcon />
|
|
336
352
|
</Avatar>
|
|
337
353
|
```
|
|
338
354
|
|
|
355
|
+
## Props and Customization
|
|
356
|
+
|
|
357
|
+
### Key Props
|
|
358
|
+
|
|
359
|
+
| Prop | Type | Default | Description |
|
|
360
|
+
| ------------ | -------------------------------------------------------------- | --------------- | ----------------------------------------------- |
|
|
361
|
+
| `src` | `string` | - | Image URL for the avatar |
|
|
362
|
+
| `alt` | `string` | - | Alt text for the avatar image |
|
|
363
|
+
| `children` | `ReactNode` | - | Fallback content (text, icon) when no image |
|
|
364
|
+
| `getInitial` | `(name: string) => string` | First character | Custom function to extract initials from a name |
|
|
365
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Avatar size |
|
|
366
|
+
| `variant` | `'solid' \| 'soft' \| 'outlined' \| 'plain'` | `'soft'` | Visual style |
|
|
367
|
+
| `color` | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Color scheme |
|
|
368
|
+
| `sx` | `SxProps` | - | Custom styles using the MUI system |
|
|
369
|
+
|
|
370
|
+
> **Note**: Avatar also accepts all Joy UI Avatar props and Framer Motion props.
|
|
371
|
+
|
|
339
372
|
## Accessibility
|
|
340
373
|
|
|
341
|
-
Avatar
|
|
374
|
+
Avatar provides the following accessibility features:
|
|
342
375
|
|
|
343
376
|
### Image Alt Text
|
|
344
377
|
|
|
345
|
-
|
|
378
|
+
For image avatars, provide appropriate alt text.
|
|
346
379
|
|
|
347
380
|
```tsx
|
|
348
|
-
<Avatar
|
|
381
|
+
<Avatar
|
|
382
|
+
src="/user-profile.jpg"
|
|
383
|
+
alt="김철수의 프로필 사진"
|
|
384
|
+
/>
|
|
349
385
|
```
|
|
350
386
|
|
|
351
387
|
### Semantic Meaning
|
|
352
388
|
|
|
353
|
-
|
|
389
|
+
If the avatar carries meaning rather than serving a purely decorative purpose, provide an appropriate role.
|
|
354
390
|
|
|
355
391
|
```tsx
|
|
356
|
-
<Avatar
|
|
392
|
+
<Avatar
|
|
393
|
+
src="/user-avatar.jpg"
|
|
394
|
+
alt="현재 사용자"
|
|
395
|
+
role="img"
|
|
396
|
+
aria-label="현재 로그인한 사용자의 프로필 이미지"
|
|
397
|
+
/>
|
|
357
398
|
```
|
|
358
399
|
|
|
359
400
|
### Color Contrast
|
|
360
401
|
|
|
361
|
-
|
|
402
|
+
For text avatars, maintain sufficient color contrast.
|
|
362
403
|
|
|
363
404
|
```tsx
|
|
364
|
-
//
|
|
405
|
+
// Color combinations that provide good contrast
|
|
365
406
|
<Avatar variant="solid" color="primary">김</Avatar>
|
|
366
407
|
<Avatar variant="soft" color="neutral">이</Avatar>
|
|
367
408
|
```
|
|
368
409
|
|
|
369
410
|
## Best Practices
|
|
370
411
|
|
|
371
|
-
1.
|
|
412
|
+
1. **Choose an appropriate size**: Select a size that fits the usage context.
|
|
372
413
|
|
|
373
414
|
```tsx
|
|
374
|
-
// ✅
|
|
375
|
-
<Avatar size="sm">김</Avatar> //
|
|
376
|
-
<Avatar size="lg">김</Avatar> //
|
|
415
|
+
// ✅ Appropriate size usage
|
|
416
|
+
<Avatar size="sm">김</Avatar> // In a list item
|
|
417
|
+
<Avatar size="lg">김</Avatar> // On a profile page
|
|
377
418
|
|
|
378
|
-
// ❌
|
|
379
|
-
<Avatar size="lg">김</Avatar> //
|
|
419
|
+
// ❌ Inappropriate size usage
|
|
420
|
+
<Avatar size="lg">김</Avatar> // In a navigation bar (too large)
|
|
380
421
|
```
|
|
381
422
|
|
|
382
|
-
2.
|
|
423
|
+
2. **Consistent styling**: Use consistent variants and colors within the same context.
|
|
383
424
|
|
|
384
|
-
3.
|
|
425
|
+
3. **Optimize images**: Use avatar images optimized to an appropriate size.
|
|
385
426
|
|
|
386
|
-
4.
|
|
427
|
+
4. **Provide a fallback**: Prepare an appropriate fallback for missing or failed image loads.
|
|
387
428
|
|
|
388
429
|
```tsx
|
|
389
430
|
<Avatar src={user.avatar} alt={user.name} color="primary" variant="soft">
|
|
@@ -391,14 +432,14 @@ Avatar 컴포넌트는 다음과 같은 접근성 기능을 제공합니다:
|
|
|
391
432
|
</Avatar>
|
|
392
433
|
```
|
|
393
434
|
|
|
394
|
-
5.
|
|
435
|
+
5. **Meaningful usage**: It should be clear whom the avatar represents.
|
|
395
436
|
|
|
396
437
|
## Performance Considerations
|
|
397
438
|
|
|
398
|
-
1.
|
|
439
|
+
1. **Image optimization**: Optimize avatar images to a small size to improve loading speed.
|
|
399
440
|
|
|
400
|
-
2. **Lazy Loading**:
|
|
441
|
+
2. **Lazy Loading**: Consider lazy loading on pages with many avatars.
|
|
401
442
|
|
|
402
|
-
3.
|
|
443
|
+
3. **Caching**: Cache frequently used avatar images appropriately.
|
|
403
444
|
|
|
404
|
-
Avatar
|
|
445
|
+
Avatar is an important component for visually representing people in a user interface. By choosing the right size, color, and variant, you can provide a consistent and accessible user experience.
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
Badge
|
|
5
|
+
Badge is a small visual indicator that overlays another UI element to display a count, status, or label. It is commonly used to show unread notification counts, online/offline status indicators, and "NEW" labels on menu items or navigation elements. The Badge wraps a child component (such as an icon button or avatar) and positions itself in the top-right corner by default.
|
|
6
|
+
|
|
7
|
+
Badge supports multiple colors, variants, and sizes for flexible visual customization. It also provides utility features like a `max` prop for truncating large numbers (e.g., "99+"), a `showZero` prop for controlling zero-count visibility, and a dot-only mode when no `badgeContent` is provided.
|
|
6
8
|
|
|
7
9
|
```tsx
|
|
8
10
|
<Badge {...args}>
|
|
@@ -26,7 +28,7 @@ Badge 컴포넌트는 다른 UI 요소 위에 작은 카운트, 상태, 또는
|
|
|
26
28
|
|
|
27
29
|
```tsx
|
|
28
30
|
import { Badge, IconButton } from '@ceed/cds';
|
|
29
|
-
import
|
|
31
|
+
import NotificationsIcon from '@mui/icons-material/Notifications';
|
|
30
32
|
|
|
31
33
|
function MyComponent() {
|
|
32
34
|
return (
|
|
@@ -39,11 +41,9 @@ function MyComponent() {
|
|
|
39
41
|
}
|
|
40
42
|
```
|
|
41
43
|
|
|
42
|
-
##
|
|
43
|
-
|
|
44
|
-
### Basic Usage
|
|
44
|
+
## Basic
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
Basic Badge usage showing numeric counts, max overflow, and text content.
|
|
47
47
|
|
|
48
48
|
```tsx
|
|
49
49
|
<div style={{
|
|
@@ -70,9 +70,9 @@ function MyComponent() {
|
|
|
70
70
|
</div>
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
## Colors
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
Apply semantic colors to convey the badge's meaning: `primary` for general counts, `danger` for urgent notifications, `success` for online status, and `warning` for attention items.
|
|
76
76
|
|
|
77
77
|
```tsx
|
|
78
78
|
<div style={{
|
|
@@ -111,9 +111,9 @@ function MyComponent() {
|
|
|
111
111
|
</div>
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
## Variants
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
Four style variants are available: `solid` (filled), `soft` (subtle background), `outlined` (border only), and `plain` (minimal).
|
|
117
117
|
|
|
118
118
|
```tsx
|
|
119
119
|
<div style={{
|
|
@@ -146,9 +146,9 @@ function MyComponent() {
|
|
|
146
146
|
</div>
|
|
147
147
|
```
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
## Sizes
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
Three sizes -- `sm`, `md`, and `lg` -- allow the badge to scale proportionally with its wrapped element.
|
|
152
152
|
|
|
153
153
|
```tsx
|
|
154
154
|
<div style={{
|
|
@@ -176,9 +176,9 @@ function MyComponent() {
|
|
|
176
176
|
</div>
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
## With Avatar
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
Badge pairs naturally with Avatar to indicate user status (e.g., notification count or online indicator).
|
|
182
182
|
|
|
183
183
|
```tsx
|
|
184
184
|
<div style={{
|
|
@@ -195,9 +195,9 @@ function MyComponent() {
|
|
|
195
195
|
</div>
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
## Dot Badge
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
When no `badgeContent` is provided, Badge renders as a small dot. This is useful for simple presence or status indicators without a specific count.
|
|
201
201
|
|
|
202
202
|
```tsx
|
|
203
203
|
<div style={{
|
|
@@ -216,9 +216,9 @@ function MyComponent() {
|
|
|
216
216
|
</div>
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
## Max Count
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
Use the `max` prop to cap the displayed number. When `badgeContent` exceeds `max`, it renders as "max+" (e.g., "99+").
|
|
222
222
|
|
|
223
223
|
```tsx
|
|
224
224
|
<div style={{
|
|
@@ -245,9 +245,9 @@ function MyComponent() {
|
|
|
245
245
|
</div>
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
## Show Zero
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
By default, Badge hides when `badgeContent` is `0`. Use the `showZero` prop to force it to remain visible.
|
|
251
251
|
|
|
252
252
|
```tsx
|
|
253
253
|
<div style={{
|
|
@@ -276,40 +276,92 @@ function MyComponent() {
|
|
|
276
276
|
|
|
277
277
|
## Common Use Cases
|
|
278
278
|
|
|
279
|
-
### Notification
|
|
279
|
+
### Notification Bell
|
|
280
280
|
|
|
281
281
|
```tsx
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
import { Badge, IconButton } from '@ceed/cds';
|
|
283
|
+
import NotificationsIcon from '@mui/icons-material/Notifications';
|
|
284
|
+
|
|
285
|
+
function NotificationBell({ unreadCount }) {
|
|
286
|
+
return (
|
|
287
|
+
<Badge badgeContent={unreadCount} max={99} color="danger">
|
|
288
|
+
<IconButton aria-label={`${unreadCount} unread notifications`}>
|
|
289
|
+
<NotificationsIcon />
|
|
290
|
+
</IconButton>
|
|
291
|
+
</Badge>
|
|
292
|
+
);
|
|
293
|
+
}
|
|
287
294
|
```
|
|
288
295
|
|
|
289
|
-
### Status
|
|
296
|
+
### Online Status on Avatar
|
|
290
297
|
|
|
291
298
|
```tsx
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
299
|
+
import { Badge, Avatar } from '@ceed/cds';
|
|
300
|
+
|
|
301
|
+
function UserAvatar({ name, avatarUrl, isOnline }) {
|
|
302
|
+
return (
|
|
303
|
+
<Badge
|
|
304
|
+
color={isOnline ? 'success' : 'neutral'}
|
|
305
|
+
variant="solid"
|
|
306
|
+
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
|
|
307
|
+
>
|
|
308
|
+
<Avatar src={avatarUrl} alt={name} />
|
|
309
|
+
</Badge>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
295
312
|
```
|
|
296
313
|
|
|
297
|
-
### New
|
|
314
|
+
### New Feature Label
|
|
298
315
|
|
|
299
316
|
```tsx
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
317
|
+
import { Badge, Button } from '@ceed/cds';
|
|
318
|
+
|
|
319
|
+
function FeatureButton() {
|
|
320
|
+
return (
|
|
321
|
+
<Badge badgeContent="NEW" color="warning" size="sm">
|
|
322
|
+
<Button variant="outlined">Analytics</Button>
|
|
323
|
+
</Badge>
|
|
324
|
+
);
|
|
325
|
+
}
|
|
303
326
|
```
|
|
304
327
|
|
|
305
328
|
## Best Practices
|
|
306
329
|
|
|
307
|
-
|
|
330
|
+
- **Use semantic colors consistently.** Reserve `danger` for urgent notifications, `success` for positive status (e.g., online), `warning` for attention-needed items, and `primary` for neutral counts.
|
|
331
|
+
- ✔ `color="danger"` for unread message count
|
|
332
|
+
- ✘ `color="primary"` for critical alert count
|
|
333
|
+
|
|
334
|
+
- **Set a `max` value for numeric badges.** Avoid displaying very large numbers like "1,247" in a tiny badge. Use `max={99}` or `max={999}` to keep the badge compact and readable.
|
|
335
|
+
|
|
336
|
+
- **Keep badge content short.** Badges work best with numbers (1-3 digits) or very short text ("NEW", "HOT"). Long text will overflow and look broken.
|
|
337
|
+
|
|
338
|
+
- **Use dot badges for binary states.** When the specific count does not matter (e.g., "has unread items" vs. "12 unread items"), use a dot badge by omitting `badgeContent`.
|
|
339
|
+
|
|
340
|
+
- **Do not badge everything.** Only add badges to elements where the count or status information is genuinely useful. Overuse diminishes their attention-grabbing effect.
|
|
341
|
+
|
|
342
|
+
## Props and Customization
|
|
343
|
+
|
|
344
|
+
### Key Props
|
|
308
345
|
|
|
309
|
-
|
|
346
|
+
| Prop | Type | Default | Description |
|
|
347
|
+
| -------------- | ---------------------------------------------------------------- | ------------------------------------------ | --------------------------------------------------------------------- |
|
|
348
|
+
| `badgeContent` | `ReactNode` | - | Content displayed inside the badge (number, text). Omit for dot badge |
|
|
349
|
+
| `children` | `ReactNode` | - | The element the badge is attached to |
|
|
350
|
+
| `color` | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'danger'` | Badge color |
|
|
351
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Badge size |
|
|
352
|
+
| `variant` | `'solid' \| 'soft' \| 'outlined' \| 'plain'` | `'solid'` | Visual style |
|
|
353
|
+
| `max` | `number` | `99` | Maximum value before showing "N+" |
|
|
354
|
+
| `invisible` | `boolean` | `false` | Hides the badge |
|
|
355
|
+
| `showZero` | `boolean` | `false` | Shows badge when value is 0 |
|
|
356
|
+
| `anchorOrigin` | `{ vertical: 'top' \| 'bottom'; horizontal: 'left' \| 'right' }` | `{ vertical: 'top', horizontal: 'right' }` | Badge position |
|
|
357
|
+
| `badgeInset` | `string` | - | Custom inset for badge positioning |
|
|
358
|
+
| `sx` | `SxProps` | - | Custom styles using the MUI system |
|
|
310
359
|
|
|
311
|
-
|
|
360
|
+
> **Note**: Badge also accepts all Joy UI Badge props.
|
|
312
361
|
|
|
313
|
-
|
|
362
|
+
## Accessibility
|
|
314
363
|
|
|
315
|
-
|
|
364
|
+
- Badge automatically applies `aria-label` or equivalent attributes so screen readers can announce the badge content alongside the wrapped element.
|
|
365
|
+
- When using Badge on an IconButton, always provide an `aria-label` on the IconButton that includes the badge context (e.g., `aria-label="5 unread notifications"`).
|
|
366
|
+
- Avoid relying solely on color to convey badge meaning. Pair colored badges with icons, text, or positional context so color-blind users can also interpret the status.
|
|
367
|
+
- Dot badges (without `badgeContent`) should have an accessible label on the parent element that describes the status (e.g., "User is online").
|