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

activity-grid

v1.1.1

Published

A customizable activity grid component similar to GitHub's contribution graph

Downloads

40

Readme

Activity Grid

A customizable activity grid component that creates GitHub-style contribution graphs. This web component allows you to visualize activity data over time with support for various themes, configurations, and interaction options.

npm version License: MIT

Default View

Live Examples

Interactive examples are available on StackBlitz:

React Vue.js Angular TypeScript

Features

  • 📊 GitHub-style activity visualization
  • 🎨 Multiple built-in color themes (green, blue, red, yellow, purple)
  • 🌓 Dark mode support
  • 📅 Flexible date range configuration
  • 🗓️ Customizable week display (start on Monday, skip weekends)
  • 🎯 Interactive cells with click events
  • 💪 TypeScript support
  • 🔌 Framework agnostic - works with any frontend framework

Installation

npm install activity-grid

Basic Usage

<!-- In your HTML -->
<activity-grid id="myGrid"></activity-grid>

<script>
  // Initialize with data
  const grid = document.getElementById('myGrid');
  grid.data = [
    { date: '2024-01-01', count: 5 },
    { date: '2024-01-02', count: 2 },
    // ... more data
  ];
</script>
// If using TypeScript/ES modules
import 'activity-grid';

Data Format

The component accepts an array of activity data points with the following structure:

interface ActivityData {
  /** Date in YYYY-MM-DD format */
  date: string;
  /** Number of activities for this date (must be non-negative) */
  count: number;
  /** Optional identifier for the cell */
  id?: string;
}

Configuration Options

The component can be configured with the following attributes/properties:

| Property | Type | Default | Options | Description | |----------|------|---------|----------|-------------| | data | ActivityData[] | [] | - | Array of activity data points | | colorTheme | string | 'green' | 'green', 'red', 'blue', 'yellow', 'purple' | Predefined color theme for the grid | | colors | string[] | ['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39'] | Any array of 5 valid CSS colors | Custom color array for activity levels | | emptyColor | string | Light mode: '#ebedf0'Dark mode: '#161b22' | Any valid CSS color | Color for days with no activity | | darkMode | boolean | false | true, false | Whether to use dark mode colors | | skipWeekends | boolean | false | true, false | Whether to exclude weekends from the grid | | startWeekOnMonday | boolean | false | true, false | Whether to start weeks on Monday instead of Sunday | | startDate | string | One year before end date | Any valid date in YYYY-MM-DD format | Start date for the activity grid | | endDate | string | Current date | Any valid date in YYYY-MM-DD format | End date for the activity grid |

ActivityData Interface

interface ActivityData {
  /** Date in YYYY-MM-DD format */
  date: string;
  /** Number of activities for this date (must be non-negative) */
  count: number;
  /** Optional identifier for the cell */
  id?: string;
}

Examples

Color Themes

The activity grid comes with several built-in themes:

Default (Green)

<activity-grid></activity-grid>

Default Theme

Blue Theme

<activity-grid color-theme="blue"></activity-grid>

Blue Theme

Red Theme

<activity-grid color-theme="red"></activity-grid>

Red Theme

Yellow Theme

<activity-grid color-theme="yellow"></activity-grid>

Yellow Theme

Purple Theme

<activity-grid color-theme="purple"></activity-grid>

Purple Theme

Custom Colors

<activity-grid colors='["#ebedf0", "#9be9a8", "#40c463", "#30a14e", "#216e39"]'></activity-grid>

Custom Colors

Week Configuration

<!-- Start week on Monday -->
<activity-grid start-week-on-monday></activity-grid>

<!-- Skip weekends -->
<activity-grid skip-weekends></activity-grid>

Dark Mode

<activity-grid dark-mode></activity-grid>

Dark Mode

Custom Date Range

<activity-grid 
  start-date="2024-01-01" 
  end-date="2024-12-31">
</activity-grid>

Custom Date Range

Handling Click Events

const grid = document.querySelector('activity-grid');
grid.addEventListener('cell-click', (event) => {
  const { date, count, id } = event.detail;
  console.log(`Cell clicked: ${date} with ${count} activities`);
});

Custom titles/tool-tips

const grid = document.querySelector('activity-grid');
grid.titleFormatter = (date, count) => {
    if (count === 0) {
        return `${date.toDateString()}: Rest day 😴`;
    }
    
    const workouts = count === 1 ? 'workout' : 'workouts';
    const emoji = count >= 5 ? ' 🔥' : count >= 3 ? ' 💪' : ' 👍';
    return `${date.toDateString()}: ${count} ${workouts}${emoji}`;
};

Custom titles/tooltips

Framework Integration

React

import 'activity-grid';
import { useEffect, useRef } from 'react';

declare global {
  namespace JSX {
    interface IntrinsicElements {
      'activity-grid': any;
    }
  }
}

function ActivityGridComponent() {
  const gridRef = useRef(null);

  useEffect(() => {
    if (gridRef.current) {
      gridRef.current.data = [
        { date: '2024-01-01', count: 5 },
        // ... more data
      ];
    }
  }, []);

  return <activity-grid ref={gridRef} dark-mode></activity-grid>;
}

Vue

<template>
  <activity-grid ref="grid" dark-mode></activity-grid>
</template>

<script setup lang="ts">
import 'activity-grid';
import { onMounted, ref } from 'vue';

const grid = ref();

onMounted(() => {
  grid.value.data = [
    { date: '2024-01-01', count: 5 },
    // ... more data
  ];
});
</script>

More framework examples coming soon!

Browser Support

The component works in all modern browsers that support Web Components:

  • Chrome/Edge (Chromium-based)
  • Firefox
  • Safari

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.