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

@riishabh/react-calender-heatmap

v5.0.1

Published

A simple and customizable React calendar heatmap component

Readme

React Calendar Heatmap

@riishabh/react-calender-heatmap is a lightweight React component that renders a contribution-style calendar heatmap. It ships with sensible defaults, supports custom day states, and now works seamlessly in both React 18 and React 19 applications.

Highlights

  • React 18 & 19 support with strict TypeScript typings
  • 🧩 Plug-and-play component — no context or provider setup required
  • 🎨 Customizable color palette for different attendance or productivity states
  • 🧪 Storybook & Testing Library integration for rapid UI iteration

Installation

npm install @riishabh/react-calender-heatmap
# or
yarn add @riishabh/react-calender-heatmap
# or
pnpm add @riishabh/react-calender-heatmap

Peer dependencies

  • react: ^18.2.0 || ^19.0.0
  • react-dom: match your React version

Quick Start

import { TileChart } from '@riishabh/react-calender-heatmap';

const data = [
  { date: '2024-01-01', status: 'success' },
  { date: '2024-01-02', status: 'warning' },
  { date: '2024-01-03', status: 'holiday' },
];

export function AttendanceHeatmap() {
  return (
    <TileChart
      data={data}
      range={6}
      tileText="Day"
      onTileHover={(label, status) => {
        if (status) {
          console.log(`${label} → ${status}`);
        }
      }}
    />
  );
}

Importing the package automatically injects the default stylesheet, so the heatmap is ready to render without additional configuration.

Data shape

Each entry in the data array corresponds to a day.

type TileState =
  | 'success'
  | 'warning'
  | 'alert'
  | 'holiday'
  | 'weekend'
  | 'fullDayLeave'
  | 'halfDayLeave';

interface TileDataPoint {
  date: string;   // any ISO-8601 string parsable by new Date()
  status?: TileState;
}

Component props

| Prop | Type | Default | Description | |---------------|----------------------------------------------------------------------------------------|---------|---------------------------------------------------------------------------------------------------------| | data | TileDataPoint[] | — | Source data for the heatmap. Dates should be parseable by the browser's Date constructor. | | range | 3 \| 6 \| 12 | 6 | Number of months (backwards from the current month) to render. | | onTileHover | (label: string, status?: TileState) => void | — | Callback fired after a tile has been hovered long enough for the tooltip to appear. Empty string clears.| | tileText | string | — | Optional static string shown in the tooltip instead of the generated date string. |

Visual states

Use one of the built-in status values to map data to colors. Override the classes below to match your design system.

| Status | Class | Default styling (excerpt) | |-----------------|-------------------|--------------------------------------------------------| | success | .bg-success | green background, subtle border | | warning | .bg-warning | amber background | | alert | .bg-alert | red background | | holiday | .bg-holiday | blue background | | weekend | .bg-weekend | lilac background | | fullDayLeave | .bg-fullDayLeave| burnt orange background | | halfDayLeave | .bg-halfDayLeave| magenta background | | unset | .bg-default | neutral gray background |

Customizing the palette

Create a global stylesheet (or use CSS modules) to override the classes:

:root {
  --heatmap-success: #00a86b;
}

.bg-success {
  background-color: var(--heatmap-success);
  border-color: rgba(0, 168, 107, 0.45);
}

Because the component injects its CSS at runtime, make sure your overrides load after the component (for example, in your app-level stylesheet).

Tooltip & interactions

Tile hover events emit a human-friendly label (e.g. 3rd Jan 24) and the resolved status. Use this to show additional UI (like side panels or analytics) or to hook into analytics events.

<TileChart
  data={data}
  onTileHover={(label, status) => track('heatmap-hover', { label, status })} 
/>

TypeScript support

All exports ship with .d.ts files generated from the source TypeScript. If you need to narrow the status union for your own domain, extend the provided TileChartProps:

import type { TileChartProps } from '@riishabh/react-calender-heatmap';

type CustomTileState = TileChartProps['data'][number]['status'] | 'remote';

Development & contributing

npm install        # install dependencies
npm run storybook  # launch interactive component docs at http://localhost:6006
npm run build      # create the production-ready bundles in /dist
npm test           # (optional) run Jest in watch mode

Feel free to open issues or pull requests on GitHub with feature ideas or fixes.

License

MIT © Rishabh Sharma