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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chloeadriancreates/custom-react-table

v1.1.7

Published

A React component to display a custom table based on data provided.

Downloads

18

Readme

NodeJS React JavaScript CSS

Need a light, customizable and easy-to-use table component to display data in your React app? Look no further!

Table screenshot

This 18kb React component allows you to display complex data into a clean table, complete with pagination, a search system and sorting by each category. Let's see how it works!

Prerequisites

Getting started

Installation

npm install @chloeadriancreates/custom-react-table

Usage

import { Table } from "@chloeadriancreates/custom-react-table";

const YourComponent = () => {
  const [content, setContent] = useState([{
      animal: "manatee",
      color: "turquoise"
      food: "pizza"
  }, {
      animal: "deer",
      color: "lavender"
      food: "sushi"
  }]);
  return <Table content={content} />;
};

Further customization

The only required prop for the table to run is content, which is an array of objects, as you can see in the demonstration in Getting started. There are, however, a few options for further customization.

Colors

A color theme is calculated based on one main color, which is by default a medium warm grey. You can customize it to fit your app's design system, by passing a hex code (either 3 or 6 characters) to the color prop. For fonts, setting the font-family of the parent component you're using the table in suffices, as it uses inherit.

<Table content={content} color="#577399" />

Date format

The Table component automatically detects dates (passed as ISO strings), and formats them by default in "DD/MM/YYYY" using Day.js. You can use any other valid Day.js parsing token by passing it to the dateFormat prop.

<Table content={content} dateFormat="MM/DD/YY" />

Object flattening

If a row of your table (symbolized by each object in your content array) contains another object, you can choose to flatten it by choosing which property to display. For example, if a row were to look like this:

{
    color: "purple",
	animals": { 
		pastFavorite: "unicorn", 
		currentFavorite: "panda" 
	}
}

You would have to pass either { animals: "pastFavorite" } or { animals: "currentFavorite" } to the objectKey prop, to decide whether to display "unicorn" or "panda". The objectKey object can have as many properties as your content has properties that are objects. However, this is as deep as it goes: further sub-objects will not work with this table.

<Table content={content} objectKey={ animals: "pastFavorite" } />

Future updates

These are things that may limit your usage of this component at the moment, but I am aware of and working on! Currently:

  • Row objects can't contain arrays.
  • The Table component only has a desktop version.

Thanks for reading, and happy coding!

Chloé Adrian