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

@vishalvoid/react-india-map

v1.2.0

Published

Interactive SVG India Map React Component

Readme

React India Map Component

An interactive SVG India map component for React applications with TypeScript support. This component allows you to create clickable and hoverable state regions with custom data and styling.

1.00

Installation

npm install @vishalvoid/react-india-map

Usage

import { IndiaMap } from "@vishalvoid/react-india-map";
import type { StateData } from "@vishalvoid/react-india-map";

const App = () => {
  const mapStyle = {
    backgroundColor: "#ffffff",
    hoverColor: "#dddddd",
    tooltipConfig: {
      backgroundColor: "rgba(0, 0, 0, 0.8)",
      textColor: "#ffffff",
    },
  };

  const stateData: StateData[] = [
    {
      id: "IN-MH",
      customData: {
        population: "123.2M",
        capital: "Mumbai",
      },
    },
  ];

  const handleStateHover = (stateId: string, stateInfo?: StateData) => {
    console.log(`Hovering over ${stateId}`, stateInfo);
  };

  const handleStateClick = (stateId: string, stateInfo?: StateData) => {
    console.log(`Clicked on ${stateId}`, stateInfo);
  };

  return (
    <IndiaMap
      mapStyle={mapStyle}
      stateData={stateData}
      onStateHover={handleStateHover}
      onStateClick={handleStateClick}
    />
  );
};

Props

interface TooltipConfig {
  backgroundColor?: string; // Default: "rgba(0, 0, 0, 0.8)"
  textColor?: string; // Default: "#ffffff"
}

interface MapStyle {
  backgroundColor?: string; // Default: "#ffffff"
  hoverColor?: string; // Default: "#dddddd"
  tooltipConfig?: TooltipConfig;
  stroke?: string; // Default: "#000000"
  strokeWidth?: number; // Default: 1
}

interface StateData {
  id: string; // State ID (e.g., "IN-MH")
  customData?: {
    [key: string]: any; // Custom state data
  };
}

interface IndiaMapProps {
  mapStyle?: MapStyle;
  stateData?: StateData[];
  onStateHover?: (stateId: string, stateInfo?: StateData) => void;
  onStateClick?: (stateId: string, stateInfo?: StateData) => void;
}

State IDs Reference

| State/UT | ID | Capital | | ----------------- | ----- | ------------------ | | Andhra Pradesh | IN-AP | Amaravati | | Arunachal Pradesh | IN-AR | Itanagar | | Assam | IN-AS | Dispur | | Bihar | IN-BR | Patna | | Chhattisgarh | IN-CT | Raipur | | Goa | IN-GA | Panaji | | Gujarat | IN-GJ | Gandhinagar | | Haryana | IN-HR | Chandigarh | | Himachal Pradesh | IN-HP | Shimla | | Jharkhand | IN-JH | Ranchi | | Karnataka | IN-KA | Bengaluru | | Kerala | IN-KL | Thiruvananthapuram | | Madhya Pradesh | IN-MP | Bhopal | | Maharashtra | IN-MH | Mumbai | | Manipur | IN-MN | Imphal | | Meghalaya | IN-ML | Shillong | | Mizoram | IN-MZ | Aizawl | | Nagaland | IN-NL | Kohima | | Odisha | IN-OR | Bhubaneswar | | Punjab | IN-PB | Chandigarh | | Rajasthan | IN-RJ | Jaipur | | Sikkim | IN-SK | Gangtok | | Tamil Nadu | IN-TN | Chennai | | Telangana | IN-TG | Hyderabad | | Tripura | IN-TR | Agartala | | Uttar Pradesh | IN-UP | Lucknow | | Uttarakhand | IN-UT | Dehradun | | West Bengal | IN-WB | Kolkata |

Union Territories

| Union Territory | ID | Capital | | ---------------------------------------- | ----- | -------------- | | Andaman and Nicobar | IN-AN | Port Blair | | Chandigarh | IN-CH | Chandigarh | | Dadra and Nagar Haveli and Daman and Diu | IN-DN | Daman | | Delhi | IN-DL | New Delhi | | Jammu and Kashmir | IN-JK | Srinagar/Jammu | | Ladakh | IN-LA | Leh | | Lakshadweep | IN-LD | Kavaratti | | Puducherry | IN-PY | Puducherry |

Styling

You can customize the map appearance using CSS:

.india-map-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.india-map-container path {
  transition: fill 0.3s ease;
  stroke: #ffffff;
  stroke-width: 1;
}

.india-map-container path:hover {
  cursor: pointer;
  opacity: 0.8;
}

.state-tooltip {
  transition: opacity 0.2s;
}

Examples

Basic Usage with Hover Effect

import React, { useState } from "react";
import { IndiaMap } from "@vishalvoid/react-india-map";

const App = () => {
  const [activeState, setActiveState] = useState("");

  return (
    <IndiaMap
      mapStyle={{
        backgroundColor: "#f0f0f0",
        hoverColor: "#b3e0ff",
      }}
      onStateHover={(stateId) => setActiveState(stateId)}
    />
  );
};

With Custom State Data and Click Handler

import React from "react";
import { IndiaMap } from "@vishalvoid/react-india-map";
import type { StateData } from "@vishalvoid/react-india-map";

const App = () => {
  const stateData: StateData[] = [
    {
      id: "IN-MH",
      customData: {
        population: "123.2M",
        capital: "Mumbai",
        gdp: "$400B",
      },
    },
    {
      id: "IN-DL",
      customData: {
        population: "20.5M",
        capital: "New Delhi",
        gdp: "$110B",
      },
    },
  ];

  const handleStateClick = (stateId: string, data?: StateData) => {
    console.log(`Clicked ${stateId}:`, data?.customData);
    // You can show modal, navigate to state page, etc.
  };

  return (
    <IndiaMap
      stateData={stateData}
      onStateClick={handleStateClick}
      mapStyle={{
        backgroundColor: "#f8f9fa",
        hoverColor: "#acd5f2",
        stroke: "#ffffff",
        strokeWidth: 1,
        tooltipConfig: {
          backgroundColor: "rgba(0, 0, 0, 0.8)",
          textColor: "#ffffff",
        },
      }}
    />
  );
};

Publishing Updates

To publish a new version to NPM:

# Update version in package.json
npm version patch # or minor or major

# Build the package
npm run build

# Publish to NPM
npm publish

Development

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

License

MIT License

Contributing

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