Data Table

A React data table with debounced search, sorting, row selection, pagination, and expandable rows from one columns array, without TanStack.

Loading preview

Examples

Practical examples and common states for the same installable component.

Sortable

Click column headers to sort rows ascending or descending.

examples/data-table-sortable.tsx
"use client";
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type Invoice = {
id: string;
customer: string;
plan: string;
amount: string;
status: string;
};
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", accessorKey: "customer", sortable: true },
{ id: "plan", header: "Plan", accessorKey: "plan", sortable: true },
{ id: "amount", header: "Amount", accessorKey: "amount", sortable: true },
{ id: "status", header: "Status", accessorKey: "status", sortable: true },
];
export function SortableDataTable({ data }: { data: Invoice[] }) {
return <DataTable columns={columns} data={data} sortable />;
}

Filterable

Built-in search bar filters across all columns with debounced input.

examples/data-table-filterable.tsx
"use client";
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type Invoice = {
id: string;
customer: string;
plan: string;
status: string;
};
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", accessorKey: "customer" },
{ id: "plan", header: "Plan", accessorKey: "plan" },
{ id: "status", header: "Status", accessorKey: "status" },
];
export function FilterableDataTable({ data }: { data: Invoice[] }) {
return (
<DataTable
columns={columns}
data={data}
filterable={{ placeholder: "Search invoices…" }}
/>
);
}

Selectable

Checkbox column with select-all and individual row selection.

examples/data-table-selectable.tsx
"use client";
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type User = {
id: string;
name: string;
role: string;
};
const columns: DataTableColumn<User>[] = [
{ id: "name", header: "Name", accessorKey: "name" },
{ id: "role", header: "Role", accessorKey: "role" },
];
export function SelectableDataTable({ data }: { data: User[] }) {
return <DataTable columns={columns} data={data} selectable />;
}

Paginated

Splits large datasets across pages with compact pagination controls.

examples/data-table-paginated.tsx
"use client";
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type Invoice = {
id: string;
customer: string;
plan: string;
amount: string;
status: string;
};
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", accessorKey: "customer", sortable: true },
{ id: "plan", header: "Plan", accessorKey: "plan" },
{ id: "amount", header: "Amount", accessorKey: "amount", sortable: true },
{ id: "status", header: "Status", accessorKey: "status" },
];
export function PaginatedDataTable({ data }: { data: Invoice[] }) {
return (
<DataTable
columns={columns}
data={data}
sortable
paginated={{ pageSize: 5 }}
/>
);
}

Expandable

Click any row to reveal additional details in an expandable panel.

examples/data-table-expandable.tsx
"use client";
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type Invoice = {
id: string;
customer: string;
plan: string;
status: string;
detail: string;
};
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", accessorKey: "customer" },
{ id: "plan", header: "Plan", accessorKey: "plan" },
{ id: "status", header: "Status", accessorKey: "status" },
];
export function ExpandableDataTable({ data }: { data: Invoice[] }) {
return (
<DataTable
columns={columns}
data={data}
expandable={{
renderExpanded: (row) => (
<div className="text-xs text-muted-foreground">
<p><strong>ID:</strong> {row.id}</p>
<p>{row.detail}</p>
</div>
),
}}
/>
);
}

Overview

Data Table is a React and Tailwind CSS data table, in Next.js or any React app, that takes columns and a data array and handles search, sorting, selection, pagination, and expandable rows for you, with no TanStack dependency. The search box waits 240 milliseconds before filtering across accessor columns or the keys you list, header clicks cycle ascending, descending, and off with number aware ordering, and select all covers the current page. Pagination defaults to 10 rows with a range and total under the table. Rows need an id field or a getRowId function, or selection cannot tell them apart.

Installation

Run the following command

~/your-project
pnpm dlx wensity@latest add data-table

Usage

Import DataTable from @/components/wensity/data-table and render it anywhere in your React or Next.js app. The source lands in your own repo, so every prop, class and animation below is yours to edit.

app/example.tsx
import {
DataTable,
type DataTableColumn,
} from "@/components/wensity/data-table";
type Invoice = {
id: string;
customer: string;
status: string;
};
const columns: DataTableColumn<Invoice>[] = [
{ id: "customer", header: "Customer", accessorKey: "customer", sortable: true },
{ id: "status", header: "Status", accessorKey: "status", sortable: true },
];
const data: Invoice[] = [
{ id: "1", customer: "Northwind Labs", status: "Paid" },
{ id: "2", customer: "Orbit Systems", status: "Pending" },
];
export function InvoicesTable() {
return (
<DataTable
columns={columns}
data={data}
sortable
filterable
paginated
/>
);
}

Props

PropTypeDefaultDescription
columnsDataTableColumn<TData>[]-Column definitions. Required.
dataTData[]-Row data. Required.
getRowId(row: TData) => string-Unique row key. Defaults to row.id as a string.
sortablebooleanfalseEnables sorting on any column marked sortable.
filterableboolean | DataTableFilterConfigfalseEnables search. Pass a config object to customise it.
selectableboolean | DataTableSelectableConfig<TData>falseEnables checkbox row selection. Pass a config object for controlled mode.
paginatedboolean | DataTablePaginationConfigfalseEnables pagination. Defaults to 10 rows per page.
expandableboolean | DataTableExpandableConfig<TData>falseEnables expandable rows. Pass a config with renderExpanded.
density"compact" | "comfortable" | "spacious""comfortable"Row height and cell padding.
stickyHeaderbooleanfalsePins the header row while the body scrolls.
emptyStateReact.ReactNode-Shown when no rows match the current filters.
captionstring-Caption rendered below the table.
  • KPI Card with Sparkline component preview

    KPI Card with Sparkline

    Dashboard KPI cards with a smooth SVG sparkline chart and a glowing dot that snaps to whichever value you scrub across.

  • Fluid Drag-and-Drop Kanban component preview

    Fluid Drag-and-Drop Kanban

    A Trello-grade board running real pointer physics, where every card tilts toward the velocity you throw it across at.

  • GitHub-Style Activity Grid component preview

    GitHub-Style Activity Grid

    365 squares sharing one tooltip that flies between days on rails, with a reveal that ripples backward from today.

  • Bento Grid Layout component preview

    Bento Grid Layout

    A responsive bento grid of dashboard tiles where clicking one moves it to the front and the rest glide into place.