React Data Grid

7.0.0-beta.59 · active · verified Tue Apr 21

react-data-grid is a high-performance, feature-rich data grid component for React applications, currently in `7.0.0-beta.59`. It is engineered for efficiency with large datasets through virtualization, rendering only visible rows and columns. The library offers extensive customization options, including frozen columns, multi-column sorting, row and column grouping, row selection, cell editing, and adaptable renderers. It ships with comprehensive TypeScript support, ensuring type safety across its API. `react-data-grid` supports React 19.2+, modern browsers, and server-side rendering, prioritizing bundle size efficiency with tree-shaking and no external runtime dependencies. The project maintains an active development pace with frequent beta releases, incorporating features like keyboard accessibility, light/dark modes, and RTL support, though a stable v7 release date is not yet scheduled.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic functional React Data Grid component with columns, initial rows, and state management for row changes. It includes necessary imports for the `DataGrid` component, `Column` type, and default styles. The example showcases a simple grid with sorting and resizing enabled on columns, making it runnable and illustrative for common usage patterns.

import React from 'react';
import { DataGrid, type Column } from 'react-data-grid';
import 'react-data-grid/lib/styles.css';

interface Row {
  id: number;
  title: string;
  status: 'todo' | 'in-progress' | 'done';
  priority: 'low' | 'medium' | 'high';
}

const initialRows: Row[] = Array.from({ length: 50 }, (_, i) => ({
  id: i,
  title: `Task ${i + 1}`,
  status: i % 3 === 0 ? 'todo' : i % 3 === 1 ? 'in-progress' : 'done',
  priority: i % 4 === 0 ? 'high' : i % 4 === 1 ? 'medium' : 'low'
}));

const columns: readonly Column<Row>[] = [
  { key: 'id', name: 'ID', width: 60, resizable: true },
  { key: 'title', name: 'Title', resizable: true, sortable: true },
  { key: 'status', name: 'Status', resizable: true, sortable: true },
  { key: 'priority', name: 'Priority', resizable: true, sortable: true }
];

function MyDataGrid() {
  const [rows, setRows] = React.useState(initialRows);

  const onRowsChange = (updatedRows: Row[]) => {
    setRows(updatedRows);
  };

  return (
    <div style={{ height: 400, width: '100%' }}>
      <DataGrid
        columns={columns}
        rows={rows}
        onRowsChange={onRowsChange}
        rowKeyGetter={(row) => row.id}
        className="rdg-grid"
      />
    </div>
  );
}

export default MyDataGrid;

view raw JSON →