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

@digitaleventsupport/data-table

v0.1.5

Published

A custom data table component built with React, TypeScript, and Tailwind CSS

Downloads

254

Readme

@digitaleventsupport/data-table

A powerful and customizable data table component built with React, TypeScript, TanStack Table, and Tailwind CSS.

Features ✨

  • 🎯 Type-safe - Full TypeScript support
  • 🔄 Sorting - Client-side and server-side sorting
  • 📄 Pagination - Multiple pagination variants
  • 🔍 Filtering - Column filters, search filters, and global search
  • 👁️ Column Visibility - Show/hide columns
  • 📌 Sticky Columns - Pin columns to left or right
  • 🎨 Customizable - Built with Tailwind CSS
  • 🌗 Dark Mode - Built-in dark mode support
  • Performance - Skeleton loading and optimized rendering
  • 🎭 Flexible - Works with both client-side and server-side data

Installation

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

Prerequisites

Your project must have:

  • React 18+
  • Tailwind CSS 3+ configured

Setup

1. Configure Tailwind CSS

Update your tailwind.config.js:

module.exports = {
  presets: [require('@digitaleventsupport/data-table/tailwind')],
  content: [
    './src/**/*.{js,ts,jsx,tsx}',
    './node_modules/@digitaleventsupport/data-table/dist/**/*.{js,mjs}',
  ],
}

2. Import CSS Variables (Optional)

If you don't already have these CSS variables, import them in your app:

import '@digitaleventsupport/data-table/variables.css'

Usage

Basic Example

import { DataTable, Table, useCreateTable } from '@digitaleventsupport/data-table'
import { ColumnDef } from '@tanstack/react-table'

interface User {
  id: number
  name: string
  email: string
  role: string
}

const columns: ColumnDef<User>[] = [
  {
    accessorKey: 'name',
    header: 'Name',
  },
  {
    accessorKey: 'email',
    header: 'Email',
  },
  {
    accessorKey: 'role',
    header: 'Role',
  },
]

function UsersTable() {
  const data: User[] = [
    { id: 1, name: 'John Doe', email: '[email protected]', role: 'Admin' },
    { id: 2, name: 'Jane Smith', email: '[email protected]', role: 'User' },
  ]

  const table = useCreateTable({
    data,
    columns,
  })

  return (
    <DataTable table={table}>
      <Table />
    </DataTable>
  )
}

With Pagination and Controls

import { 
  DataTable, 
  Table, 
  Pagination,
  PageSize,
  PageCount,
  ColumnVisibility,
  useCreateTable 
} from '@digitaleventsupport/data-table'

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

  const table = useCreateTable({
    data,
    columns,
    options: {
      pagination: {
        state: pagination,
        onChange: setPagination,
      },
    },
  })

  return (
    <DataTable table={table}>
      <div className="flex items-center justify-between mb-4">
        <ColumnVisibility />
        <PageSize range={[10, 20, 50, 100]} />
      </div>
      
      <Table />
      
      <div className="flex items-center justify-between mt-4">
        <PageCount />
        <Pagination variant="simple" />
      </div>
    </DataTable>
  )
}

With Filters

import { 
  DataTable, 
  Table,
  GlobalSearchFilter,
  ColumnFilters,
  ClearFilters,
  useCreateTable 
} from '@digitaleventsupport/data-table'

function UsersTable() {
  const [columnFilters, setColumnFilters] = useState([])
  const [globalFilter, setGlobalFilter] = useState('')

  const table = useCreateTable({
    data,
    columns,
    options: {
      columnFilters: {
        state: columnFilters,
        onChange: setColumnFilters,
      },
      globalFiltering: {
        state: globalFilter,
        onChange: setGlobalFilter,
      },
    },
  })

  return (
    <DataTable table={table}>
      <div className="flex gap-2 mb-4">
        <GlobalSearchFilter placeholder="Search..." debounce={300} />
        <ColumnFilters />
        <ClearFilters />
      </div>
      
      <Table />
    </DataTable>
  )
}

Server-Side Data

function UsersTable() {
  const [sorting, setSorting] = useState([])
  const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 10 })

  const { data, isLoading, isFetching } = useQuery({
    queryKey: ['users', sorting, pagination],
    queryFn: () => fetchUsers({ sorting, pagination }),
  })

  const table = useCreateTable({
    data: data?.users ?? [],
    columns,
    options: {
      sorting: {
        manualSorting: true,
        state: sorting,
        onChange: setSorting,
      },
      pagination: {
        manualPagination: true,
        state: pagination,
        onChange: setPagination,
        rowCount: data?.totalCount ?? 0,
      },
      isLoading,
      isFetching,
    },
  })

  return (
    <DataTable table={table}>
      <Table />
      <Pagination variant="full" />
    </DataTable>
  )
}

Components

Core Components

  • DataTable - Provider component that wraps all table-related components
  • Table - The main table component with sorting, filtering, and sticky columns support

Control Components

  • ColumnVisibility - Toggle column visibility
  • PageCount - Display current page info
  • PageSize - Select rows per page
  • Pagination - Navigate pages (variants: minimal, icons, simple, full)

Filter Components

  • GlobalSearchFilter - Search across all columns
  • ColumnFilters - Multi-select column filters
  • ColumnSearchFilter - Individual column search (auto-rendered in headers)
  • ClearFilters - Clear all active filters

Hooks

  • useCreateTable - Create a TanStack Table instance
  • useTable - Access table context
  • useSerializedColumnFilters - Serialize filters for API calls

Column Configuration

import { ColumnDef } from '@tanstack/react-table'

const columns: ColumnDef<User>[] = [
  {
    accessorKey: 'name',
    header: 'Name',
    enableSorting: true,
    enableHiding: true,
    enableGlobalFilter: true, // Enable for global search
    meta: {
      label: 'Full Name', // Display name
      columnFilter: [
        {
          type: 'search', // Add search filter in header
        },
      ],
    },
  },
  {
    accessorKey: 'status',
    header: 'Status',
    meta: {
      label: 'Status',
      columnFilter: [
        {
          type: 'multi-select',
          icon: CheckCircle,
          values: [
            { label: 'Active', value: 'active' },
            { label: 'Inactive', value: 'inactive' },
          ],
        },
      ],
    },
  },
]

API Reference

Full API documentation with examples is available in the source code JSDoc comments.

TypeScript

This package is written in TypeScript and provides full type safety:

import type { TableContext, ColumnDefFilter } from '@digitaleventsupport/data-table'

Styling

The package uses Tailwind CSS and CSS variables for theming. You can override the default theme by defining your own CSS variables:

:root {
  --border: 220 13% 91%;
  --radius: 0.75rem;
  /* ... other variables */
}

License

MIT

Contributing

Contributions are welcome! This package is built with best practices in mind and follows TypeScript and React conventions.