AdaptTable for shadcn

Inline cell editing in shadcn

Mark a column editable, pass onCellEdit, and double-click opens a shadcn editor in the cell. Enter commits, Escape cancels, Tab moves to the next editable cell.

The table never mutates your rows. It hands your handler the row, the column and the new value, and shows whatever you hand back — which is what makes optimistic updates, validation and rollback yours to decide.

With cellNavigation on, the same handler receives whole blocks: paste a spreadsheet range with Ctrl+V, drag the fill handle, and undo the entire paste with one Ctrl+Z.

Text, number and select editors all share one class key, so every editor in the table is the same h-8 field over border-input — and a rejected commit reads as a form error in text-destructive, the tone shadcn already uses for one.

The code

import { DataTable } from "@adapttable/shadcn";

const columns = [
  { key: "name", editable: true },
  {
    key: "status",
    editable: true,
    editor: { type: "select", options: ["active", "on-leave"] },
  },
  { key: "budget", editable: true, editor: "number" },
];

export function People({ rows, onSave }) {
  return (
    <DataTable
      data={rows}
      columns={columns}
      rowKey={(row) => row.id}
      cellNavigation
      editHistory
      onCellEdit={(row, key, value) =>
        onSave({ ...row, [key]: value })
      }
    />
  );
}

Install

pnpm add @adapttable/shadcn @adapttable/core

The same feature in the other kits

More shadcn features

Reference: cell-editing, cell-navigation. More of this kit: AdaptTable for shadcn, or the live demo.