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

@laterinc/data-table

v0.3.0

Published

Complete data table solution with shadcn/ui and TanStack Table

Readme

@laterinc/data-table

A comprehensive, production-ready data table solution built on TanStack Table and shadcn/ui. This package provides everything you need to build powerful, feature-rich data tables with minimal setup.

✨ Features

  • 🎯 Zero Config: Works out of the box with sensible defaults
  • 🔧 Fully Customizable: Extensive customization options for advanced use cases
  • 📦 All-in-One: Includes TanStack Table, shadcn/ui components, and custom hooks
  • 🎨 Beautiful UI: Pre-styled components based on shadcn/ui
  • ⚡ Performance: Built with React best practices and optimized for performance
  • 🔍 Rich Filtering: Column filters, global search, faceted filters
  • 📊 Sorting: Multi-column sorting support
  • ✅ Row Selection: Single and multi-row selection
  • 📄 Pagination: Client-side and server-side pagination
  • 👁️ Column Visibility: Toggle column visibility
  • 🎛️ Bulk Actions: Perform actions on multiple rows
  • 📱 Responsive: Mobile-friendly design
  • 🎭 TypeScript: Fully typed for better DX

📦 Installation

npm install @laterinc/data-table
# or
pnpm add @laterinc/data-table
# or
yarn add @laterinc/data-table

Peer Dependencies

This package requires React 18+ or 19+:

npm install react react-dom

🚀 Quick Start

Basic Example

import {
  useDataTable,
  DataTable,
  DataTablePagination,
  DataTableColumnHeader,
  Checkbox,
  type ColumnDef,
} from '@laterinc/data-table';
import '@laterinc/data-table/styles';

type User = {
  id: string;
  name: string;
  email: string;
  role: string;
};

const columns: ColumnDef<User>[] = [
  {
    id: 'select',
    header: ({ table }) => (
      <Checkbox
        checked={table.getIsAllPageRowsSelected()}
        onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
      />
    ),
    cell: ({ row }) => (
      <Checkbox
        checked={row.getIsSelected()}
        onCheckedChange={(value) => row.toggleSelected(!!value)}
      />
    ),
  },
  {
    accessorKey: 'name',
    header: ({ column }) => <DataTableColumnHeader column={column} title="Name" />,
  },
  {
    accessorKey: 'email',
    header: 'Email',
  },
  {
    accessorKey: 'role',
    header: 'Role',
  },
];

function UsersTable({ data }: { data: User[] }) {
  const { table } = useDataTable({
    columns,
    data,
    enableRowSelection: true,
    enableSorting: true,
    enablePagination: true,
  });

  return (
    <div className="space-y-4">
      <DataTable table={table} />
      <DataTablePagination table={table} />
    </div>
  );
}

Advanced Example with Filters and Bulk Actions

import {
  useDataTable,
  DataTable,
  DataTablePagination,
  DataTableFacetedFilter,
  DataTableBulkActions,
  Input,
  type BulkActionDefinition,
} from '@laterinc/data-table';
import { Trash2, Mail } from 'lucide-react';

function AdvancedTable({ data }: { data: User[] }) {
  const { table, rowSelection, resetSelection } = useDataTable({
    columns,
    data,
    enableRowSelection: true,
    enableSorting: true,
    enableFiltering: true,
    enablePagination: true,
    pageSize: 20,
  });

  const bulkActions: BulkActionDefinition<User>[] = [
    {
      label: 'Send Email',
      icon: Mail,
      onClick: (rows) => {
        console.log('Sending email to', rows.length, 'users');
        resetSelection();
      },
    },
    {
      label: 'Delete',
      icon: Trash2,
      variant: 'destructive',
      onClick: (rows) => {
        console.log('Deleting', rows.length, 'users');
        resetSelection();
      },
    },
  ];

  const selectedCount = Object.keys(rowSelection).length;
  const selectedRows = table.getFilteredSelectedRowModel().rows;

  return (
    <div className="space-y-4">
      {/* Search */}
      <Input
        placeholder="Search users..."
        value={(table.getColumn('name')?.getFilterValue() as string) ?? ''}
        onChange={(e) => table.getColumn('name')?.setFilterValue(e.target.value)}
      />

      {/* Filters */}
      <div className="flex gap-2">
        <DataTableFacetedFilter
          column={table.getColumn('role')}
          title="Role"
          options={[
            { label: 'Admin', value: 'admin' },
            { label: 'User', value: 'user' },
          ]}
        />
      </div>

      {/* Bulk Actions */}
      {selectedCount > 0 && (
        <DataTableBulkActions
          selectedCount={selectedCount}
          actions={bulkActions}
          selectedRows={selectedRows}
        />
      )}

      {/* Table */}
      <DataTable table={table} />
      <DataTablePagination table={table} />
    </div>
  );
}

