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

dynamic-table-pkg

v0.1.0

Published

A React dynamic table with built-in pagination and Tailwind CSS styling

Readme

dynamic-table-pkg

A modern, highly customizable React dynamic table component with built-in pagination, loading states, and Tailwind CSS styling out of the box.

Features

  • Client-side & Server-side Data: Pass all your data at once, or provide a fetch function for server-side pagination.
  • Built-in Pagination: Includes a complete pagination component with page size selection and ellipsis logic.
  • Tailwind CSS Styling: Beautiful default styles powered by Tailwind CSS, fully responsive.
  • Custom Renderers: Easily customize cell contents with custom render functions.
  • TypeScript Ready: Written in TypeScript with full type definitions exported.

Installation

Install the package via npm, yarn, or pnpm:

npm install dynamic-table-pkg
# or
yarn add dynamic-table-pkg
# or
pnpm add dynamic-table-pkg

Setup

To use the default Tailwind CSS styles, import the CSS file in your application's entry point (e.g., main.tsx, App.tsx, or _app.tsx):

import "dynamic-table-pkg/dist/dynamic-table-pkg.css";

Usage

1. Client-Side Pagination

If you have all the data available locally, simply pass the data array and the component will handle pagination automatically.

TypeScript (TSX)

import React from "react";
import { DynamicTable, Column } from "dynamic-table-pkg";
import "dynamic-table-pkg/dist/dynamic-table-pkg.css";

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

const columns: Column<User>[] = [
  { key: "id", header: "ID" },
  { key: "name", header: "Name" },
  { key: "email", header: "Email" },
  {
    key: "role",
    header: "Role",
    render: (row) => (
      <span className="px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-xs">
        {row.role}
      </span>
    ),
  },
];

const data: User[] = [
  { id: 1, name: "John Doe", email: "[email protected]", role: "Admin" },
  { id: 2, name: "Jane Smith", email: "[email protected]", role: "User" },
  // ... more data
];

export default function App() {
  return (
    <div className="p-8">
      <h1 className="text-2xl font-bold mb-4">Users</h1>
      <DynamicTable
        columns={columns}
        data={data}
        pageSize={5}
        pageSizeOptions={[5, 10, 20]}
      />
    </div>
  );
}

JavaScript (JSX)

import React from "react";
import { DynamicTable } from "dynamic-table-pkg";
import "dynamic-table-pkg/dist/dynamic-table-pkg.css";

const columns = [
  { key: "id", header: "ID" },
  { key: "name", header: "Name" },
  { key: "email", header: "Email" },
  {
    key: "role",
    header: "Role",
    render: (row) => (
      <span className="px-2 py-1 bg-blue-100 text-blue-800 rounded-full text-xs">
        {row.role}
      </span>
    ),
  },
];

const data = [
  { id: 1, name: "John Doe", email: "[email protected]", role: "Admin" },
  { id: 2, name: "Jane Smith", email: "[email protected]", role: "User" },
  // ... more data
];

export default function App() {
  return (
    <div className="p-8">
      <h1 className="text-2xl font-bold mb-4">Users</h1>
      <DynamicTable
        columns={columns}
        data={data}
        pageSize={5}
        pageSizeOptions={[5, 10, 20]}
      />
    </div>
  );
}

2. Server-Side Pagination

For large datasets, use the fetchData prop to load data on demand. The table will automatically display a loading spinner while fetching.

TypeScript (TSX)

import React from "react";
import { DynamicTable, Column } from "dynamic-table-pkg";
import "dynamic-table-pkg/dist/dynamic-table-pkg.css";

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

const columns: Column<Product>[] = [
  { key: "id", header: "Product ID" },
  { key: "title", header: "Title" },
  {
    key: "price",
    header: "Price",
    render: (row) => `$${row.price.toFixed(2)}`,
  },
];

