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

@zuilib/table

v0.0.1

Published

Table component for ZUI component library - built on tanstack-react-table.

Readme

@zuilib/table

Data tables for ZUI on @tanstack/react-table v8: sorting, pagination, global search, facet/search column filters, expandable rows, and column helpers.

When to use

  • Tabular data with client-side sort/filter/page
  • Server-driven tables via manualControls + rowCount
  • You already use @zuilib/components for buttons and global styles

Prerequisites

| Package | Version | |---------|---------| | react, react-dom | ^18.0.0 | | @tanstack/react-table | ^8.0.0 | | @zuilib/components | styles + Button in footer |

import '@zuilib/components/styles.css'

Table components use Tailwind classes from core tokens; no separate CSS file in this package.

Installation

pnpm add @zuilib/table @zuilib/components @headlessui/react @tanstack/react-table

Monorepo:

{
  "dependencies": {
    "@zuilib/table": "workspace:*",
    "@zuilib/components": "workspace:*",
    "@tanstack/react-table": "^8.0.0"
  }
}

Import rules

| Rule | Detail | |------|--------| | Default exports | import Table from '@zuilib/table/table' | | Hook | import useTable from '@zuilib/table/use-table' | | Column helpers | Functions like textColumn, not components | | Pass undefined data carefully | useTable uses a stable empty array when data is undefined (e.g. failed fetch) to avoid re-render loops |

Exports

| Subpath | Export | Purpose | |---------|--------|---------| | @zuilib/table/table | Table (default), TableProps | Main grid UI | | @zuilib/table/use-table | useTable (default), TableModel, UseTableOptions | TanStack instance + ZUI helpers | | @zuilib/table/use-table-state | useTableState (default) | Low-level pagination/sort/filter state | | @zuilib/table/table-footer | TableFooter (default) | Pagination controls | | @zuilib/table/table-styles | TableStyles, TableStyleDefaults, TableStyleConfig, Alignment | Style overrides | | @zuilib/table/columns/text-column | textColumn | Single-value column | | @zuilib/table/columns/two-values-column | twoValuesColumn | Primary + secondary stacked cell | | @zuilib/table/cells/date-cell | DateCell | toLocaleDateString() cell renderer | | @zuilib/table/cells/date-time-cell | DateTimeCell | Date + time cell renderer | | @zuilib/table/filters/facet-filter-fn | facetFilterFn | Multi-select facet filter | | @zuilib/table/filters/date-range-filter-fn | dateRangeFilterFn, DateRangeFilter | Start/end date filter | | @zuilib/table/filters/boolean-filter-fn | booleanFilterFn | Exact boolean match |

SimpleTable is internal only — use Table or plain HTML for custom layouts.

Quick start

import { useMemo } from 'react'
import useTable from '@zuilib/table/use-table'
import Table from '@zuilib/table/table'
import TableFooter from '@zuilib/table/table-footer'
import textColumn from '@zuilib/table/columns/text-column'
import '@zuilib/components/styles.css'

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

function UserTable({ users }: { users: User[] }) {
  const columns = useMemo(
    () => [
      textColumn<User>({ key: 'name', header: 'Name' }),
      textColumn<User>({ key: 'email', header: 'Email', enableSorting: false }),
    ],
    []
  )

  const model = useTable(users, columns, { pageSize: 10 })

  return (
    <>
      <Table model={model} loading={false} />
      <TableFooter tableModel={model} />
    </>
  )
}

Core flow

  1. Define ColumnDef[] (helpers or raw TanStack defs).
  2. const model = useTable(data, columns, options).
  3. Render <Table model={model} /> and optionally <TableFooter tableModel={model} />.

TableModel<T> = TanStack Table<T> plus:

  • globalFilter: string
  • resetAllFilters() — clears global filter, column filters, and sorting

useTable

const model = useTable(data, columns, {
  pageSize: 10,
  initialSort: [{ id: 'name', desc: false }],
  columnVisibility: { email: false },
  canRowExpand: (row) => row.original.hasDetails,
  filterFns: { facet: facetFilterFn },
  onStateChange: ({ pagination, sorting, globalFilter, columnFilters }) => {},
  manualControls: true,  // server-side mode
  rowCount: totalFromApi,
})

