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

@aryanjsx/indiamap

v1.0.2

Published

Interactive SVG Map of India with hover and click functionality

Readme

🇮🇳 @aryanjsx/indiamap

An elegant, interactive SVG map of India for React applications

npm version npm downloads license TypeScript React

India Map Demo

InstallationUsagePropsState CodesExamplesContributing


✨ Features

  • 🗺️ Complete Coverage — All 28 states and 8 union territories of India
  • 🎨 Fully Customizable — Colors, sizes, and styles to match your design
  • 🖱️ Interactive — Smooth hover effects and click handling
  • ⌨️ Accessible — Full keyboard navigation and ARIA support
  • 📦 Lightweight — Zero external dependencies
  • 🔷 TypeScript — Complete type definitions included
  • Performant — Optimized with React hooks and memoization

📦 Installation

# npm
npm install @aryanjsx/indiamap

# yarn
yarn add @aryanjsx/indiamap

# pnpm
pnpm add @aryanjsx/indiamap

🚀 Usage

Basic Example

import { useState } from 'react'
import IndiaMap from '@aryanjsx/indiamap'

function App() {
  const [selectedState, setSelectedState] = useState('')

  return (
    <div>
      <h2>Selected: {selectedState || 'Click a state'}</h2>
      <IndiaMap
        onClick={(stateCode) => setSelectedState(stateCode)}
        size="500px"
        mapColor="#ffffff"
        strokeColor="#4a4a4a"
        strokeWidth="0.5"
        hoverColor="#ff9933"
      />
    </div>
  )
}

Next.js / App Router

'use client'

import { useState } from 'react'
import IndiaMap from '@aryanjsx/indiamap'

export default function MapPage() {
  const [state, setState] = useState('')

  return (
    <IndiaMap
      onClick={setState}
      size="100%"
      mapColor="#f8fafc"
      strokeColor="#334155"
      hoverColor="#0ea5e9"
    />
  )
}

With TypeScript

import { useState } from 'react'
import IndiaMap from '@aryanjsx/indiamap'

const MapComponent: React.FC = () => {
  const [selectedState, setSelectedState] = useState<string>('')

  const handleStateClick = (stateCode: string): void => {
    setSelectedState(stateCode)
    console.log(`Selected: ${stateCode}`)
  }

  return (
    <IndiaMap
      onClick={handleStateClick}
      size="600px"
      mapColor="#1e293b"
      strokeColor="#475569"
      strokeWidth="0.5"
      hoverColor="#22c55e"
      className="india-map"
    />
  )
}

export default MapComponent

📋 Props

| Prop | Type | Required | Default | Description | |:-----|:-----|:--------:|:--------|:------------| | onClick | (stateCode: string) => void | ✅ | — | Callback fired when a state is clicked | | className | string | ❌ | "svgmap" | CSS class for the container | | size | string | ❌ | "inherit" | Width of the map (e.g., "500px", "100%") | | mapColor | string | ❌ | "#ffffff" | Default fill color for states | | strokeColor | string | ❌ | "#000000" | Border color for states | | strokeWidth | string | ❌ | "0.5" | Border width for states | | hoverColor | string | ❌ | "#303030" | Fill color on hover/focus |


🗺️ State Codes

The map uses ISO-style 2-letter codes for each state and union territory:

| Code | State | |:----:|:------| | AP | Andhra Pradesh | | AR | Arunachal Pradesh | | AS | Assam | | BR | Bihar | | CT | Chhattisgarh | | GA | Goa | | GJ | Gujarat | | HR | Haryana | | HP | Himachal Pradesh | | JH | Jharkhand | | KA | Karnataka | | KL | Kerala | | MP | Madhya Pradesh | | MH | Maharashtra | | MN | Manipur | | ML | Meghalaya | | MZ | Mizoram | | NL | Nagaland | | OR | Odisha | | PB | Punjab | | RJ | Rajasthan | | SK | Sikkim | | TN | Tamil Nadu | | TG | Telangana | | TR | Tripura | | UP | Uttar Pradesh | | UT | Uttarakhand | | WB | West Bengal |

| Code | Union Territory | |:----:|:----------------| | AN | Andaman and Nicobar Islands | | CH | Chandigarh | | DD | Dadra and Nagar Haveli and Daman and Diu | | DL | Delhi | | JK | Jammu and Kashmir | | LA | Ladakh | | LD | Lakshadweep | | PY | Puducherry |

Quick Reference

const stateNames = {
  'AN': 'Andaman and Nicobar Islands',
  'AP': 'Andhra Pradesh',
  'AR': 'Arunachal Pradesh',
  'AS': 'Assam',
  'BR': 'Bihar',
  'CH': 'Chandigarh',
  'CT': 'Chhattisgarh',
  'DD': 'Dadra and Nagar Haveli and Daman and Diu',
  'DL': 'Delhi',
  'GA': 'Goa',
  'GJ': 'Gujarat',
  'HP': 'Himachal Pradesh',
  'HR': 'Haryana',
  'JH': 'Jharkhand',
  'JK': 'Jammu and Kashmir',
  'KA': 'Karnataka',
  'KL': 'Kerala',
  'LA': 'Ladakh',
  'LD': 'Lakshadweep',
  'MH': 'Maharashtra',
  'ML': 'Meghalaya',
  'MN': 'Manipur',
  'MP': 'Madhya Pradesh',
  'MZ': 'Mizoram',
  'NL': 'Nagaland',
  'OR': 'Odisha',
  'PB': 'Punjab',
  'PY': 'Puducherry',
  'RJ': 'Rajasthan',
  'SK': 'Sikkim',
  'TG': 'Telangana',
  'TN': 'Tamil Nadu',
  'TR': 'Tripura',
  'UP': 'Uttar Pradesh',
  'UT': 'Uttarakhand',
  'WB': 'West Bengal'
}

🎨 Examples

Dark Theme

<IndiaMap
  onClick={handleClick}
  size="100%"
  mapColor="#1a1a2e"
  strokeColor="#4a4a6a"
  strokeWidth="0.5"
  hoverColor="#e94560"
/>

Tricolor Theme (Indian Flag Colors)

<IndiaMap
  onClick={handleClick}
  size="500px"
  mapColor="#ffffff"
  strokeColor="#138808"
  strokeWidth="1"
  hoverColor="#ff9933"
/>

Minimal Light

<IndiaMap
  onClick={handleClick}
  size="100%"
  mapColor="#f1f5f9"
  strokeColor="#cbd5e1"
  strokeWidth="0.25"
  hoverColor="#3b82f6"
/>

Navigation Example

import { useNavigate } from 'react-router-dom'
import IndiaMap from '@aryanjsx/indiamap'

function ExploreMap() {
  const navigate = useNavigate()

  const handleStateClick = (stateCode) => {
    navigate(`/state/${stateCode.toLowerCase()}`)
  }

  return (
    <IndiaMap
      onClick={handleStateClick}
      size="100%"
      mapColor="#ecfdf5"
      strokeColor="#059669"
      hoverColor="#10b981"
    />
  )
}

♿ Accessibility

This component is built with accessibility in mind:

  • Keyboard Navigation — Tab through states, press Enter or Space to select
  • ARIA Labels — Screen reader support with descriptive labels
  • Focus Indicators — Visual focus states that mirror hover styles
  • Semantic SVG — Proper role and aria-label attributes

🤝 Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

ISC © Aryan


🙏 Credits


⬆ Back to Top

Made with ❤️ in India