📚 API Reference

Hooks

useDataTable

The main hook for creating a table instance with all features enabled.

const {
  table,              // TanStack Table instance
  rowSelection,       // Current row selection state
  sorting,            // Current sorting state
  columnFilters,      // Current filter state
  columnVisibility,   // Current visibility state
  pagination,         // Current pagination state
  resetSelection,     // Reset row selection
  resetFilters,       // Reset all filters
  resetSorting,       // Reset sorting
  resetPagination,    // Reset pagination
  resetAll,           // Reset everything
} = useDataTable({
  columns,            // Column definitions
  data,               // Data array
  enableRowSelection: true,
  enableSorting: true,
  enableFiltering: true,
  enablePagination: true,
  pageSize: 10,
  // ... more options
});

useServerDataTable

Hook for server-side data tables with manual pagination/sorting/filtering.

const { table, ... } = useServerDataTable({
  columns,
  data,
  rowCount: totalItems, // Total number of items from server
});

Components

DataTable

Main table component that renders the table UI.

<DataTable
  table={table}
  isLoading={false}
  emptyState={<CustomEmptyState />}
  loadingState={<CustomLoadingState />}
  stickyHeader={false}
  getRowClassName={(row) => row.isHighlighted ? 'bg-yellow-50' : ''}
/>

DataTablePagination

Pagination controls with page size selector.

<DataTablePagination table={table} />

DataTableToolbar

Customizable toolbar for filters and actions.

<DataTableToolbar table={table}>
  {/* Your custom toolbar content */}
</DataTableToolbar>

DataTableFacetedFilter

Multi-select filter for categorical columns.

<DataTableFacetedFilter
  column={table.getColumn('status')}
  title="Status"
  options={[
    { label: 'Active', value: 'active' },
    { label: 'Inactive', value: 'inactive' },
  ]}
/>

DataTableColumnHeader

Sortable column header with sort indicators.

<DataTableColumnHeader column={column} title="Name" />

DataTableViewOptions

Column visibility toggle dropdown.

<DataTableViewOptions table={table} />

DataTableBulkActions

Bulk action buttons for selected rows.

<DataTableBulkActions
  selectedCount={selectedCount}
  selectedRows={selectedRows}
  actions={[
    {
      label: 'Delete',
      icon: Trash2,
      variant: 'destructive',
      onClick: (rows) => handleDelete(rows),
    },
  ]}
/>

Re-exported from TanStack Table

For convenience, all TanStack Table exports are re-exported:

import {
  useReactTable,
  getCoreRowModel,
  getSortedRowModel,
  getFilteredRowModel,
  getPaginationRowModel,
  flexRender,
  type ColumnDef,
  type Table,
  type Row,
  // ... and more
} from '@laterinc/data-table';

shadcn/ui Components

All necessary shadcn/ui components are included:

import {
  Button,
  Checkbox,
  Input,
  Select,
  Badge,
  Table,
  DropdownMenu,
  Popover,
  Command,
  Tooltip,
  Dialog,
  Separator,
} from '@laterinc/data-table';

🎨 Styling

Import the base styles in your root component:

import '@laterinc/data-table/styles';

The package uses Tailwind CSS. Make sure you have Tailwind configured in your project and include the package in your tailwind.config.js:

module.exports = {
  content: [
    './src/**/*.{js,ts,jsx,tsx}',
    './node_modules/@laterinc/data-table/**/*.{js,ts,jsx,tsx}',
  ],
  // ... rest of your config
};

🔧 TypeScript

The package is fully typed. All types are exported for your convenience:

import type {
  ColumnDef,
  Table,
  Row,
  FilterOption,
  BulkActionDefinition,
  UseDataTableOptions,
} from '@laterinc/data-table';

📖 Examples

Check out the /stories directory for more comprehensive examples:

  • Basic table with selection
  • Advanced table with filtering
  • Server-side pagination
  • Custom renderers
  • Bulk actions
  • And more!

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT © LaterInc

🙏 Credits

Built with: