Shadcn React Table

Search documentation

Search the docs

Row actions

Provide renderRowActions to add a trailing actions column. It receives { row, table } and returns whatever controls you need — for example a delete button.

Row actions
GitHub
ID
AvaThompsonOwnerEngineeringactive22$45,000Jan 2, 2023
0%
LiamNguyenAdminMarketinginactive25$47,137Jan 13, 2023
9%
NoahSilvaEditorDesignpending28$49,274Jan 24, 2023
18%
EmmaCarterViewerSalesactive31$51,411Feb 4, 2023
27%
OliviaRossiOwnerSupportinactive34$53,548Feb 15, 2023
36%
WilliamWalkerAdminEngineeringpending37$55,685Feb 26, 2023
45%
SophiaPatelEditorMarketingactive40$57,822Mar 9, 2023
54%
JamesMullerViewerDesigninactive43$59,959Mar 20, 2023
63%
IsabellaParkOwnerSalespending46$62,096Mar 31, 2023
72%
LucasReyesAdminSupportactive49$64,233Apr 11, 2023
81%
$4,120,536
Rows per page
1–10 of 48

Usage

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  renderRowActions: ({ row }) => (
    <Button
      variant="ghost"
      size="icon"
      onClick={() =>
        setData((prev) => prev.filter((r) => r.id !== row.original.id))
      }
    >
      <RiDeleteBinLine />
      <span className="sr-only">Delete</span>
    </Button>
  ),
})

return <DataTable table={table} />

Combine with editing

Row actions sit alongside editing controls — wire up an edit button here to start row editing programmatically.

As a menu

For a compact kebab menu instead of inline buttons, use renderRowActionMenuItems. It returns the menu items (e.g. DropdownMenuItems) rendered inside an auto-injected dropdown in the actions column. Both slots can be combined — inline controls plus a menu.

import { DropdownMenuItem } from "@/components/ui/dropdown-menu"

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  renderRowActionMenuItems: ({ row, table }) => (
    <>
      <DropdownMenuItem onClick={() => table.cnTable.beginRowEdit(row)}>
        Edit
      </DropdownMenuItem>
      <DropdownMenuItem variant="destructive" onClick={() => remove(row.id)}>
        Delete
      </DropdownMenuItem>
    </>
  ),
})

Positioning the column

The actions column trails the data columns by default. Set positionActionsColumn: "first" to move it to the leading edge.

useDataTable({
  renderRowActions: ({ row }) => <RowMenu row={row} />,
  positionActionsColumn: "first", // "first" | "last"
})