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 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-datatable-library

v1.0.6

Published

A lightweight and efficient React DataTable component.

Readme

react-datatable-library npm version

A lightweight and efficient React DataTable component built with Material UI (MUI) and TypeScript. It provides built-in pagination, sorting, and filtering, fully leveraging Material UI's design system.

Installation

npm install react-datatable-library

or

yarn add react-datatable-library

Prerequisites

Make sure you have the following prerequisites installed:

  • Node.js: >= 14.0.0
  • Yarn: >= 1.22.0

Peer Dependencies

Make sure you have the following dependencies installed in your project:

{
  "peerDependencies": {
    "@mui/material": "^5.0.0",
    "@emotion/react": "^11.0.0",
    "@emotion/styled": "^11.0.0",
    "react": "^19.0.0",
    "react-dom": "^19.0.0"
  }
}

Usage

Basic Example

import React from 'react'
import { DataTable } from 'react-datatable-library'

const data = [
  { id: 1, name: 'Alice', age: 25 },
  { id: 2, name: 'Bob', age: 30 },
  { id: 3, name: 'Charlie', age: 35 },
]

const columns = [
  { title: 'ID', dataIndex: 'id' },
  { title: 'Name', dataIndex: 'name' },
  { title: 'Age', dataIndex: 'age' },
]

const App = () => {
  return <DataTable data={data} columns={columns} />
}

export default App

Props

| Prop | Type | Default | Description | | -------------------- | ------------------- | ------------------- | ---------------------------------------- | | data | any[] | [] | The data to be displayed in the table. | | columns | DataTableColumn[] | [] | Defines the columns of the table. | | rowsPerPageOptions | number[] | [10, 25, 50, 100] | Options for the number of rows per page. | | sx | SxProps | {} | Custom styling using MUI's sx prop. |

DataTableColumn Type

interface DataTableColumn {
  title: string
  dataIndex: string
  render?: (value: any) => string
}

Column Configuration (columns)

Each table column is defined by an object with the following properties:

  • title (string, required): The displayed name of the column.
  • dataIndex (string, required): The key corresponding to the data field in the data array.
  • render (function, optional): Allows modifying the displayed value (e.g., formatting a date, converting a state code to a label).

Examples

  • Format a date:

    {
      title: 'Start Date',
      dataIndex: 'startDate',
      render: (date: string) => new Date(date).toLocaleDateString(),
    }
  • Convert a state code to a label:

    const states = { CA: 'California', NY: 'New York' };
    
    {
      title: 'State',
      dataIndex: 'state',
      render: (stateCode: string) => states[stateCode] || stateCode,
    }

Features

  • Pagination – Easily navigate through large datasets.
  • Sorting – Click on column headers to sort data.
  • Search filtering – Built-in text search for quick filtering.
  • Custom column rendering – Customize cell content using the render function.
  • MUI sx styling support – Apply custom styles using the Material UI sx prop.

Custom Styling

The component supports MUI's sx prop for custom styling:

<DataTable
  data={employees}
  columns={columns}
  sx={{
    container: {
      padding: '16px',
      borderRadius: '8px',
      boxShadow: '0 0 10px rgba(0, 0, 0, 0.1)',
      mt: '20px',
    },
    search: { marginBottom: '20px' },
    table: { border: '1px solid black' },
    header: { backgroundColor: 'lightblue' },
    body: { backgroundColor: 'lightgrey' },
    row: { '&:nth-of-type(odd)': { backgroundColor: '#f9f9f9' } },
    cell: { padding: '10px' },
    pagination: { marginTop: '20px' },
  }}
/>

Contribution

Contributions are welcome! Feel free to open issues or pull requests in the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for more details.