export default function ServerSideTable() {
  const fetchProducts = async (page: number, pageSize: number) => {
    // Replace with your actual API call
    const response = await fetch(
      `/api/products?page=${page}&limit=${pageSize}`
    );
    const data = await response.json();

    return {
      rows: data.items, // The array of data for the current page
      totalCount: data.total, // The total number of items in the database
    };
  };

  return (
    <DynamicTable
      columns={columns}
      fetchData={fetchProducts}
      initialPage={1}
      pageSize={10}
    />
  );
}

JavaScript (JSX)

import React from "react";
import { DynamicTable } from "dynamic-table-pkg";
import "dynamic-table-pkg/dist/dynamic-table-pkg.css";

const columns = [
  { key: "id", header: "Product ID" },
  { key: "title", header: "Title" },
  {
    key: "price",
    header: "Price",
    render: (row) => `$${row.price.toFixed(2)}`,
  },
];

export default function ServerSideTable() {
  const fetchProducts = async (page, pageSize) => {
    // Replace with your actual API call
    const response = await fetch(
      `/api/products?page=${page}&limit=${pageSize}`
    );
    const data = await response.json();

    return {
      rows: data.items, // The array of data for the current page
      totalCount: data.total, // The total number of items in the database
    };
  };

  return (
    <DynamicTable
      columns={columns}
      fetchData={fetchProducts}
      initialPage={1}
      pageSize={10}
    />
  );
}

API Reference

DynamicTableProps

| Prop | Type | Default | Description | | :-------------------- | :------------------------------------------------ | :---------------- | :---------------------------------------------------- | | columns | Column<T>[] | Required | Array of column definitions | | data | T[] | undefined | Array of data for client-side pagination | | fetchData | (page, pageSize) => Promise<{rows, totalCount}> | undefined | Function to fetch data for server-side pagination | | initialPage | number | 1 | The initial active page | | pageSize | number | 10 | The number of rows per page | | pageSizeOptions | number[] | [5, 10, 20, 50] | Available options for the page size dropdown | | loading | boolean | false | Force external loading state (useful for server-side) | | className | string | undefined | Additional CSS classes for the main wrapper | | tableClassName | string | undefined | Additional CSS classes for the <table> element | | paginationClassName | string | undefined | Additional CSS classes for the pagination component | | onPageChange | (page: number) => void | undefined | Callback fired when the page changes | | onPageSizeChange | (size: number) => void | undefined | Callback fired when the page size changes |

Column<T>

| Property | Type | Default | Description | | :--------- | :------------------------------------------- | :----------- | :---------------------------------------------------------------------------------------------- | | key | string | Required | Unique key for the column, typically matching a property in your data object | | header | string | Required | The text to display in the table header | | render | (row: T, index: number) => React.ReactNode | undefined | Custom render function for the cell content | | sortable | boolean | undefined | Flag indicating if the column is sortable (Note: UI for sorting may need custom implementation) |

Customization

The table relies on standard class names that can be targeted for overriding styles. You can also pass custom Tailwind classes through the className, tableClassName, and paginationClassName props.

License

MIT

🎯 Support & Community

If you find this package helpful, please consider supporting its development:

  • Star the Repository - Give it a star on GitHub to show your appreciation
  • 🐛 Report Issues - Found a bug? Open an issue and help improve the package
  • 💡 Feature Requests - Have an idea for a new feature? Submit a feature request
  • 🔧 Contribute - Pull requests are welcome! Fork the repo and submit your improvements
  • 📢 Share - Tell your colleagues and friends about this package

🔔 Follow for More Packages

I regularly build and publish high-quality React components and utility packages. Follow me to stay updated:

💬 Need a Custom Package?

If you have a specific requirement or need a custom React component/package built for your project, feel free to reach out! I'm available for:

  • 🎨 Custom component development
  • 📦 NPM package creation
  • 🔧 Feature additions to existing packages
  • 📚 Technical consulting for React projects

Contact me on LinkedIn: Aarish Jafri - Developer


📊 Package Stats

  • Stars: Show your support by starring the repo
  • 📥 Downloads: Check out npm trends
  • 🔄 Updates: Watch the repo for new releases

If this package saved you time, please give it a ⭐!

Made with ❤️ by Aarish Jafri

GitHub LinkedIn npm