ag-grid-react、material-table、react-data-grid、react-table は、React アプリケーションでデータを表形式で表示・操作するための主要なライブラリです。それぞれ設計思想が異なり、ag-grid-react は高機能なエンタープライズ向けグリッド、material-table は Material Design に準拠した手軽なテーブル、react-data-grid は Excel 風の編集機能に特化したグリッド、react-table は UI を完全に制御できるヘッドレスライブラリとして位置づけられます。プロジェクトの要件(予算、デザインシステム、データの複雑さ、カスタマイズ性)に応じて適切な選択が必要です。
React でデータを表形式で扱う際、ag-grid-react、material-table、react-data-grid、react-table の 4 つが主要な選択肢となります。これらはすべて「テーブルを表示する」という同じ目的を持っていますが、内部の仕組み、提供される機能、そして開発者が負うべき責任が大きく異なります。アーキテクチャの観点から、それぞれの違いと適切な使用場面を技術的に深掘りします。
ライブラリごとに、データをどのように渡し、どのように列を定義するかが異なります。これはコードの保守性に直結する重要なポイントです。
ag-grid-react は、コンポーネントに rowData と columnDefs を渡す設定駆動型です。
// ag-grid-react
import { AgGridReact } from 'ag-grid-react';
function Grid() {
const [rowData, setRowData] = useState([...]);
const [colDefs, setColDefs] = useState([
{ field: 'make' },
{ field: 'model' }
]);
return <AgGridReact rowData={rowData} columnDefs={colDefs} />;
}
material-table は、columns プロパティに定義を渡し、データは data プロパティで渡します。
// material-table
import MaterialTable from 'material-table';
function Table() {
return (
<MaterialTable
columns={[
{ title: 'Make', field: 'make' },
{ title: 'Model', field: 'model' }
]}
data={[
{ make: 'Toyota', model: 'Cellica' }
]}
/>
);
}
react-data-grid は、columns と rows を明確に区別して渡します。
// react-data-grid
import DataGrid from 'react-data-grid';
function Grid() {
const columns = [
{ key: 'make', name: 'Make' },
{ key: 'model', name: 'Model' }
];
const rows = [{ id: 1, make: 'Toyota', model: 'Cellica' }];
return <DataGrid columns={columns} rows={rows} />;
}
react-table はヘッドレスライブラリのため、テーブル構造自体を JSX で構築します。
useReactTable フックを使ってテーブルインスタンスを作成します。// react-table (@tanstack/react-table)
import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
function Table() {
const table = useReactTable({
data: [{ make: 'Toyota', model: 'Cellica' }],
columns: [
{ accessorKey: 'make', header: 'Make' },
{ accessorKey: 'model', header: 'Model' }
],
getCoreRowModel: getCoreRowModel()
});
return (
<table>
<thead>
{table.getHeaderGroups().map(headerGroup => (
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => (
<th key={header.id}>{header.renderHeader()}</th>
))}
</tr>
))}
</thead>
<tbody>
{table.getRowModel().rows.map(row => (
<tr key={row.id}>
{row.getVisibleCells().map(cell => (
<td key={cell.id}>{cell.renderValue()}</td>
))}
</tr>
))}
</tbody>
</table>
);
}
データ操作機能は、ライブラリ選びの大きな分かれ道になります。内蔵されているか、自分で作るかで工数が変わります。
ag-grid-react は、設定一つでソートとフィルタが有効になります。
// ag-grid-react
<AgGridReact
rowData={rowData}
columnDefs={[
{ field: 'make', sortable: true, filter: true },
{ field: 'model', sortable: true, filter: true }
]}
/>
material-table もデフォルトでソートとフィルタ機能を持ちます。
// material-table
<MaterialTable
columns={[
{ title: 'Make', field: 'make', sortable: true },
{ title: 'Model', field: 'model' }
]}
data={data}
options={{ filtering: true }}
/>
react-data-grid は、ソート機能を実装するために少しコードが必要です。
// react-data-grid
function Grid() {
const [rows, setRows] = useState(initialRows);
const [sortColumns, setSortColumns] = useState([]);
// ソートロジックを自分で適用する必要があります
const sortedRows = useMemo(() => {
// ... sort logic based on sortColumns
return rows;
}, [rows, sortColumns]);
return (
<DataGrid
columns={columns}
rows={sortedRows}
sortColumns={sortColumns}
onSortColumnsChange={setSortColumns}
/>
);
}
react-table は、ソートとフィルタのロジックをフック経由で有効にします。
getSortedRowModel など)をインポートして設定します。// react-table
import { getSortedRowModel, getFilteredRowModel } from '@tanstack/react-table';
const table = useReactTable({
data,
columns,
state: { sorting, globalFilter },
onSortingChange: setSorting,
onGlobalFilterChange: setGlobalFilter,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
getFilteredRowModel: getFilteredRowModel()
});
// JSX 内で input やボタンを自由に配置して制御します
<input value={globalFilter} onChange={e => setGlobalFilter(e.target.value)} />
大量のデータを扱う場合、パフォーマンスが最重要課題となります。ここで各ライブラリの戦略が明確に分かれます。
ag-grid-react は「行の仮想化」がコア機能です。
// ag-grid-react
<AgGridReact
rowData={largeDataSet}
pagination={true}
paginationPageSize={20}
// 仮想スクロールはデフォルトで有効
/>
material-table はページネーションをサポートしていますが、仮想スクロールは限定的です。
// material-table
<MaterialTable
data={data}
options={{
pageSize: 10,
paging: true
// 大規模データ用の仮想化オプションは標準では弱い
}}
/>
react-data-grid は仮想スクロールに非常に強いです。
// react-data-grid
<DataGrid
columns={columns}
rows={largeDataSet}
// 内部で効率的な仮想化が行われます
style={{ height: '600px' }}
/>
react-table は仮想化機能を持っていません。
react-window や tanstack/virtual などの別ライブラリと組み合わせる必要があります。// react-table + @tanstack/react-virtual
import { useVirtualizer } from '@tanstack/react-virtual';
const virtualizer = useVirtualizer({
count: rows.length,
getScrollElement: () => tableContainerRef.current,
estimateSize: () => 35
});
// 仮想化された行のみをレンダリングするロジックを JSX に記述
UI の見た目をプロジェクトのデザインシステムにどれだけ合わせられるかも重要な選定基準です。
ag-grid-react は独自のデザインを持っていますが、テーマ変更は可能です。
// ag-grid-react
<AgGridReact
className="ag-theme-alpine" // 事前定義されたテーマ
rowData={rowData}
columnDefs={colDefs}
/>
material-table は Material Design に準拠しています。
// material-table
// Material UI のコンポーネントとして振る舞うため、
// Theme Provider の設定に従います
<ThemeProvider theme={customTheme}>
<MaterialTable {...} />
</ThemeProvider>
react-data-grid はミニマルなデザインですが、CSS で上書き可能です。
// react-data-grid
// CSS ファイルでカスタマイズ
// .rdg-cell { background-color: #f0f0f0; }
<DataGrid
className="my-custom-grid"
columns={columns}
rows={rows}
/>
react-table はスタイルを完全に提供しません。
// react-table
// 完全に自作のクラス名や Tailwind などを適用
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
{/* ... */}
</thead>
{/* ... */}
</table>
これら 4 つのライブラリには、React エコシステムにおける共通の基盤があります。
// どのライブラリでも Redux の状態を渡せる
const data = useSelector(state => state.tableData);
<GridComponent data={data} />
// どのライブラリでも useEffect でデータ取得
useEffect(() => {
fetchData(params).then(setData);
}, [params]);
react-table は型定義が複雑になる傾向があります。// どのライブラリでも型定義を利用可能
interface RowType {
id: number;
name: string;
}
| 機能 | ag-grid-react | material-table | react-data-grid | react-table |
|---|---|---|---|---|
| タイプ | 高機能グリッド | Material UI テーブル | Excel 風グリッド | ヘッドレスライブラリ |
| セットアップ | 設定駆動 | 設定駆動 | 設定駆動 | コード駆動 (JSX) |
| 仮想スクロール | ✅ 内蔵 | ⚠️ 限定的 | ✅ 内蔵 (高速) | ❌ 外部ライブラリ必要 |
| 編集機能 | ✅ 豊富 (有料版など) | ⚠️ 基本機能 | ✅ 特化 (Excel 風) | ❌ 自作 |
| デザイン | テーマ変更可能 | Material Design 固定 | カスタマイズ可能 | 完全自由 |
| 学習コスト | 中 | 低 | 中 | 高 |
| 保守状況 | ✅ 活発 | ⚠️ 注意が必要 | ✅ 安定 | ✅ 活発 (TanStack) |
ag-grid-react は、予算があり、機能性を最優先するエンタープライズ向けダッシュボードに最適です。設定だけで高度な機能が手に入るため、時間対効果が非常に高いです。
material-table は、Material UI を使っている小〜中規模プロジェクトや、プロトタイプ作成に適しています。ただし、長期メンテナンスを考慮すると、コミュニティの動向を注視するか、代替を検討する価値があります。
react-data-grid は、データ入力がメインのアプリケーションや、スプレッドシートのような操作性が必要な場合に強力な選択肢となります。パフォーマンス要件が高い場合にも有効です。
react-table は、デザインや挙動を完全にコントロールしたいチームに向いています。初期コストは高いですが、技術的負債になりにくく、長期的な柔軟性を確保できます。
最終的には、プロジェクトの「デザイン要件」、「予算」、「データ規模」、「開発リソース」の 4 つを天秤にかけて選定することが重要です。
大規模なデータセットを扱い、フィルタリング、ソート、集計、Excel エクスポートなどの高度な機能をすぐに必要とする場合に選択します。予算があり、ライセンス購入が可能なエンタープライズプロジェクトに最適です。設定だけで複雑な機能が使えるため、開発期間を短縮したい場合に有効ですが、バンドルサイズは大きくなります。
Material UI を既に採用しており、手軽に標準的なテーブル機能(ソート、フィルタ、ページネーション)を追加したい場合に適しています。ただし、メンテナンス状況に注意が必要で、長期のエンタープライズプロジェクトではフォーク版や代替の検討を推奨します。プロトタイプや内部ツールで素早く画面を作りたい時に便利です。
Excel のようなセル編集機能や、大量の行を高速にスクロールさせる必要がある場合に選択します。データ入力フォームやスプレッドシート風の UI を実装する際に強みを発揮します。コミュニティ版でも十分な機能がありますが、UI のカスタマイズにはある程度のコード量が必要です。
デザインシステムを完全に自作したい、または既存の UI コンポーネントライブラリと厳密に統合したい場合に選択します。テーブルの見た目や挙動をすべて自分で制御できるため、柔軟性は最高ですが、実装コストも最も高くなります。ヘッドレスであるため、バンドルサイズを最小限に抑えたいプロジェクトにも向いています。
AG Grid is a fully-featured and highly customizable React Data Grid. It delivers outstanding performance and has no third-party dependencies.
AG Grid is available in two versions: Community & Enterprise.
ag-grid-community is free, available under the MIT license, and comes with all of the core features expected from a React Data Grid, including Sorting, Filtering, Pagination, Editing, Custom Components, Theming and more.ag-grid-enterprise is available under a commercial license and comes with advanced features, like AI Toolkit, Integrated Charting, Formulas, Row Grouping, Aggregation, Pivoting, Master/Detail, Server-side Row Model, Find and Exporting in addition to dedicated support from our Engineering team.| Feature | AG Grid Community | AG Grid Enterprise |
|---|---|---|
| MCP Server | ✅ | ✅ (Advanced) |
| Filtering | ✅ | ✅ (Advanced) |
| Sorting | ✅ | ✅ |
| Cell Editing | ✅ | ✅ |
| CSV Export | ✅ | ✅ |
| Drag & Drop | ✅ | ✅ |
| Themes and Styling | ✅ | ✅ |
| Selection | ✅ | ✅ |
| Accessibility | ✅ | ✅ |
| Infinite Scrolling | ✅ | ✅ |
| Pagination | ✅ | ✅ |
| Server-Side Data | ✅ | ✅ (Advanced) |
| Custom Components | ✅ | ✅ |
| AI Toolkit | ❌ | ✅ |
| Integrated Charting | ❌ | ✅ |
| Formulas | ❌ | ✅ |
| Find | ❌ | ✅ |
| Range Selection | ❌ | ✅ |
| Row Grouping and Aggregation | ❌ | ✅ |
| Pivoting | ❌ | ✅ |
| Excel Export | ❌ | ✅ |
| Clipboard Operations | ❌ | ✅ |
| Master/Detail | ❌ | ✅ |
| Tree Data | ❌ | ✅ |
| Column Menu | ❌ | ✅ |
| Context Menu | ❌ | ✅ |
| Tool Panels | ❌ | ✅ |
| Support | ❌ | ✅ |
ℹ️ Note:
Visit the Pricing page for a full comparison.
We've created several demos to showcase AG Grid's rich feature set across different use cases. See them in action below, or interact with them on our Demo page.
AG Grid is easy to set up - all you need to do is provide your data and define your column structure.
$ npm install --save ag-grid-react
1. Register Modules
Register the AllCommunityModule to access all Community features:
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
// Register all Community features
ModuleRegistry.registerModules([AllCommunityModule]);
ℹ️ Note:
To minimize bundle size, only register the modules you want to use. See the Modules page for more information.
2. Import the React Data Grid
// React Data Grid Component
import { AgGridReact } from 'ag-grid-react';
3. Define Rows and Columns
const GridExample = () => {
// Row Data: The data to be displayed.
const [rowData, setRowData] = useState([
{ make: 'Tesla', model: 'Model Y', price: 64950, electric: true },
{ make: 'Ford', model: 'F-Series', price: 33850, electric: false },
{ make: 'Toyota', model: 'Corolla', price: 29600, electric: false },
]);
// Column Definitions: Defines the columns to be displayed.
const [colDefs, setColDefs] = useState([
{ field: 'make' },
{ field: 'model' },
{ field: 'price' },
{ field: 'electric' },
]);
// ...
};
4. React Data Grid Component
return (
// set a height on the parent div because the grid fills the available space
<div style={{ height: 500 }}>
<AgGridReact rowData={rowData} columnDefs={colDefs} />
</div>
);
ℹ️ Note:
For more information on building Data Grids with AG Grid, refer to our Documentation.
We also provide Seed Projects to help you get started with common configurations:
| Environment | Framework |
|---|---|
| Create React App (CRA) | |
| Vite | |
| Create Next App | |
| Vite - TypeScript | |
| Webpack 5 - TypeScript | |
| Webpack 5 - React | |
| Angular CLI | |
| Nuxt | |
| Vite |
AG Grid is fully customisable, both in terms of appearance and functionality. There are many ways in which the grid can be customised and we provide a selection of tools to help create those customisations.
You can create your own Custom Components to customise the behaviour of the grid. For example, you can customise how cells are rendered, how values are edited and also create your own filters.
There are a number of different Component Types that you can provide to the grid, including:
To supply a custom cell renderer and filter components to the Grid, create a direct reference to your component within the gridOptions.columnDefs property:
gridOptions = {
columnDefs: [
{
field: 'country', // The column to add the component to
cellRenderer: CountryCellRenderer, // Your custom cell component
filter: CountryFilter, // Your custom filter component
},
],
};
AG Grid has 4 themes, each available in light & dark modes:
| Quartz | Material |
|---|---|
|
|
| Alpine | Balham |
|
|
All AG Grid themes can be customised using the Theming API, or you can create a new theme from scratch with the help of our Theme Builder or Figma Design System.
AG Grid has a large and active community who have created an ecosystem of 3rd party tools, extensions and utilities to help you build your next project with AG Grid, no matter which language or framework you use:
AG Grid is used by 100,000's of developers across the world, from almost every industry. Whilst most of these projects are private, we've curated a selection of open-source projects from different industries where household names use AG Grid, including J.P.Morgan, MongoDB and NASA. Visit our Community Showcase page to learn more.
Founded in 2016, AG Grid has seen a steady rise in popularity and is now the market leader for Data Grids:
AG Grid Enterprise customers have access to dedicated support via ZenDesk, which is monitored by our engineering teams.
If you have found a bug, please report it in this repository's issues section.
Look for similar problems on StackOverflow using the ag-grid tag. If nothing seems related, post a new message there. Please do not use GitHub issues to ask questions.
AG Grid is developed by a team of co-located developers in London. If you want to join the team send your application to info@ag-grid.com.
ag-grid-community is licensed under the MIT license.
ag-grid-enterprise has a Commercial license.
See the LICENSE file for more info.
If you've made it this far, you may be interested in our latest project: AG Charts - The best React Charting library in the world.
Initially built to power Integrated Charts in AG Grid, we open-sourced this project in 2018. Having seen the steady rise in popularity since then, we have decided to invest in AG Charts with a dedicated Enterprise version (ag-charts-enterprise) in addition to our continued support of ag-charts-community.