Black Friday is here 🔥 Get Wensity Pro for 20% less with

Table

A semantic React table with sortable headers, selectable and expandable rows, a sticky header, three densities, and rows that glide into place on sort.

Loading preview

Examples

Practical examples and common states for the same installable component.

Sortable

Click column headers to sort ascending or descending.

examples/table-sortable.tsx
"use client";
import * as React from "react";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/wensity/table";
export function SortableTable() {
const [direction, setDirection] = React.useState<"asc" | "desc">("asc");
return (
<Table>
<TableHeader>
<TableRow>
<TableHead
sortable
sortDirection={direction}
onSort={() => setDirection((d) => (d === "asc" ? "desc" : "asc"))}
>
Customer
</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Northwind Labs</TableCell>
<TableCell>Paid</TableCell>
</TableRow>
</TableBody>
</Table>
);
}

Selectable

Checkbox column with selected row styling.

examples/table-selectable.tsx
"use client";
import * as React from "react";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
TableSelectCell,
} from "@/components/wensity/table";
export function SelectableTable() {
const [selected, setSelected] = React.useState<string[]>([]);
return (
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-10" />
<TableHead>Customer</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow selected={selected.includes("northwind")}>
<TableSelectCell
checked={selected.includes("northwind")}
onCheckedChange={(checked) =>
setSelected(checked ? ["northwind"] : [])
}
/>
<TableCell>Northwind Labs</TableCell>
</TableRow>
</TableBody>
</Table>
);
}

Expandable

Reveal row details with a smooth height transition.

examples/table-expandable.tsx
"use client";
import * as React from "react";
import {
Table,
TableBody,
TableCell,
TableExpandableContent,
TableExpandTriggerCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/wensity/table";
export function ExpandableTable() {
const [open, setOpen] = React.useState(true);
return (
<Table>
<TableHeader>
<TableRow>
<TableHead className="w-10" />
<TableHead>Customer</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow expanded={open}>
<TableExpandTriggerCell expanded={open} onToggle={() => setOpen((v) => !v)} />
<TableCell>Northwind Labs</TableCell>
</TableRow>
<TableExpandableContent open={open} colSpan={2}>
Receipt sent to billing@northwind.dev.
</TableExpandableContent>
</TableBody>
</Table>
);
}

Sticky Header

Keep column labels visible while scrolling long tables.

examples/table-sticky-header.tsx
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/wensity/table";
export function StickyHeaderTable() {
return (
<Table stickyHeader className="max-h-56">
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{/* long list of rows */}
</TableBody>
</Table>
);
}

Overview

Table is a React and Tailwind CSS table component, in Next.js or any React app, made of semantic table, thead, tbody, and th elements with three density settings and an optional sticky header. Sortable headers render a button and set aria-sort, rows can respond to clicks for selection or expansion, and TableSelectCell adds a checkbox that supports a mixed select all state. Turn on animatedSort and rows glide to their new positions when the order changes, unless reduced motion is on. The table shows sort state but never sorts, so reorder rows in your onSort handler or use Data Table.

Installation

Run the following command

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

Usage

Import Table from @/components/wensity/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 {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/wensity/table";
export function TableDemo() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Customer</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Northwind Labs</TableCell>
<TableCell>Paid</TableCell>
</TableRow>
</TableBody>
</Table>
);
}

Props

PropTypeDefaultDescription
stickyHeaderbooleanfalsePins the header row while the body scrolls.
density"compact" | "comfortable" | "spacious""comfortable"Row height and cell padding.
  • 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.

  • 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.

  • 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.

  • 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.