Data Table

React data table with sortable columns, row selection, a floating bulk actions bar, hover row actions, sticky header, three densities and skeleton loading.

src/registry/ui/data-table.tsx/r/data-table.json
Invoices
Actions
NL

Northwind Labs

billing@northwind.io

INV-2041PaidSep 24$12,400
AR

Acme Robotics

ap@acme.dev

INV-2040PendingSep 22$3,890
G

Globex

finance@globex.com

INV-2039OverdueSep 12$890
I

Initech

peter@initech.co

INV-2038PaidSep 10$5,200
UH

Umbrella Health

ops@umbrella.health

INV-2037PaidSep 8$21,750
H

Hooli

gavin@hooli.xyz

INV-2036RefundedSep 3$1,450
SI

Stark Industrial

pepper@stark.io

INV-2035PendingAug 29$9,980
WF

Wayne Freight

lucius@wayne.co

INV-2034PaidAug 27$6,300

Sort, select, hover a row

Installation#

bash
npx shadcn@latest add @minidev/data-table

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/data-table.json

Usage#

tsx
import { DataTable } from "@/components/ui/data-table"

export function Example() {
  return (
    <DataTable
      data={filtered}
      columns={[
        { id: "name", header: "Name", sortValue: (r) => r.name, cell: (r) => r.name },
        { id: "plan", header: "Plan", cell: (r) => r.plan },
        { id: "status", header: "Status", cell: (r) => (
          <StatusBadge tone={r.status === "active" ? "success" : r.status === "past_due" ? "danger" : "warning"}>{r.status}</StatusBadge>
        ) },
      ]}
    />
  )
}

API reference#

DataTable props
PropTypeDefault
columnsColumn<T>[]SAMPLE_COLUMNS
dataT[]SAMPLE_ROWS
getRowId(row: T, index: number) => string(_r, i) => String(i)
selectableboolean-
selectedstring[]-
onSelectedChange(ids: string[]) => void-
bulkActions(ids: string[]) => React.ReactNode-
rowActions(row: T) => React.ReactNode-
onRowClick(row: T) => void-
defaultSortSortnull
densityDensity"default"
loadingboolean-
maxHeightnumber | string-
emptyReact.ReactNode-
captionstring-
classNamestring-

Dependencies#

npm

lucide-react

Built from

Examples#

All data table components

Learn more