Getting Started
Installation
npm install @ackplus/mui-tanstack-data-grid @tanstack/react-table@9
Peer dependencies (you most likely already have these):
npm install @mui/material @mui/icons-material @emotion/react @emotion/styled
Works with MUI 7 and 9 (@mui/material + @mui/icons-material; Material UI has no v8),
React 18 / 19 and TanStack Table 9, on Node 20+. CI runs the test suite against each of them.
Since 2.0 your app installs @tanstack/react-table@9 itself, so the app and the grid share one copy.
Import ColumnDef (and other table types) from the grid: they include the grid's column options and
don't need TanStack's features type argument.
import type { ColumnDef } from '@ackplus/mui-tanstack-data-grid';
Use 1.x: npm install @ackplus/mui-tanstack-data-grid@1. It supports MUI 5, 6, 7 and 9 with TanStack
Table 8. See Migration to move to 2.0.
Bundle size & module formats
The package is ESM-only (like TanStack Table 9) and built for tree-shaking, so you ship only what you actually import:
- ESM through the
exportsmap: works in Vite, webpack, Rollup, esbuild, Next.js and Node's ESM loader. Node 20.19+ / 22.12+ can alsorequire()it. "sideEffects": false— bundlers drop every feature you don't reference. Importing a single helper pulls ~200 bytes, not the whole grid.- Per-path MUI icons — the grid imports each icon from
@mui/icons-material/<IconName>(never the barrel), so you bundle the ~13 icons it uses, not the full ~2,100-icon set. - TypeScript types are included (
exports.types).
import { DataTable } from '@ackplus/mui-tanstack-data-grid';
If you previously aliased @mui/icons-material to a small shim to keep your bundle down, you can delete
that alias — since v1.2.0 the grid no longer imports the icon barrel, and since v1.3.0 the ESM build lets
your bundler tree-shake unused grid code too. Want your own icons? See
Custom icons.
Your first grid
Pass TanStack column definitions and your data, then opt into features with enable* props.
import { DataTable } from '@ackplus/mui-tanstack-data-grid';
import type { ColumnDef } from '@ackplus/mui-tanstack-data-grid';
interface User { id: number; name: string; email: string; role: string; }
const columns: ColumnDef<User, any>[] = [
{ id: 'name', header: 'Name', accessorKey: 'name' },
{ id: 'email', header: 'Email', accessorKey: 'email' },
{ id: 'role', header: 'Role', accessorKey: 'role' },
];
export function UsersGrid({ data }: { data: User[] }) {
return (
<DataTable
columns={columns}
data={data}
enableSorting
enableColumnResizing
enablePagination
/>
);
}
Core concepts
- Columns are standard TanStack
ColumnDefs, with a few extras (align,type,wrapText, and export options). - Data is client-side via the
dataprop, or server-side viadataMode="server"+onFetchData. - Features are opt-in through
enable*props — sorting, filtering, pagination, selection, pinning, resizing, reordering, virtualization, export. - Imperative control via
apiRef; or drop the UI and use the headlessuseDataTable()hook.