PACKAGES

@plumeria/inspector

★★★☆☆ Candidate

Hover any element to see the Plumeria rules applied to it, in development or on staging.

Inspector: ON (⌘ + I)

@plumeria/inspector is a component you render once. It outlines the element under the cursor and shows the Plumeria rules applied to it, in the browser.


Installation

Terminal
pnpm i @plumeria/inspector

Usage

Render Inspector once at the root of the application, such as the root layout or the entry component.

app/layout.tsx
import { Inspector } from '@plumeria/inspector';
import type { ReactNode } from 'react';

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <html>
      <body>
        {/* Render the inspector component */}
        <Inspector initial />
        {children}
      </body>
    </html>
  );
}

Features

  • Outline: the element under the cursor is outlined.
  • Tooltip: shows the classes, rules and properties Plumeria applied to that element.
  • Freeze: Shift locks onto the hovered element, so the cursor can move into the tooltip and scroll its rules. Shift again unlocks.
  • Shortcut: Cmd + I / Alt + I turns the inspector on and off.
  • Badge: a badge in the bottom-right corner shows the status and toggles it on click.

Props

PropTypeDefaultDescription
initialbooleanfalseIf true, the inspector starts toggled ON. If false, it starts toggled OFF.

Production mode

By default, the Inspector imported from @plumeria/inspector is stripped from production builds entirely. The main entry point resolves through the production export condition to a no-op module, so your bundler emits no client chunk for it.

To keep the inspector in a production build, for staging or a demo, import from the @plumeria/inspector/production subpath instead:

import { Inspector } from '@plumeria/inspector/production';

export default function Layout({ children }: { children: ReactNode }) {
  return (
    <html>
      <body>
        <Inspector initial />
        {children}
      </body>
    </html>
  );
}

Live demo

The inspector is running on this page:

  1. Click the Inspector: ON badge in the bottom-right corner, or press Cmd + I / Alt + I.
  2. Hover over any text, heading, or container on this page to see the outline and compiled rules.
  3. Press Shift to freeze the selection and explore the details in the tooltip.
Edit on GitHub