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

react-body-selector

v1.0.2

Published

A React component library for interactive body part selection with customizable intensity levels

Readme

React Body Selector

A customizable React component library for interactive body part selection with intensity levels. Perfect for fitness apps, medical applications, pain tracking, and workout planning.

Features

  • Interactive SVG-based body visualization
  • Male and female body models
  • Front and back views
  • Customizable color schemes
  • Intensity levels (1-3) for each body part
  • Click to select/deselect body parts
  • TypeScript support with full type definitions
  • Zero dependencies (only React peer dependency)
  • Lightweight and performant

Installation

npm install react-body-selector
yarn add react-body-selector
pnpm add react-body-selector

Basic Usage

import { useState } from 'react';
import { Body, ExtendedBodyPart } from 'react-body-selector';

function App() {
  const [selectedParts, setSelectedParts] = useState<ExtendedBodyPart[]>([]);

  const handleBodyPartPress = (bodyPart: ExtendedBodyPart) => {
    const exists = selectedParts.find(p => p.slug === bodyPart.slug);

    if (exists) {
      setSelectedParts(selectedParts.filter(p => p.slug !== bodyPart.slug));
    } else {
      setSelectedParts([
        ...selectedParts,
        { slug: bodyPart.slug, intensity: 2 }
      ]);
    }
  };

  return (
    <Body
      data={selectedParts}
      gender="male"
      side="front"
      scale={1.5}
      onBodyPartPress={handleBodyPartPress}
    />
  );
}

Props

Body Component

| Prop | Type | Default | Description | |------|------|---------|-------------| | data | ExtendedBodyPart[] | [] | Array of selected body parts with intensity levels | | gender | "male" \| "female" | "male" | Body model to display | | side | "front" \| "back" | "front" | View to display | | scale | number | 1 | Scale factor for the body visualization | | colors | string[] | ["#0984e3", "#74b9ff", "#a29bfe"] | Array of 3 colors for intensity levels (1-3) | | border | string | "#dfe6e9" | Border color for body parts | | onBodyPartPress | (bodyPart: ExtendedBodyPart, side?: "left" \| "right") => void | - | Callback when a body part is clicked |

Types

ExtendedBodyPart

interface ExtendedBodyPart {
  slug: Slug;
  intensity?: number;
  side?: "left" | "right";
}

Slug (Body Parts)

Available body part identifiers:

  • abs - Abdominals
  • adductors - Adductors
  • ankles - Ankles
  • biceps - Biceps
  • calves - Calves
  • chest - Chest
  • deltoids - Shoulders
  • feet - Feet
  • forearm - Forearms
  • gluteal - Glutes
  • hamstring - Hamstrings
  • hands - Hands
  • head - Head
  • knees - Knees
  • lower-back - Lower Back
  • neck - Neck
  • obliques - Obliques
  • quadriceps - Quadriceps
  • tibialis - Tibialis
  • trapezius - Trapezius
  • triceps - Triceps
  • upper-back - Upper Back

Advanced Usage

Custom Colors

<Body
  data={selectedParts}
  colors={["#93c5fd", "#3b82f6", "#1d4ed8"]}
  border="#cbd5e1"
/>

Handling Side-Specific Selection

const handleBodyPartPress = (bodyPart: ExtendedBodyPart, side?: "left" | "right") => {
  if (side) {
    // Handle left/right specific selection
    setSelectedParts([
      ...selectedParts,
      { slug: bodyPart.slug, intensity: 2, side }
    ]);
  } else {
    // Handle symmetric selection (both sides)
    setSelectedParts([
      ...selectedParts,
      { slug: bodyPart.slug, intensity: 2 }
    ]);
  }
};

Dynamic Intensity Updates

const updateIntensity = (slug: Slug, intensity: number) => {
  setSelectedParts(selectedParts.map(part =>
    part.slug === slug ? { ...part, intensity } : part
  ));
};

// Usage with slider
<input
  type="range"
  min="1"
  max="3"
  value={part.intensity || 1}
  onChange={(e) => updateIntensity(part.slug!, parseInt(e.target.value))}
/>

Example: Full-Featured App

Check out the demo folder in the repository for a complete example with:

  • Gender toggle
  • Front/back view switching
  • Selected parts panel
  • Intensity sliders
  • Clear all functionality

Development

Running the Demo

npm install
npm run dev

Building the Library

npm run build:lib

Type Checking

npm run typecheck

Browser Support

Works in all modern browsers that support:

  • ES6+
  • React 18+
  • SVG rendering

License

MIT

Contributing

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

Credits

SVG body models adapted and enhanced for interactive use.