@ceed/cds 1.29.0 → 1.30.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/dist/Overview.md +5 -5
- package/dist/components/Calendar/utils/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +4 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +4 -0
- package/dist/components/MonthRangePicker/MonthRangePicker.d.ts +8 -0
- 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 +59 -5
- package/dist/components/inputs/DateRangePicker.md +46 -5
- 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 +59 -5
- package/dist/components/inputs/MonthRangePicker.md +44 -5
- 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/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +3 -3
- package/dist/index.cjs +99 -39
- package/dist/index.js +99 -39
- package/framer/index.js +1 -1
- package/package.json +1 -1
|
@@ -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").
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
Chip
|
|
5
|
+
The Chip component is a compact UI element used to represent inputs, attributes, and actions. It is commonly used for tags, filters, contacts, categories, and similar items. It can be used with text, icons, or avatars, and provides interactive behaviors such as clicking or deleting.
|
|
6
6
|
|
|
7
7
|
```tsx
|
|
8
8
|
<Chip {...args} />
|
|
@@ -28,7 +28,10 @@ function MyComponent() {
|
|
|
28
28
|
<Chip clickable onClick={() => console.log('clicked')}>
|
|
29
29
|
Clickable Chip
|
|
30
30
|
</Chip>
|
|
31
|
-
<Chip
|
|
31
|
+
<Chip
|
|
32
|
+
endDecorator={<CloseIcon />}
|
|
33
|
+
onClick={() => console.log('delete')}
|
|
34
|
+
>
|
|
32
35
|
Deletable Chip
|
|
33
36
|
</Chip>
|
|
34
37
|
</div>
|
|
@@ -40,7 +43,7 @@ function MyComponent() {
|
|
|
40
43
|
|
|
41
44
|
### Basic Usage
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
Basic Chip usage.
|
|
44
47
|
|
|
45
48
|
```tsx
|
|
46
49
|
<div style={{
|
|
@@ -56,7 +59,7 @@ function MyComponent() {
|
|
|
56
59
|
|
|
57
60
|
### Colors
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
You can apply various colors.
|
|
60
63
|
|
|
61
64
|
```tsx
|
|
62
65
|
<div style={{
|
|
@@ -74,7 +77,7 @@ function MyComponent() {
|
|
|
74
77
|
|
|
75
78
|
### Variants
|
|
76
79
|
|
|
77
|
-
|
|
80
|
+
Provides a variety of style variants.
|
|
78
81
|
|
|
79
82
|
```tsx
|
|
80
83
|
<div style={{
|
|
@@ -91,7 +94,7 @@ function MyComponent() {
|
|
|
91
94
|
|
|
92
95
|
### Sizes
|
|
93
96
|
|
|
94
|
-
|
|
97
|
+
You can adjust the size.
|
|
95
98
|
|
|
96
99
|
```tsx
|
|
97
100
|
<div style={{
|
|
@@ -108,7 +111,7 @@ function MyComponent() {
|
|
|
108
111
|
|
|
109
112
|
### With Icons
|
|
110
113
|
|
|
111
|
-
|
|
114
|
+
Can be used with icons.
|
|
112
115
|
|
|
113
116
|
```tsx
|
|
114
117
|
<div style={{
|
|
@@ -126,7 +129,7 @@ function MyComponent() {
|
|
|
126
129
|
|
|
127
130
|
### With Avatar
|
|
128
131
|
|
|
129
|
-
|
|
132
|
+
Can be used with an avatar to represent a user.
|
|
130
133
|
|
|
131
134
|
```tsx
|
|
132
135
|
<div style={{
|
|
@@ -141,7 +144,7 @@ function MyComponent() {
|
|
|
141
144
|
|
|
142
145
|
### Deletable
|
|
143
146
|
|
|
144
|
-
|
|
147
|
+
A Chip with delete functionality. Clicking it removes it from the list.
|
|
145
148
|
|
|
146
149
|
```tsx
|
|
147
150
|
<div style={{
|
|
@@ -157,7 +160,7 @@ function MyComponent() {
|
|
|
157
160
|
|
|
158
161
|
### Clickable
|
|
159
162
|
|
|
160
|
-
|
|
163
|
+
A clickable Chip that can be used as a filter or tab.
|
|
161
164
|
|
|
162
165
|
```tsx
|
|
163
166
|
<div style={{
|
|
@@ -177,7 +180,7 @@ function MyComponent() {
|
|
|
177
180
|
|
|
178
181
|
### Clickable Actions
|
|
179
182
|
|
|
180
|
-
|
|
183
|
+
Can trigger various actions when clicked.
|
|
181
184
|
|
|
182
185
|
```tsx
|
|
183
186
|
<div style={{
|
|
@@ -197,7 +200,7 @@ function MyComponent() {
|
|
|
197
200
|
|
|
198
201
|
### States
|
|
199
202
|
|
|
200
|
-
|
|
203
|
+
Can represent various states.
|
|
201
204
|
|
|
202
205
|
```tsx
|
|
203
206
|
<div style={{
|
|
@@ -262,7 +265,11 @@ function MyComponent() {
|
|
|
262
265
|
### Filter Controls
|
|
263
266
|
|
|
264
267
|
```tsx
|
|
265
|
-
<Chip
|
|
268
|
+
<Chip
|
|
269
|
+
clickable
|
|
270
|
+
variant={isActive ? 'solid' : 'outlined'}
|
|
271
|
+
onClick={() => setFilter('all')}
|
|
272
|
+
>
|
|
266
273
|
All Items
|
|
267
274
|
</Chip>
|
|
268
275
|
```
|
|
@@ -270,21 +277,43 @@ function MyComponent() {
|
|
|
270
277
|
### Contact Pills
|
|
271
278
|
|
|
272
279
|
```tsx
|
|
273
|
-
<Chip
|
|
280
|
+
<Chip
|
|
281
|
+
startDecorator={<Avatar size="sm" />}
|
|
282
|
+
endDecorator={<CloseIcon />}
|
|
283
|
+
onDelete={() => removeContact(id)}
|
|
284
|
+
>
|
|
274
285
|
John Doe
|
|
275
286
|
</Chip>
|
|
276
287
|
```
|
|
277
288
|
|
|
289
|
+
## Props and Customization
|
|
290
|
+
|
|
291
|
+
### Key Props
|
|
292
|
+
|
|
293
|
+
| Prop | Type | Default | Description |
|
|
294
|
+
| ---------------- | -------------------------------------------------------------- | ----------- | -------------------------------------- |
|
|
295
|
+
| `children` | `ReactNode` | - | Chip content (text, icons) |
|
|
296
|
+
| `variant` | `'solid' \| 'soft' \| 'outlined' \| 'plain'` | `'soft'` | Visual style |
|
|
297
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Chip size |
|
|
298
|
+
| `color` | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Color scheme |
|
|
299
|
+
| `disabled` | `boolean` | `false` | Disables the chip |
|
|
300
|
+
| `onClick` | `(event: MouseEvent) => void` | - | Click handler (makes chip interactive) |
|
|
301
|
+
| `startDecorator` | `ReactNode` | - | Content before the chip text |
|
|
302
|
+
| `endDecorator` | `ReactNode` | - | Content after the chip text |
|
|
303
|
+
| `sx` | `SxProps` | - | Custom styles using the MUI system |
|
|
304
|
+
|
|
305
|
+
> **Note**: Chip also accepts all Joy UI Chip props and Framer Motion props.
|
|
306
|
+
|
|
278
307
|
## Best Practices
|
|
279
308
|
|
|
280
|
-
1.
|
|
309
|
+
1. **Use appropriate sizes**: Choose sizes that fit the content. Keep text concise.
|
|
281
310
|
|
|
282
|
-
2.
|
|
311
|
+
2. **Be consistent**: Use the same variant and color within the same context.
|
|
283
312
|
|
|
284
|
-
3.
|
|
313
|
+
3. **Clear actions**: When using clickable or deletable behavior, provide clear feedback to the user.
|
|
285
314
|
|
|
286
|
-
4.
|
|
315
|
+
4. **Accessibility**: Support keyboard navigation and provide appropriate labels for screen readers.
|
|
287
316
|
|
|
288
|
-
5.
|
|
317
|
+
5. **Appropriate spacing**: Use proper spacing when listing multiple Chips to improve readability.
|
|
289
318
|
|
|
290
|
-
6.
|
|
319
|
+
6. **Semantic color usage**: Use colors with clear meaning, such as green for success and orange for warnings.
|
|
@@ -1726,6 +1726,99 @@ This is inspector: {selectedRowId}
|
|
|
1726
1726
|
</Stack>
|
|
1727
1727
|
```
|
|
1728
1728
|
|
|
1729
|
+
## Props and Customization
|
|
1730
|
+
|
|
1731
|
+
### DataTableProps
|
|
1732
|
+
|
|
1733
|
+
| Prop | Type | Default | Description |
|
|
1734
|
+
| ------------------------------- | ------------------------------------------------------------------- | ----------------------- | ----------------------------------------------------- |
|
|
1735
|
+
| `rows` | `T[]` | (required) | Array of row data objects |
|
|
1736
|
+
| `columns` | `ColumnDef<T, ID>[]` | (required) | Column definitions array |
|
|
1737
|
+
| `getId` | `(row: T) => ID` | - | Custom row identifier function (defaults to `row.id`) |
|
|
1738
|
+
| `checkboxSelection` | `boolean` | `false` | Enables checkbox selection column |
|
|
1739
|
+
| `selectionModel` | `ID[]` | - | Controlled selection state |
|
|
1740
|
+
| `onSelectionModelChange` | `(model: ID[], isTotalSelected?: boolean) => void` | - | Callback when selection changes |
|
|
1741
|
+
| `isRowSelectable` | `(params: { row, id }) => boolean` | - | Determines if a row can be selected |
|
|
1742
|
+
| `disableSelectionOnClick` | `boolean` | `false` | Prevents selection when clicking a row |
|
|
1743
|
+
| `isTotalSelected` | `boolean` | `false` | Represents total selection state in server pagination |
|
|
1744
|
+
| `editMode` | `boolean` | `false` | Enables inline cell editing |
|
|
1745
|
+
| `pagination` | `boolean` | `false` | Enables pagination |
|
|
1746
|
+
| `paginationMode` | `'client' \| 'server'` | `'client'` | Client-side or server-side pagination |
|
|
1747
|
+
| `paginationModel` | `{ page: number; pageSize: number }` | - | Controlled pagination state |
|
|
1748
|
+
| `onPaginationModelChange` | `(model: { page, pageSize }) => void` | - | Callback when page or page size changes |
|
|
1749
|
+
| `rowCount` | `number` | - | Total row count (required for server pagination) |
|
|
1750
|
+
| `sortModel` | `SortModel<T>[]` | - | Controlled sort state |
|
|
1751
|
+
| `sortOrder` | `('asc' \| 'desc' \| null)[]` | `['asc', 'desc', null]` | Allowed sort directions cycle |
|
|
1752
|
+
| `onSortModelChange` | `(model: SortModel<T>[]) => void` | - | Callback when sort changes |
|
|
1753
|
+
| `pinnedColumns` | `{ left?: string[]; right?: string[] }` | - | Pin columns to left/right edges |
|
|
1754
|
+
| `columnGroupingModel` | `ColumnGroupingModel` | - | Column header grouping configuration |
|
|
1755
|
+
| `columnVisibilityModel` | `Record<string, boolean>` | - | Controlled column visibility (false = hidden) |
|
|
1756
|
+
| `onColumnVisibilityModelChange` | `(model: Record<string, boolean>) => void` | - | Callback when visibility changes |
|
|
1757
|
+
| `loading` | `boolean` | `false` | Shows loading overlay |
|
|
1758
|
+
| `hoverRow` | `boolean` | `false` | Highlights rows on hover |
|
|
1759
|
+
| `stickyHeader` | `boolean` | `false` | Fixes the header when scrolling |
|
|
1760
|
+
| `stripe` | `'even' \| 'odd'` | - | Applies striped row background |
|
|
1761
|
+
| `noWrap` | `boolean` | `false` | Prevents cell text wrapping |
|
|
1762
|
+
| `onRowClick` | `(params: { row, rowId }, event) => void` | - | Callback when a row is clicked |
|
|
1763
|
+
| `slots` | `{ checkbox?, toolbar?, footer?, loadingOverlay?, noRowsOverlay? }` | - | Custom component slots |
|
|
1764
|
+
| `slotProps` | `{ checkbox?, toolbar?, background?, noRowsOverlay? }` | - | Props passed to slot components |
|
|
1765
|
+
| `apiRef` | `React.RefObject<DataTableApi>` | - | Imperative API reference |
|
|
1766
|
+
| `initialState` | `{ sorting?, columns? }` | - | Initial state for uncontrolled sort/visibility |
|
|
1767
|
+
|
|
1768
|
+
### ColumnDef Union Type
|
|
1769
|
+
|
|
1770
|
+
All column types extend `BaseColumnDef` with shared properties:
|
|
1771
|
+
|
|
1772
|
+
| Prop | Type | Default | Description |
|
|
1773
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------ |
|
|
1774
|
+
| `field` | `keyof T` | (required) | Row data field to display |
|
|
1775
|
+
| `headerName` | `string` | - | Column header text |
|
|
1776
|
+
| `type` | `'text' \| 'number' \| 'currency' \| 'date' \| 'select' \| 'autocomplete' \| 'longText' \| 'link' \| 'actions'` | `'text'` | Column type (determines edit UI) |
|
|
1777
|
+
| `width` | `string` | - | Column width (e.g., `'200px'`, `'30%'`) |
|
|
1778
|
+
| `minWidth` | `string` | - | Minimum column width |
|
|
1779
|
+
| `maxWidth` | `string` | - | Maximum column width |
|
|
1780
|
+
| `resizable` | `boolean` | `false` | Enables column resizing by dragging |
|
|
1781
|
+
| `sortable` | `boolean` | `true` | Enables sorting for this column |
|
|
1782
|
+
| `sortComparator` | `(params: { rowA, rowB }) => number` | - | Custom sort logic |
|
|
1783
|
+
| `sortOrder` | `('asc' \| 'desc' \| null)[]` | - | Column-specific sort direction cycle |
|
|
1784
|
+
| `required` | `boolean` | `false` | Shows required indicator (\*) in header |
|
|
1785
|
+
| `headerLineClamp` | `1 \| 2` | `1` | Max header text lines before truncation |
|
|
1786
|
+
| `description` | `string` | - | Tooltip text for the column header |
|
|
1787
|
+
| `cellClassName` | `string \| ((params: { row, value }) => string)` | - | Dynamic cell CSS class |
|
|
1788
|
+
| `headerClassName` | `string \| ((params) => string)` | - | Dynamic header CSS class |
|
|
1789
|
+
| `renderCell` | `(params: { row, value, rowIndex, colIndex, id }) => ReactNode` | - | Custom cell renderer |
|
|
1790
|
+
| `renderEditCell` | `(params) => ReactNode` | - | Custom edit cell renderer |
|
|
1791
|
+
| `isCellEditable` | `boolean \| ((params: { row, value, id }) => boolean)` | `true` | Whether a cell is editable |
|
|
1792
|
+
| `componentProps` | `object \| ((params: { row, id }) => object)` | - | Props passed to the column type's edit component |
|
|
1793
|
+
| `onCellEditStart` | `(params: { row, originalRow, value }) => void` | - | Callback when cell editing begins |
|
|
1794
|
+
| `onCellEditStop` | `(params: { row, originalRow, value }) => void` | - | Callback when cell editing ends |
|
|
1795
|
+
|
|
1796
|
+
### ActionsColumnDef
|
|
1797
|
+
|
|
1798
|
+
For action columns, use `type: 'actions'` with `getActions`:
|
|
1799
|
+
|
|
1800
|
+
```tsx
|
|
1801
|
+
{
|
|
1802
|
+
field: 'actions',
|
|
1803
|
+
type: 'actions',
|
|
1804
|
+
getActions: ({ row, id }) => [
|
|
1805
|
+
<Button key="edit" size="sm">Edit</Button>,
|
|
1806
|
+
<IconMenuButton key="more" items={[...]} />,
|
|
1807
|
+
],
|
|
1808
|
+
}
|
|
1809
|
+
```
|
|
1810
|
+
|
|
1811
|
+
### DataTableApi
|
|
1812
|
+
|
|
1813
|
+
```tsx
|
|
1814
|
+
interface DataTableApi {
|
|
1815
|
+
getRowIndexRelativeToVisibleRows(rowId: string): number;
|
|
1816
|
+
setCellFocus(rowId: string): void;
|
|
1817
|
+
}
|
|
1818
|
+
```
|
|
1819
|
+
|
|
1820
|
+
> **Note**: DataTable also accepts all Joy UI Table props (e.g., `borderAxis`, `size`, `sx`).
|
|
1821
|
+
|
|
1729
1822
|
## Constraints and Considerations
|
|
1730
1823
|
|
|
1731
1824
|
### Required Conditions
|
|
@@ -114,6 +114,18 @@ function MetricCard() {
|
|
|
114
114
|
}
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
+
## Props and Customization
|
|
118
|
+
|
|
119
|
+
### Key Props
|
|
120
|
+
|
|
121
|
+
| Prop | Type | Default | Description |
|
|
122
|
+
| ----------- | -------------------------------------------------------------- | ----------- | ------------------------------------- |
|
|
123
|
+
| `message` | `string` | (required) | Tooltip message text |
|
|
124
|
+
| `placement` | `TooltipPlacement` | `'top'` | Tooltip position relative to the icon |
|
|
125
|
+
| `color` | `'primary' \| 'neutral' \| 'danger' \| 'success' \| 'warning'` | `'neutral'` | Icon color |
|
|
126
|
+
| `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Icon size |
|
|
127
|
+
| `sx` | `SxProps` | - | Custom styles |
|
|
128
|
+
|
|
117
129
|
## Best Practices
|
|
118
130
|
|
|
119
131
|
- **Keep messages concise.** Tooltip messages should be 1-2 sentences that quickly answer "what does this mean?" Avoid paragraphs of text.
|