ag-grid-react、material-table、react-data-table-component、react-table(TanStack Table)は、React アプリケーションでデータを表形式で表示するための主要なライブラリです。それぞれ設計思想が異なり、フル機能のグリッド、Material Design 専用コンポーネント、軽量なテーブル、そしてロジックのみを提供するヘッドレスライブラリという選択肢があります。
React でデータを表形式で表示する際、ag-grid-react、material-table、react-data-table-component、react-table の 4 つが主要な選択肢となります。これらはすべてテーブル描画を助けますが、提供される機能範囲と設計思想が大きく異なります。実装の手間、パフォーマンス、保守性を考慮して、プロジェクトに最適なものを選ぶ必要があります。
ライブラリを選ぶ際、最初に理解すべきなのは「どこまで作ってくれるか」という点です。
ag-grid-react はフル機能のグリッドです。
// ag-grid-react: 高機能グリッド
import { AgGridReact } from 'ag-grid-react';
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
pagination={true}
sideBar={true} // 列選択パネルなど
/>
material-table は Material Design 専用コンポーネントです。
// material-table: Material Design 特化
import MaterialTable from 'material-table';
<MaterialTable
columns={columns}
data={data}
options={{ pagination: true, sorting: true }}
/>
react-data-table-component は軽量なテーブルコンポーネントです。
// react-data-table-component: 軽量で依存少ない
import DataTable from 'react-data-table-component';
<DataTable
columns={columns}
data={data}
pagination
sortable
/>
react-table(現在は TanStack Table)はヘッドレスライブラリです。
<table> タグの構造から CSS まで、すべて自分で実装する必要があります。// react-table (TanStack): ロジックのみ提供
import { useReactTable, getCoreRowModel } from '@tanstack/react-table';
const table = useReactTable({
data,
columns,
getCoreRowModel: getCoreRowModel(),
});
// 自分で tr, td を描画する
<table>
<tbody>
{table.getRowModel().rows.map(row => (
<tr key={row.id}>
{row.getVisibleCells().map(cell => (
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
))}
</tr>
))}
</tbody>
</table>
各ライブラリでデータをどのように渡すかも重要です。
ag-grid-react は columnDefs と rowData を使います。
const columnDefs = [
{ field: 'name', headerName: '名前' },
{ field: 'age', headerName: '年齢' }
];
const rowData = [{ name: 'Alice', age: 25 }];
material-table は columns 配列を使います。
title と field で列を定義します。const columns = [
{ title: '名前', field: 'name' },
{ title: '年齢', field: 'age', type: 'numeric' }
];
react-data-table-component も columns 配列です。
cell プロパティでカスタム描画関数を定義できます。const columns = [
{ name: '名前', selector: row => row.name },
{ name: '年齢', selector: row => row.age }
];
react-table は columns 定義が最も詳細です。
accessorKey でデータアクセスを定義します。const columns = [
{ accessorKey: 'name', header: '名前' },
{ accessorKey: 'age', header: '年齢' }
];
標準機能としてどこまで含まれているか確認します。
ag-grid-react は設定だけで有効になります。
pagination={true} を書くだけで、複雑なページネーション UI が登場します。// ag-grid: 設定のみで有効
<AgGridReact pagination={true} paginationPageSize={10} />
material-table も options で制御します。
options オブジェクト内で行います。// material-table: options で制御
<MaterialTable options={{ pagination: true, pageSize: 10 }} />
react-data-table-component はプロパティで有効化します。
pagination プロパティを渡すだけで実装されます。// react-data-table-component: プロパティで制御
<DataTable pagination paginationPerPage={10} />
react-table は自分で実装します。
getPaginationRowModel などをインポートし、自分で UI を作ります。// react-table: 自分で実装
import { getPaginationRowModel } from '@tanstack/react-table';
const table = useReactTable({
data,
columns,
getPaginationRowModel: getPaginationRowModel(),
});
// UI は自分で作る
<button onClick={() => table.setPageIndex(0)}>First</button>
データが数千行を超えた場合の挙動が重要になります。
ag-grid-react は行仮想化が標準です。
material-table は仮想化に制限があります。
react-data-table-component は拡張機能で対応します。
react-window などを組み合わせることで対応可能です。react-table は仮想化ライブラリと組み合わせます。
@tanstack/react-virtual などを自分で統合する必要があります。プロジェクトの長期的な維持性を考える上で最も重要な点です。
ag-grid-react は企業によって管理されています。
material-table は保守に注意が必要です。
@material-table/core などのフォーク版か、他ライブラリの検討を強く推奨します。react-data-table-component はコミュニティによって維持されています。
react-table は TanStack によって管理されています。
| 特徴 | ag-grid-react | material-table | react-data-table-component | react-table |
|---|---|---|---|---|
| UI 提供 | ✅ あり(高機能) | ✅ あり(Material) | ✅ あり(軽量) | ❌ なし(ヘッドレス) |
| 仮想化 | ✅ 標準搭載 | ⚠️ 制限あり | ⚠️ 拡張必要 | ⚠️ 統合必要 |
| カスタマイズ | ⚠️ 難しい | ⚠️ 普通 | ✅ 容易 | ✅ 自由 |
| 保守状況 | ✅ 安定 | ⚠️ 不安定 | ✅ 安定 | ✅ 非常に安定 |
| ライセンス | 💰 一部有料 | ✅ 無料 | ✅ 無料 | ✅ 無料 |
ag-grid-react は、予算があり、Excel のような操作性が求められる業務システムに最適です。 — 機能面で妥協したくない場合に選んでください。
material-table は、既存の Material UI プロジェクトで補修的な用途に限るべきです。 — 新規プロジェクトでは保守リスクを避けるため、他の選択肢を検討してください。
react-data-table-component は、見た目と機能のバランスが取れた選択肢です。 — 手軽に始めたいが、ある程度の機能は欲しい場合に適しています。
react-table は、デザインシステムを完全に自作したい場合に選んでください。 — 自由度が最重要であり、実装コストをかけられるチームに向いています。
どのライブラリも一長一短があります。プロジェクトの規模、予算、デザイン要件を照らし合わせて、最適なツールを選んでください。
大規模なエンタープライズアプリケーションで、Excel のような高度な機能(ピボット、集計、セル編集)が必要な場合に選択します。コミュニティ版は無料ですが、高度な機能には有料ライセンスが必要です。
既存の Material UI プロジェクトで手軽に実装したい場合に使われますが、保守状況に不安があるため、新規プロジェクトでの採用は避けるか、フォーク版を検討すべきです。
Material Design の見た目が必要だが、MUI への依存は避けたい場合に適しています。設定が簡単で、中規模なデータ表示にバランスが良い選択肢です。
テーブルの見た目や構造を完全に自分で制御したい場合に選択します。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.