PACKAGES
@plumeria/inspector
★★★☆☆ CandidateHover any element to see the Plumeria rules applied to it, in development or on staging.
@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
pnpm i @plumeria/inspectorUsage
Render Inspector once at the root of the application, such as the root layout or the entry component.
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:
Shiftlocks onto the hovered element, so the cursor can move into the tooltip and scroll its rules.Shiftagain unlocks. - Shortcut:
Cmd + I/Alt + Iturns the inspector on and off. - Badge: a badge in the bottom-right corner shows the status and toggles it on click.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
initial | boolean | false | If 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:
- Click the Inspector: ON badge in the bottom-right corner, or press
Cmd + I/Alt + I. - Hover over any text, heading, or container on this page to see the outline and compiled rules.
- Press
Shiftto freeze the selection and explore the details in the tooltip.