Home / Market / ui canvas

ui canvas

Preview a UI component mockup in a local browser canvas where the human directly edits it (move, resize, edit text, delete, restyle), switches mobile/desktop/custom viewports, tests it, chats with you, and clicks Save and Finish. You then turn the exported edited markup into the production component. Use before committing or rebuilding a feature just to check a visual change.

skill★ 3171440 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

--- name: ui-canvas description: Preview a UI component mockup in a local browser canvas where the human directly edits it (move, resize, edit text, delete, restyle), switches mobile/desktop/custom viewports, tests it, chats with you, and clicks Save and Finish. You then turn the exported edited markup into the production component. Use before committing or rebuilding a feature just to check a visual change. metadata: origin: ECC version: "1.0.0"

---

UI Canvas

Approve-before-you-build loop for user interface work: you write a quick, self-contained HTML mockup of the component, the human opens it in the browser and adjusts it by hand like a website builder, and Save and Finish hands you the exact result to wire into the real code. Nobody has to rebuild and rerun the whole app to check a padding change.

Any component qualifies: a card, a sidebar, a modal, a settings pane, a single button state, an animation, a page section. Any harness qualifies: the loop is a CLI that prints JSON.

Shares its server, state, and hooks with plan-canvas (inspired by lavish-axi by @kunchenguid). Editing conventions follow VisBug and Onlook: Enter/Shift+Enter walk the tree, Delete removes, an edit/interact mode switch.

When to Use

it before you commit, rerun, or rebuild.

and is faster done by hand than typed.

at exact dimensions.

Do NOT use for: plan or document review (/plan-canvas), running the real app, remote URLs, or components you cannot render as plain HTML/CSS/JS in one file. The canvas serves local files only.

How It Works

Invoke the CLI as ecc-ui-canvas (bin from the ecc-universal package, on PATH after a global or plugin install; node "$CLAUDE_PLUGIN_ROOT/scripts/ui-canvas.js" also works). It runs the same detached loopback server as plan-canvas (127.0.0.1:4517), keyed by artifact path; there are no session ids.

1. Write the mockup

Write one self-contained .html file (for example .claude/previews/<name>.html or next to the component): markup, a <style> block, and any <script> the component needs to behave (tabs, toggles, open/close, animation). Rules:

the existing CSS or theme file first; do not invent a palette.

every human edit against a CSS selector; stable names make the export map cleanly back to your code.

states. The canvas renders at true CSS-pixel viewport sizes, so media queries behave exactly as they would in the app.

relative path; a data: URI or an inline SVG also works.

2. Open and listen

ecc-ui-canvas open .claude/previews/pricing-card.html --viewport desktop --title "Pricing card"
ecc-ui-canvas await .claude/previews/pricing-card.html   # run in the background; leave it running

--viewport takes mobile (393×852), desktop (fills the window), custom, or exact WxH such as 1024x768. Run await in the background if your harness time-limits foreground commands; re-run it if interrupted, queued feedback is never lost. While it runs, the canvas shows "<your harness> listening" so the human knows you are connected.

3. Handle what comes back

await prints JSON when the human acts. Items:

{ "kind": "chat", "text": "change this to dark gray in the brand colors",
  "anchor": { "selector": "#pricing-card", "tag": "article", "snippet": "Most popular Team plan…", "size": { "width": 720, "height": 388 } },
  "pendingEdits": ["resized img.art to 220px wide, 220px tall (was 260×260)", "removed button.btn.secondary"] }

they sent it; pendingEdits summarizes hand edits they have made that are

not yet in your file. Make the requested change in the mockup file. The preview reloads within a second and re-applies their pending edits on top, so do not bake pendingEdits into the file yourself: they are context, and doubling them up would misplace things. Answer in the canvas and keep listening with one command:

  ecc-ui-canvas await <file> --reply "Background is now var(--gray-800) from the brand tokens."

Speed matters here. Run ecc-ui-canvas typing <file> --state thinking the moment you start, edit the file, then reply. Under two seconds from request to repaint is the target for a one-property change.

{ "id": "fb-123", "kind": "edits", "editCount": 3, "edits": [ { "kind": "resize", "selector": "img.art", "width": 220, "height": 220, "before": { "width": 260, "height": 260 } } ],
  "viewport": { "preset": "mobile", "width": 393, "height": 852 },
  "exportPath": "/abs/.claude/previews/pricing-card.apply-mf3k2x-9a1c.edited.html", "editsPath": "/abs/.claude/previews/pricing-card.apply-mf3k2x-9a1c.edits.json" }

edits written into the mockup now. Replace the mockup file with the contents of exportPath (it is the full DOM they are looking at, with their inline-style changes), tidy it into real CSS if it is messy, keep it self-contained, and reply. Each Apply writes its own <name>.apply-<batch>.* pair, so a queued earlier batch keeps its own snapshot. The canvas keeps showing submitted edits until it recognizes the exact exported snapshot or you explicitly acknowledge the incorporated batch. After incorporating a batch, acknowledge its feedback ID with ecc-ui-canvas await <file> --ack fb-123 --reply "Applied the requested changes.". Multiple IDs may be comma-separated. Do not acknowledge a queued batch while answering an earlier chat. Exact copies of exported snapshots are recognized automatically; an unrelated file save is not acknowledgment. If a submitted batch no longer matches the file, resolve it before applying more changes.

{ "kind": "finish", "editCount": 5, "edits": [ "…" ], "viewport": { "preset": "desktop", "width": 1412, "height": 806 },
  "exportPath": "…/pricing-card.edited.html", "editsPath": "…/pricing-card.edits.json" }

(sessionEnded: true). Read exportPath, diff it against your original mockup, read editsPath for the intent behind each change, and reproduce that exact look in the real component with full functionality: real tokens, responsive rules, accessible markup, the project's framework. Then commit per the repo's rules and report in chat. Do not reopen the canvas.

Edit kinds you will see in edits: text (before/after, plus htmlAfter when inline markup was kept), resize (border-box px), move (from/to parent selector and index), nudge (dx/dy px offsets the human applied by dragging with Alt or arrow keys; translate to margin or alignment, not position: relative), remove, and style (property, computed before, after; after: null means they deleted the property, so border → none, box-shadow → none, padding → 0). An edit flagged stale: true could not be re-applied after one of your reloads; ask about it rather than guessing.

4. End

ecc-ui-canvas end <file> closes a session you opened and no longer need. {"status":"ended","endedBy":"user"} means the human closed it without saving: stop polling and do not reopen unless asked (open --reopen).

What the Human Can Do

Edit mode (default): click selects, with hover and selection outlines and a size badge; double-click edits text; corner and edge handles resize (images keep their ratio unless Shift is held); dragging reorders among siblings or into another container with an insertion marker; Alt-drag or arrow keys nudge (Shift for 10 px); Delete or Backspace removes; Enter steps into the first child, Shift+Enter to the parent, Tab between siblings; Cmd/Ctrl+Z and Shift+Cmd/Ctrl+Z undo and redo. The inspector shows the selected element's breadcrumb and grouped slider rows (size, fill, text, spacing, border, effects). Drag a slider, or double-click a value to type one (sanitized and clamped; arrow keys step). A color swatch opens hue, saturation, lightness, and alpha sliders; the hex field also takes rgb() or a color name; the x button clears a property.

Interact mode (Cmd/Ctrl+I): clicks, hovers, and keyboard reach the component so they can try the tabs, toggles, and animations exactly as a user would. A pause button freezes animations and transitions for inspection.

Viewport bar: desktop (fills the stage), mobile (iPhone-class 393×852 with a device frame), or exact width × height; a rotate button swaps the two. The preview scales down only when the stage is smaller than the chosen size, never the other way, so media queries are honest.

Rules

use plan-canvas for documents.

restores the human's pending edits, selection, and scroll. Never re-run open to refresh.

only from an edits or finish payload, from exportPath.

session is open.

per-Apply .apply-<batch>.* pairs) are review artifacts, not production code. Do not commit them unless the repo keeps previews; delete the .apply-* pairs once the mockup is updated.

(ECC_PLAN_CANVAS_IDLE_MS), and keeps state in ~/.claude/plan-canvas/ (ECC_PLAN_CANVAS_STATE_DIR). ECC_CANVAS_AGENT overrides the detected harness name shown in the browser.

Examples

Redesign with preview before commit

# user: "Make the pricing card friendlier, then show me before you commit."
# → write .claude/previews/pricing-card.html using tokens from src/styles/tokens.css
ecc-ui-canvas open .claude/previews/pricing-card.html --title "Pricing card"
ecc-ui-canvas await .claude/previews/pricing-card.html
# → {"status":"feedback","items":[{"kind":"chat","text":"change this to dark gray in the brand colors","anchor":{"selector":"#pricing-card",…},"pendingEdits":[…]}]}
ecc-ui-canvas typing .claude/previews/pricing-card.html --state thinking
# → edit the file: background: var(--gray-800)
ecc-ui-canvas await .claude/previews/pricing-card.html --reply "Card background is now --gray-800."
# → {"status":"feedback","sessionEnded":true,"items":[{"kind":"finish","editCount":5,"exportPath":"…/pricing-card.edited.html",…}]}
# → read the export, port the look into src/components/PricingCard.tsx, commit

Mobile check of an existing component

ecc-ui-canvas open .claude/previews/sidebar.html --viewport mobile
ecc-ui-canvas await .claude/previews/sidebar.html

Anti-Patterns

component instead.

milliseconds and reloads in under a second; that is the point.

again.