Redline

Spacing Inspector Overlay for React

Figma-style redlines for any layout. Point at an element to see its size, padding and gaps, with lines and labels that glide from one element to the next. Pin one and hold Alt to measure the distance to another.

  • Inspector
  • Hover
  • Design

Uses motion, clsx, tailwind-merge

Open in ChatGPTOpen in Claude
specfalse
duration0.20s
hoverDelay0.09s
tourInterval2.5s
<Redline />

The demo follows as you drag.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Redline: Figma-style redlines for any layout. Point at an element to see its size, padding and gaps, with lines and labels that glide from one element to the next. Pin one and hold Alt to measure the distance to another.
This demo, Details: A studio's "we sweat the details" section around a product card. Left alone, it tours the card's padding, the gap between the title and the price, the button's 44px height and the space around the photo. Point at anything to take over, click to pin, and hold Alt to measure between two parts. With `spec`, text shows its font.

1. Install it:
   npx shadcn@latest add @keyframeui/redline-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/redline-demo.json instead.)
   It adds the demo, components/redline-demo.tsx, and the component, components/ui/redline.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Redline> on its own.

3. These props set its feel. Change them before you change the file:
   - spec (default false): Show a card beside text elements with their font, size and line height, weight, letter spacing and color.
   - duration (default 0.2): Seconds the box, lines, hatches and their numbers take to glide from one element to the next. Scrolling and resizing still move them at once.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on an element before the box moves to it, when it arrives moving fast. A slow pointer moves it at once, so sweeping across nested elements doesn't flicker.
   - tourInterval (default 2.5): Seconds the `tour` holds on each stop before it moves on.

4. Don't change, in components/ui/redline.tsx:
   - Every number glides on its own motion value (`useGlide`) and positions snap to whole device pixels, so the box, lines and labels move together and stay crisp without re-rendering.
   - The scene only re-renders when its measurements change (compared as JSON); scrolling and resizing remeasure once per frame and jump there, without a glide.
   - A fast pointer moves the box only after it rests for `hoverDelay`; a slow one moves it at once, so sweeping across nested elements doesn't flicker.
   - A line that wasn't there before draws outward from the edge it measures with `clip-path`, and its label fades in after it; a line already shown just glides.
   - Reduced motion skips every glide and draw, so values jump; only the short fades in and out stay.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/redline.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/redline.tsx and installs motion, clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/redline

Examples

Finished sections built with Redline. Each one installs whole, with the component included.

Design System

A settings panel where every spacing label reads as a token through `tokens`, and `selector="[data-redline]"` keeps the pointer on named parts. Pin a row, hold Alt and point at another to see the space between them.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Redline: Figma-style redlines for any layout. Point at an element to see its size, padding and gaps, with lines and labels that glide from one element to the next. Pin one and hold Alt to measure the distance to another.
This demo, Design System: A settings panel where every spacing label reads as a token through `tokens`, and `selector="[data-redline]"` keeps the pointer on named parts. Pin a row, hold Alt and point at another to see the space between them.

1. Install it:
   npx shadcn@latest add @keyframeui/redline-tokens-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/redline-tokens-demo.json instead.)
   It adds the demo, components/redline-tokens-demo.tsx, and the component, components/ui/redline.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Redline> on its own.

3. These props set its feel. Change them before you change the file:
   - spec (default false): Show a card beside text elements with their font, size and line height, weight, letter spacing and color.
   - duration (default 0.2): Seconds the box, lines, hatches and their numbers take to glide from one element to the next. Scrolling and resizing still move them at once.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on an element before the box moves to it, when it arrives moving fast. A slow pointer moves it at once, so sweeping across nested elements doesn't flicker.
   - tourInterval (default 2.5): Seconds the `tour` holds on each stop before it moves on.

4. Don't change, in components/ui/redline.tsx:
   - Every number glides on its own motion value (`useGlide`) and positions snap to whole device pixels, so the box, lines and labels move together and stay crisp without re-rendering.
   - The scene only re-renders when its measurements change (compared as JSON); scrolling and resizing remeasure once per frame and jump there, without a glide.
   - A fast pointer moves the box only after it rests for `hoverDelay`; a slow one moves it at once, so sweeping across nested elements doesn't flicker.
   - A line that wasn't there before draws outward from the edge it measures with `clip-path`, and its label fades in after it; a line already shown just glides.
   - Reduced motion skips every glide and draw, so values jump; only the short fades in and out stay.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/redline.md