| Option | Purpose | |--------|---------| | pageSize | Default page size (default 10) | | initialSort | SortingState | | columnVisibility | Hide columns | | canRowExpand | Row expand predicate | | filterFns | Custom filter fns registered on the table | | onStateChange | Sync URL/API when state changes | | manualControls | Sets manualPagination, manualFiltering, manualSorting | | rowCount | Total rows when manual pagination |

Global search: model.setGlobalFilter('query') or bind UI to model.globalFilter. Uses filterFns.includesString.

Table component

<Table
  model={model}
  loading={isLoading}
  loadingMessage="Fetching…"
  error={isError}
  errorMessage={<CustomError />}
  noDataMessage="No users"
  stickyHeaders
  onRowClick={(row) => navigate(row.original.id)}
  rowClassName={(row) => (row.getIsSelected() ? 'bg-muted' : undefined)}
  renderExpandedRow={({ row }) => <DetailPanel data={row.original} />}
  styles={customTableStyles}
/>

| Prop | Type | |------|------| | model | TableModel<T> required | | loading | Shows loading row spanning all columns | | error | Shows error row when not loading | | noDataMessage | Empty state when no rows (and not loading/error) | | renderExpandedRow | Renders below row when expanded | | onRowClick | Row click handler | | rowClassName | Per-row class | | stickyHeaders | Sticky <thead> | | styles | TableStyleConfig partial override |

Column helpers

textColumn

textColumn<Row>({
  key: 'status',           // accessorKey
  header: 'Status',
  cell: (ctx) => <Badge>{ctx.getValue()}</Badge>,  // optional
  enableSorting: true,
  enableFiltering: true,
})

twoValuesColumn

Stacked primary (bold) + secondary (muted) values:

twoValuesColumn<Row>({
  primary: { accessorKey: 'name', header: 'Name' },
  secondary: { accessorKey: 'email', header: '' },
  enableSorting: false,
  filterFn: facetFilterFn,
})

Column meta (header/cell behaviour)

Set on columnDef.meta for built-in header UI:

| meta.type | Behaviour | |-------------|-----------| | 'filter-faceted' | Facet checkbox popover (needs filterFn: facetFilterFn and faceted values) | | 'filter-search' | Column search popover | | 'select-checkbox' | Select-all checkbox header | | align | 'left' \| 'center' \| 'right' on header/cell | | noWrap | true — nowrap cell |

Example facet column:

import { facetFilterFn } from '@zuilib/table/filters/facet-filter-fn'

{
  ...textColumn<Row>({ key: 'status', header: 'Status' }),
  filterFn: facetFilterFn,
  meta: { type: 'filter-faceted' },
}

Register custom filter names in useTable options: filterFns: { facet: facetFilterFn } if using string filterFn ids.

Filter functions

| Export | Filter value shape | |--------|-------------------| | facetFilterFn | unknown[] — row value must be in array | | dateRangeFilterFn | { start?: Date \| string, end?: Date \| string } | | booleanFilterFn | boolean — exact match |

Cell renderers

Use as cell in a column def:

import DateCell from '@zuilib/table/cells/date-cell'
import DateTimeCell from '@zuilib/table/cells/date-time-cell'

textColumn<Row>({
  key: 'createdAt',
  header: 'Created',
  cell: DateCell,
})

TableFooter

<TableFooter tableModel={model} scrollTarget={document.getElementById('table-top')} />

Renders First / Previous / Next / Last using @zuilib/components/button. Returns null when totalPages <= 1.

Styling

import { TableStyleDefaults, type TableStyleConfig } from '@zuilib/table/table-styles'

const styles: TableStyleConfig = {
  header: { base: '...', border: '...' },
  row: { base: '...', hover: '...', selected: '...', clickable: '...' },
  cell: { base: '...' },
  thead: { base: '...', sticky: '...' },
}

<Table model={model} styles={styles} />

Server-side table

const model = useTable(data, columns, {
  manualControls: true,
  rowCount: apiTotal,
  onStateChange: ({ pagination, sorting, columnFilters, globalFilter }) => {
    fetchPage({ pagination, sorting, columnFilters, globalFilter })
  },
})

Pass undefined for data while loading; avoid passing a new [] each render.

Related packages

  • @zuilib/components — required styles; footer buttons
  • @zuilib/form — not required for tables

Build (maintainers)

pnpm --filter @zuilib/table build