Skip to content

Rqdhw3ns/react-data-table

Repository files navigation

@rqdhw3n/react-data-table

Reusable React data table with search, sort, pagination, row expansion, and CSV export.

Install (monorepo / local)

From the app root:

cd react-data-table && npm install && npm run build

Link in bldrx-client-frontend/package.json:

"@rqdhw3n/react-data-table": "file:./react-data-table"

Usage

import { DataTable, exportDataTableToCsv, type Column } from '@rqdhw3n/react-data-table'

type Product = { id: string; name: string; price: number }

const columns: Column<Product>[] = [
  { id: 'name', header: 'Name', accessor: 'name' },
  { id: 'price', header: 'Price', accessor: 'price' },
]

<DataTable
  columns={columns}
  data={products}
  btnLabel='Export'
  exportCsv={{ fileName: 'products.csv', scope: 'all' }}
/>

CSV export

Mode Behavior
Built-in Set btnLabel without onExportClick — downloads filtered/sorted data as CSV
Custom Pass onExportClick for API-backed export (e.g. server-generated CSV)
Utility exportDataTableToCsv(columns, rows, 'file.csv') anywhere in your app

exportCsv.scope:

  • all (default) — full processed dataset (filtered + sorted)
  • page — current page only

API pagination

<DataTable
  columns={columns}
  data={pageRows}
  isFrontEndPagination
  paginationMeta={{ totalCount, currentPage, totalPages, pageSize }}
  onPageChange={setPage}
  onLimitChange={setLimit}
  onSearchChange={setSearch}
  onSortChange={(sortBy, sortOrder) => { /* ... */ }}
/>

Action menus in cells

import { TableActionMenu } from '@rqdhw3n/react-data-table'

Peer dependencies

  • react >= 18
  • react-dom >= 18
  • lucide-react >= 0.400

Scripts

npm run build    # ESM + CJS + types
npm test
npm run typecheck

Styling

Styles are injected automatically when you import the package (no Tailwind required).

In DevTools you should see:

  • classes like rdt, rdt__table, rdt__btn on elements
  • a <style id="rdt-styles"> tag in <head>

Optional overrides via CSS variables on .rdt:

.rdt {
  --rdt-primary: #7c3aed;
  --rdt-font: 'Inter', sans-serif;
}

Fallback (if styles don't load):

import '@rqdhw3n/react-data-table/styles.css'

About

A modern, reusable, and fully customizable DataTable component for React built with TypeScript and Tailwind CSS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors