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-boxmodel-inspector

v2.1.0

Published

A React developer tool that wraps any element and visually debugs its CSS box model — margin, border, padding, and content — with live overlays and a draggable panel.

Readme

react-boxmodel-inspector

A zero-dependency React developer tool that wraps any element and visually debugs its CSS box model — margin, border, padding, and content — with live overlays and a draggable floating panel.

⚠️ This is a developer tool. Don't ship it to production.


Features

  • 🔍 Long-press any element to inspect it
  • 📦 Live layered overlays — dashed rectangles for margin (orange), padding (green), and content (purple), each with pixel edge labels
  • 🪟 Draggable floating panel showing T·R·B·L values for margin, border, padding, and content size
  • 🔄 Live updates via ResizeObserver, MutationObserver, and scroll/resize listeners
  • ⌨️ Keyboard shortcuts — press backtick (`) to toggle, ESC to close
  • Zero overhead when disabled — renders only children when not in use
  • 🎨 Expandable CSS property groups — typography, layout, flex/grid, color, transform, and more
  • 🔷 First-class TypeScript support — fully typed with exported interfaces

What's New in v2.0.0

  • ✅ Fully rewritten in TypeScript
  • ✅ Ships with built-in type declarations (.d.ts) — no @types/ package needed
  • ✅ Exported BoxModelInspectorProps interface for type-safe usage
  • 100% backward-compatible with JavaScript/JSX projects

Installation

npm install react-boxmodel-inspector

Basic Usage

JavaScript (JSX)

import BoxModelInspector from 'react-boxmodel-inspector';

function App() {
  return (
    <BoxModelInspector>
      <YourApp />
    </BoxModelInspector>
  );
}

TypeScript (TSX)

import BoxModelInspector from 'react-boxmodel-inspector';
// Optionally import the props type
import type { BoxModelInspectorProps } from 'react-boxmodel-inspector';

function App() {
  return (
    <BoxModelInspector>
      <YourApp />
    </BoxModelInspector>
  );
}

Then in the browser:

  • Press ` (backtick) to activate the inspector
  • Long-press any element to inspect it
  • Press ESC or click to close the panel
  • Drag the panel anywhere

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | children | ReactNode | — | The component tree to wrap | | longPressDuration | number | 500 | How long (ms) to hold before inspection triggers | | toggleKey | string | "`" | Key to toggle the inspector on/off |


TypeScript Integration

This package is written in TypeScript and ships with built-in type declarations. No additional @types/ packages are needed.

Importing Types

import BoxModelInspector from 'react-boxmodel-inspector';
import type { BoxModelInspectorProps } from 'react-boxmodel-inspector';

Using with Custom Wrappers

import BoxModelInspector, { BoxModelInspectorProps } from 'react-boxmodel-inspector';

// Create a custom wrapper with additional props
interface DevInspectorProps extends BoxModelInspectorProps {
  enabled?: boolean;
}

function DevInspector({ enabled = true, ...props }: DevInspectorProps) {
  if (!enabled) return <>{props.children}</>;
  return <BoxModelInspector {...props} />;
}

Minimum TypeScript Version

  • TypeScript 5.0+ recommended
  • Works with TypeScript 4.7+ (moduleResolution: "bundler" or "node16")

Usage with Entry Point

main.tsx (TypeScript)

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import BoxModelInspector from 'react-boxmodel-inspector';

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <BoxModelInspector>
      <App />
    </BoxModelInspector>
  </StrictMode>
);

main.jsx (JavaScript)

import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import App from './App.jsx';
import BoxModelInspector from 'react-boxmodel-inspector';

createRoot(document.getElementById('root')).render(
  <StrictMode>
    <BoxModelInspector>
      <App />
    </BoxModelInspector>
  </StrictMode>
);

Custom Toggle Key and Duration

<BoxModelInspector toggleKey="F2" longPressDuration={300}>
  <App />
</BoxModelInspector>

How It Works

  1. Press the toggle key to activate inspector mode — a blue banner appears at the top of the screen.
  2. Long-press any element in the page. A circular ripple indicates the progress.
  3. On trigger, three dashed overlays appear directly on the element:
    • Orange — margin box with T/R/B/L labels
    • Green — padding box with T/R/B/L labels
    • Purple — content box with width × height
  4. A dark floating panel also appears to the right, showing numeric T·R·B·L values for margin, border, padding, and content size.
  5. Expand "All properties" in the panel to see grouped CSS values (typography, layout, flex, color, etc).

Requirements

  • React 17+ or 18+
  • TypeScript 5+ (for type-checking; not required at runtime)
  • Works in any browser with ResizeObserver and MutationObserver support (all modern browsers)

License

MIT