Reusable data table with loading and empty states.
import { DataTable } from "@/components/ui";| Name | Role | |
|---|---|---|
| Alice Johnson | alice@example.com | Admin |
| Bob Smith | bob@example.com | Editor |
| Carol Williams | carol@example.com | Viewer |
const columns = [
{ key: "name", header: "Name" },
{ key: "email", header: "Email" },
{ key: "role", header: "Role" },
];
const data = [
{ id: 1, name: "John Doe", email: "john@example.com", role: "Admin" },
{ id: 2, name: "Jane Smith", email: "jane@example.com", role: "User" },
];
return <DataTable columns={columns} data={data} />;Show loading state
<DataTable columns={columns} data={data} loading={isLoading}/>Custom empty message
<DataTable columns={columns} data={[]} emptyMessage="No users found. Create your first user to get started."/>Render custom cell content
const columns = [ { key: "name", header: "Name" }, { key: "status", header: "Status", render: (row) => ( <StatusBadge status={row.status} label={row.statusLabel} /> ), }, { key: "actions", header: "", render: (row) => ( <DropdownMenu trigger={<IconButton icon="MoreVertical" label="Actions" />} items={[ { type: "item", label: "Edit", onClick: () => handleEdit(row) }, { type: "item", label: "Delete", destructive: true }, ]} /> ), },];Configure your app with the features you need and download production-ready code.
Start Configuring