npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@tmzm/react-data-table

v1.0.0

Published

A modern, fully type-safe React data table built on top of @tanstack/react-table.

Readme

@tmzm/react-data-table

A modern, fully type-safe React data table built on @tanstack/react-table, with sorting, pagination, row selection, and Radix UI primitives.

Installation

pnpm add @tmzm/react-data-table @tanstack/react-table react react-dom

Or with npm / yarn:

npm install @tmzm/react-data-table @tanstack/react-table react react-dom

Peer dependencies: React 19+, @tanstack/react-table, @radix-ui/react-checkbox, @radix-ui/react-select, lucide-react (included as dependencies of this package).

Quick start

  1. Import the component and styles
import { DataTable } from "@tmzm/react-data-table";
import "@tmzm/react-data-table/styles.css";
  1. Define columns using TanStack Table’s ColumnDef:
import type { ColumnDef } from "@tanstack/react-table";

interface User {
  id: string;
  name: string;
  email: string;
}

const columns: ColumnDef<User>[] = [
  {
    accessorKey: "name",
    header: "Name",
    enableSorting: true,
  },
  {
    accessorKey: "email",
    header: "Email",
    enableSorting: true,
  },
];
  1. Control pagination with pagination and onPaginationChange (required):
const [pagination, setPagination] = useState({
  pageIndex: 0,
  pageSize: 10,
});

<DataTable<User>
  data={users}
  columns={columns}
  pagination={pagination}
  onPaginationChange={setPagination}
/>

Basic example

import { useState } from "react";
import { DataTable } from "@tmzm/react-data-table";
import type { ColumnDef } from "@tanstack/react-table";
import "@tmzm/react-data-table/styles.css";

interface Product {
  id: string;
  name: string;
  price: number;
}

const columns: ColumnDef<Product>[] = [
  { accessorKey: "name", header: "Product", enableSorting: true },
  {
    accessorKey: "price",
    header: "Price",
    enableSorting: true,
    cell: ({ getValue }) => `$${getValue<number>().toFixed(2)}`,
  },
];

const products: Product[] = [
  { id: "1", name: "Widget", price: 9.99 },
  { id: "2", name: "Gadget", price: 24.99 },
];

export function ProductTable() {
  const [pagination, setPagination] = useState({
    pageIndex: 0,
    pageSize: 10,
  });

  return (
    <DataTable<Product>
      data={products}
      columns={columns}
      pagination={pagination}
      onPaginationChange={setPagination}
    />
  );
}

Features

Sorting

  • Set enableSorting: true on columns that should be sortable.
  • Use client-side sorting (default): no extra props needed.
  • Use server-side sorting: pass sorting, onSortingChange, and paginationOptions={{ manualSorting: true }}. Send sorting to your API and pass back sorted data.
const [sorting, setSorting] = useState<SortingState>([]);

<DataTable<User>
  data={users}
  columns={columns}
  pagination={pagination}
  onPaginationChange={setPagination}
  sorting={sorting}
  onSortingChange={setSorting}
  paginationOptions={{ manualSorting: true }}
/>

Row selection

  • selectable={true} enables checkboxes and a header “select all”.
  • Control selected rows with selection and onSelectionChange.
  • Use getSelectionKey to identify rows (default: row => row?.id ?? "").
  • Use enableRowSelection: true | false | (row) => boolean to allow or disable selection per row.
const [selected, setSelected] = useState<User[]>([]);

<DataTable<User>
  data={users}
  columns={columns}
  pagination={pagination}
  onPaginationChange={setPagination}
  selectable
  selection={selected}
  onSelectionChange={setSelected}
  getSelectionKey={(row) => row.id}
/>

With manual pagination, selection can span pages; use paginationOptions.resetSelection to clear selection when the page changes.

Pagination options

| Option | Type | Description | |----------------------|-----------|-----------------------------------------------------------------------------| | manualPagination | boolean | You control total row count and pages; pass rowCount and fetch by page. | | manualSorting | boolean | You handle sorting (e.g. server-side); use with sorting / onSortingChange. | | resetSelection | boolean | Clear selection when pagination changes. | | selectLabel | string | Label for the “rows per page” select (default: "Rows per page"). |

Manual pagination example:

const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 });
const { data, totalCount } = useFetchUsers(pagination);

<DataTable<User>
  data={data}
  columns={columns}
  pagination={pagination}
  onPaginationChange={setPagination}
  rowCount={totalCount}
  paginationOptions={{ manualPagination: true }}
/>

Other props

| Prop | Type | Description | |--------------------|-------------------------|----------------------------------------------------------| | hidePagination | boolean | Hide pagination controls. | | loading | boolean | Show skeleton rows. | | striped | boolean | Alternate row background. | | placeholder | ReactNode | Custom content when there are no rows. | | placeholderText | string | Default empty state text (default: "No data found"). | | size | "default" \| "sm" | Row/cell size. |

You can also pass any valid div props (e.g. className, style) and they are forwarded to the table wrapper.

Type exports

Re-exported from @tanstack/react-table for convenience:

  • DataTableColumnDef — same as ColumnDef
  • DataTableSortingState — same as SortingState
  • DataTablePaginationState — same as PaginationState
import type {
  DataTableColumnDef,
  DataTableSortingState,
  DataTablePaginationState,
} from "@tmzm/react-data-table";

License

ISC