TanStack Table

Headless UI for building powerful tables & datagrids

table

Framework-agnostic with sorting, filtering, pagination, and more.

ReactTableHeadlessSortingFiltering

๐ŸŽฎ Playground

import { useReactTable, getCoreRowModel, flexRender } from "@tanstack/react-table"

const data = [
  { name: "Alice", email: "alice@example.com" },
  { name: "Bob", email: "bob@example.com" },
  { name: "Charlie", email: "charlie@example.com" },
]

const columns = [
  { accessorKey: "name", header: "Name" },
  { accessorKey: "email", header: "Email" },
]

export default function Demo() {
  const table = useReactTable({
    data,
    columns,
    getCoreRowModel: getCoreRowModel(),
  })

  return (
    <table style={{ width: "100%", borderCollapse: "collapse" }}>
      <thead>
        {table.getHeaderGroups().map(headerGroup => (
          <tr key={headerGroup.id}>
            {headerGroup.headers.map(header => (
              <th key={header.id} style={{ border: "1px solid #ccc", padding: "8px", textAlign: "left" }}>
                {flexRender(header.column.columnDef.header, header.getContext())}
              </th>
            ))}
          </tr>
        ))}
      </thead>
      <tbody>
        {table.getRowModel().rows.map(row => (
          <tr key={row.id}>
            {row.getVisibleCells().map(cell => (
              <td key={cell.id} style={{ border: "1px solid #ccc", padding: "8px" }}>
                {flexRender(cell.column.columnDef.cell, cell.getContext())}
              </td>
            ))}
          </tr>
        ))}
      </tbody>
    </table>
  )
}
Use cases
  • โ€ขData tables
  • โ€ขAdmin panels
  • โ€ขSpreadsheet-like interfaces
Good for
  • โœ“Complex data displays
  • โœ“Custom table designs
  • โœ“Multi-framework projects
Not good for
  • โœ—Simple lists
  • โœ—Quick prototypes needing styled tables
Installation
$ npm install @tanstack/react-table
Example
import { useReactTable, getCoreRowModel, flexRender } from "@tanstack/react-table"

const data = [
  { name: "Alice", email: "alice@example.com" },
  { name: "Bob", email: "bob@example.com" },
  { name: "Charlie", email: "charlie@example.com" },
]

const columns = [
  { accessorKey: "name", header: "Name" },
  { accessorKey: "email", header: "Email" },
]

export default function Demo() {
  const table = useReactTable({
    data,
    columns,
    getCoreRowModel: getCoreRowModel(),
  })

  return (
    <table style={{ width: "100%", borderCollapse: "collapse" }}>
      <thead>
        {table.getHeaderGroups().map(headerGroup => (
          <tr key={headerGroup.id}>
            {headerGroup.headers.map(header => (
              <th key={header.id} style={{ border: "1px solid #ccc", padding: "8px", textAlign: "left" }}>
                {flexRender(header.column.columnDef.header, header.getContext())}
              </th>
            ))}
          </tr>
        ))}
      </thead>
      <tbody>
        {table.getRowModel().rows.map(row => (
          <tr key={row.id}>
            {row.getVisibleCells().map(cell => (
              <td key={cell.id} style={{ border: "1px solid #ccc", padding: "8px" }}>
                {flexRender(cell.column.columnDef.cell, cell.getContext())}
              </td>
            ))}
          </tr>
        ))}
      </tbody>
    </table>
  )
}
Comparison

"More flexible than AG Grid, more features than react-table v7."

Trust Metrics

25.5K

GitHub Stars

2.8M

Weekly Downloads

Last Commit:last year
Used by
FacebookAmazonMicrosoft