Data Table

PreviousNext

Modern SaaS data table with TanStack Table, inset-card layout, selection, sorting, search, pagination, and expandable rows.

StatusConfidenceAssignee
ResearcherRunning
94%
Ana Silva
Proposal DrafterIdle
87%
Marina CostaLucas RochaJL+2
Data ExtractorError
61
AG
UX ReviewerRunning
91%
Pedro MartinsMateus DiasCarlos Freitas
ComposerRunning
88%
Laura MendesFelipe SouzaNR+1
Code ReviewerScheduled
96%
Bruno LopesGustavo LimaDiego Nunes+3

SHOWING: 6 of 35 items

1/1

Installation

pnpm dlx shadcn@latest add https://matos-ui.com/r/data-table.json

Usage

import type { ColumnDef } from "@tanstack/react-table"
import {
  DataTable,
  DataTableBadge,
  DataTableColumnHeader
} from "@/components/matos-ui/data-table"
import { BriefcaseBusiness, Building2, Hash, Mail } from "lucide-react"
type Employee = {
  id: string
  department: "Finance" | "HR" | "Marketing" | "Sales" | "Engineering"
  email: string
  employment: "Active" | "Inactive"
  firstName: string
  lastName: string
}

const columns: ColumnDef<Employee>[] = [
  {
    accessorKey: "id",
    header: ({ column }) => (
      <DataTableColumnHeader
        column={column}
        title="ID"
        icon={<Hash aria-hidden="true" />}
      />
    )
  },
  {
    accessorKey: "department",
    header: ({ column }) => (
      <DataTableColumnHeader
        column={column}
        title="Department"
        icon={<Building2 aria-hidden="true" />}
      />
    ),
    cell: ({ row }) => (
      <DataTableBadge tone="engineering">
        {row.getValue("department")}
      </DataTableBadge>
    )
  },
  {
    accessorKey: "email",
    header: ({ column }) => (
      <DataTableColumnHeader
        column={column}
        title="Email"
        icon={<Mail aria-hidden="true" />}
      />
    )
  },
  {
    accessorKey: "employment",
    header: ({ column }) => (
      <DataTableColumnHeader
        column={column}
        title="Employment"
        icon={<BriefcaseBusiness aria-hidden="true" />}
      />
    )
  }
]
<DataTable
  data={employees}
  columns={columns}
/>

Reference

DataTable Props

PropTypeDefaultDescription
dataTData[]-Records rendered by TanStack Table.
columnsColumnDef<TData, TValue>[]-Column definitions passed to TanStack Table.
titlestring?-Loose header title.
descriptionstring?-Loose header description.
searchKeystring?-Column id/accessor key used by the search input.
searchPlaceholderstring?"Search records..."Placeholder for the search input.
pageSizenumber?10Initial page size.
pageSizeOptionsnumber[]?[5, 10, 20, 50]Options shown in the rows-per-page select.
loadingboolean?falseShows table skeleton rows.
emptyTitlestring?"No records found"Empty state title.
emptyDescriptionstring?"Try adjusting..."Empty state description.
toolbarActionsReactNode?-Optional actions rendered beside search.
getRowState(row: TData) => DataTableRowState | undefinedInferred from row fieldsControls inactive/deleted row visuals.

Row State

DataTable can infer row state from deleted, disabled, inactive, status, or employment fields. You can override this with getRowState.

StateVisual treatment
"default"Normal row with subtle hover.
"inactive"Reduced opacity and muted text.
"deleted"Reduced opacity plus a soft diagonal stripe fill.

Exports

Also exported: DataTableToolbar, DataTablePagination, DataTableEmpty, DataTableBadge, DataTableColumnHeader, DataTableRowState, and the semantic table primitives Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, and TableCaption.