Component guideEditable source

Data Table

An editable TanStack Table recipe with filtering, sorting, selection, and pagination.

Original component docs
On this page4 sectionsBack to top

This is an installable recipe with sample payment data, not a generic table component accepting arbitrary data and columns. Copy it, define your row type and columns, then connect application data. Use Table for a simple semantic table without state management.

The row menu copies the payment ID and reports success or failure beside that row. If clipboard access is unavailable, the message displays the ID for manual copying. Customer navigation and payment-detail screens are application responsibilities, not inactive menu entries in this recipe.

Live preview
Loading preview...

#Installation

Complete the base setup. The CLI resolves the dependencies. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/data-table.json

#Usage

import DataTable from "@/components/ui/data-table";

export default function PaymentsExample() {
  return <DataTable />;
}

The default export initially renders the bundled example. Replace its data and columns definitions in the installed file; do not pass unsupported data or columns props to this export.

#API reference

Recipe partPurposeInitial behavior
DataTableDefault exported component without generic propsSample payments
data / columnsRow model and column definitions in sourcePayment schema
sorting / columnFiltersClient sorting and filteringEmpty state
rowSelection / columnVisibilitySelected and hidden rows/columnsEmpty state
useReactTableRow models and state callbacksConfigured locally
getPaginationRowModelClient paginationTanStack default page size

#Accessibility

Preserve semantic table elements, meaningful column headers, and names on row-selection controls. Sorting exposes its direction with aria-sort. Row actions announce their result without depending on a toast provider. Keep empty, loading, and error states distinct. The sample uses payment IDs as stable row IDs; configure your own stable IDs and server state for large or server-paginated datasets. This sample is not a database grid or backend integration.