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
+234-8Lines changed: 234 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,9 +120,120 @@ 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:
The DataGrid accepts standard [`className`](#classname-string--undefined) and [`style`](#style-cssproperties--undefined) props:
206
+
207
+
```tsx
208
+
<DataGrid
209
+
columns={columns}
210
+
rows={rows}
211
+
className="my-grid custom-theme"
212
+
style={{ width: 800, height: 600 }}
213
+
/>
214
+
```
215
+
216
+
### Row and Cell Styling
217
+
218
+
#### Row Heights
219
+
220
+
Control row heights using the [`rowHeight`](#rowheight-maybenumber--row-r--number), [`headerRowHeight`](#headerrowheight-maybenumber), and [`summaryRowHeight`](#summaryrowheight-maybenumber) props. The `rowHeight` prop supports both fixed heights and dynamic heights per row.
221
+
222
+
#### Row Classes
223
+
224
+
Apply custom CSS classes to rows using the [`rowClass`](#rowclass-mayberow-r-rowidx-number--maybestring) prop, and to header rows using the [`headerRowClass`](#headerrowclass-maybestring) prop.
225
+
226
+
#### Cell Classes
227
+
228
+
Apply custom CSS classes to cells using the [`cellClass`](#cellclass-maybestring--row-trow--maybestring) property in column definitions. You can also use [`headerCellClass`](#headercellclass-maybestring) and [`summaryCellClass`](#summarycellclass-maybestring--row-tsummaryrow--maybestring) for header and summary cells respectively.
229
+
230
+
#### Column Widths
231
+
232
+
Control column widths using the [`width`](#width-maybenumber--string), [`minWidth`](#minwidth-maybenumber), and [`maxWidth`](#maxwidth-maybenumber) properties in column definitions. Enable column resizing using the [`resizable`](#resizable-maybeboolean) property, or use [`defaultColumnOptions`](#defaultcolumnoptions-maybedefaultcolumnoptionsr-sr) to apply it to all columns.
233
+
234
+
### Custom Renderers
235
+
236
+
Replace default components with custom implementations using the [`renderers`](#renderers-mayberenderersr-sr) prop. Columns can also have custom renderers using the [`renderCell`](#rendercell-maybeprops-rendercellpropstrow-tsummaryrow--reactnode), [`renderHeaderCell`](#renderheadercell-maybeprops-renderheadercellpropstrow-tsummaryrow--reactnode), [`renderSummaryCell`](#rendersummarycell-maybeprops-rendersummarycellpropstsummaryrow-trow--reactnode), [`renderGroupCell`](#rendergroupcell-maybeprops-rendergroupcellpropstrow-tsummaryrow--reactnode), and [`renderEditCell`](#rendereditcell-maybeprops-rendereditcellpropstrow-tsummaryrow--reactnode) properties.
126
237
127
238
## API Reference
128
239
@@ -214,7 +325,19 @@ function MyGrid() {
214
325
215
326
Height of each row in pixels. A function can be used to set different row heights.
216
327
217
-
:warning:**Performance:** When using a function, the height of all rows is calculated upfront on every render. For large datasets (1000+ rows), this can cause performance issues. Consider using a fixed height when possible, or memoize the `rowHeight` function.
:warning:**Performance:** When using a function, the heights of all rows are processed upfront. For large datasets (1000+ rows), this can cause performance issues if the identity of the function changes and invalidates internal memoization. Consider using a static function when possible, or memoize the `rowHeight` function.
218
341
219
342
###### `headerRowHeight?: Maybe<number>`
220
343
@@ -228,6 +351,17 @@ Height of the header row in pixels.
228
351
229
352
Height of each summary row in pixels.
230
353
354
+
```tsx
355
+
<DataGrid
356
+
columns={columns}
357
+
rows={rows}
358
+
rowHeight={35}
359
+
headerRowHeight={45}
360
+
summaryRowHeight={40}
361
+
topSummaryRows={topSummaryRows}
362
+
/>
363
+
```
364
+
231
365
###### `columnWidths?: Maybe<ColumnWidths>`
232
366
233
367
A map of column widths containing both measured and resized widths. If not provided then an internal state is used.
This property sets the text direction of the grid, it defaults to `'ltr'` (left-to-right). Setting `direction` to `'rtl'` has the following effects:
@@ -1036,6 +1207,31 @@ A unique key to distinguish each column
1036
1207
1037
1208
Width can be any valid css grid column value. If not specified, it will be determined automatically based on grid width and specified widths of other columns.
1038
1209
1210
+
```tsx
1211
+
const columns:Column<Row>[] = [
1212
+
{
1213
+
key: 'id',
1214
+
name: 'ID',
1215
+
width: 80, // Fixed width in pixels
1216
+
resizable: false
1217
+
},
1218
+
{
1219
+
key: 'name',
1220
+
name: 'Name',
1221
+
width: '30%', // Percentage width
1222
+
minWidth: 100,
1223
+
maxWidth: 400
1224
+
},
1225
+
{
1226
+
key: 'description',
1227
+
name: 'Description'
1228
+
// No width specified - automatically sized
1229
+
}
1230
+
];
1231
+
```
1232
+
1233
+
Other examples:
1234
+
1039
1235
```tsx
1040
1236
width: 80, // pixels
1041
1237
width: '25%',
@@ -1059,6 +1255,36 @@ Maximum column width in pixels.
1059
1255
1060
1256
Class name(s) for cells. Can be a string or a function that returns a class name based on the row.
0 commit comments