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

@botanicalcoder/react-heatmap-grid

v0.1.0

Published

Accessible, data-agnostic React heatmap with CSS variables and typed API.

Readme

React Heatmap Grid

NPM version License

An accessible, data-agnostic, and highly customizable heatmap component for React, built with TypeScript. Visualize your data in a clean grid layout, styled effortlessly with CSS variables.

✨ Features

  • 🎨 Highly Customizable: Easily theme colors, cell sizes, gaps, and borders using CSS variables.
  • 🔌 Data-Agnostic: Works with any data structure through simple accessor props (getX, getValue).
  • ✅ Fully Typed: Built with TypeScript for a superior developer experience and type safety.
  • 🦴 Skeleton Loader: Includes a <HeatmapSkeleton /> component for elegant loading states.
  • ♿ Accessibility-Ready: Built with semantic HTML and ARIA attributes in mind.
  • 📦 Lightweight: Minimal dependencies to keep your bundle size small.

🚀 Installation

Install the package and its peer dependencies using your favorite package manager.

npm install @botanicalcoder/react-heatmap-grid react react-dom

or

yarn add @botanicalcoder/react-heatmap-grid react react-dom

Usage

To get started, import the Heatmap component and its corresponding stylesheet. Then, provide your data and the required accessor props.

Basic Example

Here's a simple example of how to render a heatmap:

import React from 'react';
import { Heatmap } from '@botanicalcoder/react-heatmap-grid';
import '@botanicalcoder/react-heatmap-grid/styles.css';

// 1. Define your data type
type SalesData = {
  quarter: string; // Corresponds to an xLabel
  total: number; // The value to visualize
};

// 2. Prepare your data, organized by rows
const salesByRegion = [
  {
    y: 'North America', // Corresponds to a yLabel
    data: [
      { quarter: 'Q1', total: 15 },
      { quarter: 'Q2', total: 25 },
      { quarter: 'Q3', total: 18 },
      { quarter: 'Q4', total: 30 },
    ],
  },
  {
    y: 'Europe',
    data: [
      { quarter: 'Q1', total: 8 },
      { quarter: 'Q2', total: 12 },
      { quarter: 'Q3', total: 22 },
      { quarter: 'Q4', total: 19 },
    ],
  },
];

const App = () => {
  return (
    <Heatmap<SalesData>
      // 3. Define the labels for your axes
      xLabels={['Q1', 'Q2', 'Q3', 'Q4']}
      yLabels={['North America', 'Europe']}
      // 4. Pass the data
      rows={salesByRegion}
      // 5. Provide accessor functions
      getX={(item) => item.quarter}
      getValue={(item) => item.total}
    />
  );
};

export default App;

Loading State with Skeleton

Use the HeatmapSkeleton component to provide a better user experience while your data is loading.

import { HeatmapSkeleton } from '@botanicalcoder/react-heatmap-grid';
import '@botanicalcoder/react-heatmap-grid/styles.css';

function MyComponent() {
  const [loading, setLoading] = React.useState(true);
  // ... fetch data

  if (loading) {
    return <HeatmapSkeleton />;
  }

  return <Heatmap /* ...props */ />;
}

Component Props (API)

The <Heatmap /> component is highly configurable through its props.

| Prop | Type | Default | Description | | -------------------- | --------------------------------- | ---------------------------------- | ------------------------------------------------------------------------- | | xLabels | Array<string \| number> | [0, 1, ..., 23] | Labels for the columns (X-axis). | | yLabels | string[] | ['Mon', ..., 'Sun'] | Labels for the rows (Y-axis). Defines the row order. | | rows | Array<{ y: string; data: T[] }> | undefined | Your dataset, structured as an array of row objects. (Preferred) | | getX | (item: T) => string \| number | - | Required. A function to extract the X-value from a data item. | | getValue | (item: T) => number | - | Required. A function to extract the numerical value from a data item. | | colorRange | object | { empty, low, medium, high } | An object of hex codes to define the color palette. | | thresholds | object | { low: 0, medium: 10, high: 20 } | Numerical thresholds for applying the low, medium, and high colors. | | cellSizePx | number | 24 | The size (width and height) of each cell in pixels. | | cellGapPx | number | 2 | The gap between cells in pixels. | | cellBorderRadiusPx | number | 4 | The border radius for each cell. | | caption | string | 'Heatmap' | A caption displayed above the heatmap. | | showCaption | boolean | true | Toggles the visibility of the caption. | | getTitle | (args) => string | A default formatted string | A function to generate the title attribute (tooltip) for each cell. | | classNames | object | {} | An object to override the default CSS class names for different elements. |

🛠️ Technologies Used

| Technology | Link | | ---------- | ------------------------------------------------------------------ | | React | https://react.dev/ | | TypeScript | https://www.typescriptlang.org/ | | tsup | https://tsup.egoist.dev/ | | Vite | https://vitejs.dev/ |

🤝 Contributing

Contributions are always welcome! If you have suggestions for improvements or want to report a bug, please feel free to open an issue or submit a pull request.

  • Fork the repository on GitHub.
  • Clone your fork: git clone https://github.com/botanicalcoder/react-heatmap-grid.git
  • Create a new branch: git checkout -b feature/your-feature-name
  • Make your changes and commit them: git commit -m 'Add some feature'
  • Push to the branch: git push origin feature/your-feature-name
  • Open a pull request.

📄 License

This project is licensed under the MIT License.

👤 Author

Botanicalcoder

Readme was generated by Dokugen