You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+292-2Lines changed: 292 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,9 +120,299 @@ function App() {
120
120
}
121
121
```
122
122
123
-
## Theming
123
+
## Styling and Customization
124
124
125
-
Set `--rdg-color-scheme: light/dark` at the `:root` to control the color theme. The light or dark themes can be enforced using the `rdg-light` or `rdg-dark` classes.
125
+
The DataGrid provides multiple ways to customize its appearance and behavior.
126
+
127
+
### Light/Dark Themes
128
+
129
+
The DataGrid supports both light and dark color schemes out of the box using CSS's `light-dark()` function. The theme automatically adapts based on the user's system preference when `color-scheme: light dark;` is set.
130
+
131
+
To enforce a specific theme, we recommend setting the standard `color-scheme` CSS property on the `:root`:
132
+
133
+
```css
134
+
:root {
135
+
color-scheme: light; /* or 'dark', or 'light dark' for auto */
136
+
}
137
+
```
138
+
139
+
Alternatively, you can add the `rdg-light` or `rdg-dark` class to individual grids:
You can also use `headerCellClass` and `summaryCellClass` for header and summary cells respectively.
315
+
316
+
#### Column Widths
317
+
318
+
Control column widths using the `width`, `minWidth`, and `maxWidth` properties:
319
+
320
+
```tsx
321
+
const columns:Column<Row>[] = [
322
+
{
323
+
key: 'id',
324
+
name: 'ID',
325
+
width: 80, // Fixed width
326
+
resizable: false
327
+
},
328
+
{
329
+
key: 'name',
330
+
name: 'Name',
331
+
width: '30%', // Percentage width
332
+
minWidth: 100,
333
+
maxWidth: 400
334
+
},
335
+
{
336
+
key: 'description',
337
+
name: 'Description'
338
+
// No width specified - automatically sized
339
+
}
340
+
];
341
+
```
342
+
343
+
Enable column resizing by setting `resizable: true` on individual columns or use [`defaultColumnOptions`](#defaultcolumnoptions-maybedefaultcolumnoptionsr-sr) to apply it to all columns:
344
+
345
+
```tsx
346
+
<DataGrid
347
+
columns={columns}
348
+
rows={rows}
349
+
defaultColumnOptions={{
350
+
resizable: true,
351
+
sortable: true
352
+
}}
353
+
/>
354
+
```
355
+
356
+
### Custom Renderers
357
+
358
+
Replace default components with custom implementations using the [`renderers`](#renderers-mayberendererstrow-tsummaryrow) prop:
0 commit comments