Dev Handoff

A design tool's handoff mode. `onSelect` fills the panel on the right with the CSS and the Tailwind classes of whatever layer is selected, and it swaps as you move.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Redline: Figma-style redlines for any layout. Point at an element to see its size, padding and gaps, with lines and labels that glide from one element to the next. Pin one and hold Alt to measure the distance to another.
This demo, Dev Handoff: A design tool's handoff mode. `onSelect` fills the panel on the right with the CSS and the Tailwind classes of whatever layer is selected, and it swaps as you move.

1. Install it:
   npx shadcn@latest add @keyframeui/redline-handoff-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/redline-handoff-demo.json instead.)
   It adds the demo, components/redline-handoff-demo.tsx, and the component, components/ui/redline.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <Redline> on its own.

3. These props set its feel. Change them before you change the file:
   - spec (default false): Show a card beside text elements with their font, size and line height, weight, letter spacing and color.
   - duration (default 0.2): Seconds the box, lines, hatches and their numbers take to glide from one element to the next. Scrolling and resizing still move them at once.
   - hoverDelay (default 0.09): Seconds the pointer has to rest on an element before the box moves to it, when it arrives moving fast. A slow pointer moves it at once, so sweeping across nested elements doesn't flicker.
   - tourInterval (default 2.5): Seconds the `tour` holds on each stop before it moves on.

4. Don't change, in components/ui/redline.tsx:
   - Every number glides on its own motion value (`useGlide`) and positions snap to whole device pixels, so the box, lines and labels move together and stay crisp without re-rendering.
   - The scene only re-renders when its measurements change (compared as JSON); scrolling and resizing remeasure once per frame and jump there, without a glide.
   - A fast pointer moves the box only after it rests for `hoverDelay`; a slow one moves it at once, so sweeping across nested elements doesn't flicker.
   - A line that wasn't there before draws outward from the edge it measures with `clip-path`, and its label fades in after it; a line already shown just glides.
   - Reduced motion skips every glide and draw, so values jump; only the short fades in and out stay.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/redline.md

Props

children Required

TypeReact.ReactNode

The layout to measure. Measurements are relative to the Redline box and keep up with resizes and with scrolling inside it.

data-redline

Typestring

Put it on any element inside to name it, for tour steps, for onSelect's name and for the announcement when it's selected.

tour

Type(string | [string, string])[]

Elements to walk through on their own while nobody is pointing, by data-redline name, tourInterval seconds each. A pair of names measures between the two. It loops while on screen, stops when the pointer comes in and picks up 2s after it leaves.

tokens

TypeRecord<number, string>

Names for pixel values, so padding, gap and distance labels read space-4 instead of 16: { 16: "space-4" }. Sizes stay in pixels.

spec

TypebooleanDefaultfalse

Show a card beside text elements with their font, size and line height, weight, letter spacing and color.

duration

TypenumberDefault0.2

Seconds the box, lines, hatches and their numbers take to glide from one element to the next. Scrolling and resizing still move them at once.

hoverDelay

TypenumberDefault0.09

Seconds the pointer has to rest on an element before the box moves to it, when it arrives moving fast. A slow pointer moves it at once, so sweeping across nested elements doesn't flicker.

tourInterval

TypenumberDefault2.5

Seconds the tour holds on each stop before it moves on.

selector

TypestringDefault"*"

Which elements can be measured. "[data-redline]" limits it to named elements, like layers in a design tool; the pointer then picks the nearest named element under it.

onSelect

Type(selection: RedlineSelection | null) => void

Called when the selected element changes, with the element, its name, width, height, padding, flex or grid gap, the spacing to its neighbors and, for text, its text style. Called with null when the redlines fade out.

colors

Type{ selection?: string; distance?: string; spacing?: string }Default{ selection: "#0C8CE9", distance: "#F24822", spacing: "#C026D3" }

Colors for the selection box and size pill, the distance lines and their labels, and the padding and gap hatching.

className

Typestring

Classes for the measured area. It takes keyboard focus: arrow keys walk the tree, Enter pins, Esc clears.