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

@sultanavtajev/element-picker

v1.0.1

Published

React dev tool for inspecting elements — hover to see component hierarchy, source path, CSS selector, and copy to clipboard

Readme

@sultanavtajev/element-picker

Dev tool for Next.js that gives AI assistants precise context about your UI — hover to highlight, click to copy component hierarchy, source path, CSS selector, and more to clipboard.

Built for AI-assisted development with Claude Code, Cursor, Copilot, and similar tools. Designed for Next.js projects (App Router & Pages Router).

Why?

AI assistants struggle when you say "fix that button" — they don't know which component, file, or selector you mean. Element Picker solves this:

  1. Activate the picker (Ctrl+Shift+X)
  2. Click any element in your app
  3. Paste the copied output into your AI chat
  4. Done — the AI has full context: component name, source file, CSS selector, hierarchy

No more manual searching for file paths or describing UI elements. One click, one paste.

Features

  • Hover any element to see an overlay with component info
  • Click to copy a detailed markdown summary to clipboard
  • Shows React component hierarchy with source file references
  • Generates smart CSS selectors (ID → data-slot → aria-label → semantic class → ancestor path)
  • Resolves source files via React _debugSource with heuristic fallback
  • Filters out Next.js internals (router components, layout wrappers, etc.)
  • Keyboard shortcut to toggle (default Ctrl+Shift+X)
  • Renders via portal — zero impact on your app's DOM structure
  • SSR-safe — works with both App Router and Pages Router
  • Fully configurable: custom source paths, component bases, output format

Installation

npm i @sultanavtajev/element-picker

Requires a Next.js project with react ≥ 18 and react-dom ≥ 18.

Icons (lucide-react) and toasts (sonner) are included as regular dependencies and installed automatically.

Quick start

npm i @sultanavtajev/element-picker

Then ask your AI assistant to add it to your Next.js root layout:

Add <ElementPicker /> from @sultanavtajev/element-picker to my root layout. Only render it in development mode.

Or add it manually to app/layout.tsx:

import { ElementPicker } from "@sultanavtajev/element-picker";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        {process.env.NODE_ENV === "development" && <ElementPicker />}
      </body>
    </html>
  );
}

Press Ctrl+Shift+X to activate the picker, hover any element, and click to copy its info.

Clipboard output

Clicking an element copies markdown like this:

## Element Picker
- Page: `http://localhost:3000/dashboard`
- React Component: `UserCard`
- React Key: `user-42`
- Component Tree: `AppLayout → DashboardPage → UserCard`
- Source (exact): `src/components/user-card.tsx:14`
- data-slot: `card`
- Text: `John Doe`
- Selector: `[data-slot="card"]`

Fields with no value (like id, aria-label, data-testid) are omitted automatically.

Configuration

All props are optional:

<ElementPicker
  componentBases={["button", "card", "dialog"]}
  sourcePathPrefix="src/components/ui/"
  frameworkInternals={["MyInternalWrapper"]}
  shortcut={{ ctrl: true, shift: true, key: "X" }}
  formatOutput={(info) => JSON.stringify(info, null, 2)}
/>

ElementPickerConfig

| Prop | Type | Default | Description | |---|---|---|---| | componentBases | string[] | [] | UI component base names for source file inference (e.g. ["button", "card"]) | | sourcePathPrefix | string | "src/components/ui/" | Path prefix for inferred source files | | frameworkInternals | string[] | [] | Additional component names to filter from the hierarchy | | shortcut | ShortcutConfig | { ctrl: true, shift: true, key: "X" } | Keyboard shortcut to toggle the picker | | formatOutput | (info: ElementInfo) => string | Built-in markdown | Custom formatter for clipboard output |

ShortcutConfig

| Field | Type | Default | |---|---|---| | ctrl | boolean | false | | shift | boolean | false | | alt | boolean | false | | key | string | — |

API reference

Components

ElementPicker

The main React component. Renders a portal-based overlay for element inspection. See Configuration for props.

Functions

extractElementInfo(element: HTMLElement, config?: ElementPickerConfig): ElementInfo

Extracts all info for a given DOM element — component hierarchy, source path, CSS selector, attributes, and more.

formatElementInfo(info: ElementInfo): string

Formats an ElementInfo object into the default markdown clipboard string.

generateSelector(element: HTMLElement): string

Generates a smart CSS selector for an element, preferring stable identifiers (ID, data-slot, aria-label) over brittle positional selectors.

getComponentHierarchy(element: HTMLElement, frameworkInternals?: string[]): ComponentEntry[]

Walks the React Fiber tree to build a component hierarchy, filtering out framework internals.

Types

interface ElementInfo {
  pageUrl: string;
  reactComponent: string;
  reactKey: string;
  componentTree: string;
  sourcePath: string;
  sourceConfidence: string;
  tagName: string;
  id: string;
  dataSlot: string;
  dataTestId: string;
  ariaLabel: string;
  textContent: string;
  cssSelector: string;
}

interface ComponentEntry {
  name: string;
  source: string | null;
  key: string | null;
}

interface ShortcutConfig {
  ctrl?: boolean;
  shift?: boolean;
  alt?: boolean;
  key: string;
}

License

MIT