Guide

Theme editor

A visual editor for the whole page: every block, every token, and the conditions under which each block appears.

Open the editorStarter templates

The document is the page

The editor does not have a preview renderer. It has a document, and LB.page() renders it — the same function a published page calls. Anything you see in the canvas is what ships, because there is no second implementation that could drift from the first.

Structural keys carry a $ because seven components already have a name prop, two have an id and one has a meta. Without the prefix, { "type": "profile-header", "name": "Mira" } would be ambiguous — and the original flat block format, which every page written against the first release uses, is exactly that shape. It still loads: every non-structural key is lifted into props untouched.

The document validates against dist/schemas/theme.json, which is generated from the same setting tables the compiler walks, so the schema cannot describe a setting the editor does not have.

Global settings and overrides

Every setting compiles to a CSS custom property. Components never write raw colours or sizes — they read --lb-primary, --lb-surface, --lb-r-lg — so restyling the page is re-declaring a token, and scoping that same declaration to one block is the per-block override:

The cascade supplies inheritance; nothing in the editor has to walk a tree and merge. Two consequences worth relying on:

  • Only differences are emitted. A document nobody has touched compiles to zero bytes. That is what makes the override dots in the inspector honest — “overridden” is a fact about the document, not a guess.
  • Overrides survive a theme change. Switching the page from light to dark re-declares the page-scope tokens; a block that set its own colour keeps it, because its declaration is still more specific.

Ten global groups — theme, background, typography, palette, layout, spacing, container, radius, shadow, motion — and thirteen block groups. A block group only appears for components that can use it: there is no icon panel on a component with no icon.

Display rules

A block can carry conditions: device, viewport, country, language, browser, operating system, colour scheme, date and time window, weekday, hour, audience and tag. Rules are evaluated at render time and again on resize and scheme change.

A hidden block stays in the DOM, marked data-lb-hidden and hidden, rather than being removed. Re-evaluating on resize is then an attribute flip, not a re-render — which matters because a re-render would restart every animation and lose focus.

  • These signals are weaker than they look. Country is inferred from the browser's time zone against a partial table, and returns nothing rather than a guess when it cannot tell — so a rule keyed to country will not fire for a reader behind a VPN or in a zone the table does not list. Browser and OS come from the user-agent string, which lies routinely. Every condition type states its own limitation in the editor, next to the control. Use rules for tailoring, never for anything that has to be true.

Modes

ModeWhat it edits
DesignGlobal settings and per-block style overrides.
ContentComponent props, with controls derived from each component's own prop table.
RulesConditions, plus an environment simulator for testing them.
CodeThe document as JSON, editable, with exports for JSON, a standalone HTML page, and the compiled CSS.
PreviewThe page with the editor chrome out of the way.

The canvas is an iframe, not a scaled div. The kit's responsive behaviour is @media (min-width: …), and a media query inside a transformed element measures the outer viewport — so a scaled-div mobile preview renders the desktop layout, convincingly and wrongly. An iframe has its own viewport, so the breakpoints fire where they will fire for a reader.

Keyboard

KeysAction
⌘Z / ⇧⌘ZUndo, redo. A slider drag is one entry, not sixty.
↑ ↓Select the previous or next block.
⌥↑ ⌥↓Move the selected block.
⌘DDuplicate.
⌘C / ⌘VCopy and paste the block.
⌥⌘C / ⌥⌘VCopy and paste styles only.
⇧⌥⌘VPaste styles to every block of the same type.
⌘+ ⌘− ⌘0Zoom in, out, fit.
⌘PPreview mode.
?This list, in the editor.

Embedding the editor

Two files on top of the kit, and one element:

data-asset-base is the path from the page to the kit's root; the canvas needs it to load the stylesheet and script into its iframe. To mount it yourself instead, or to supply your own starting document:

The editor keeps the working document in localStorage so a reload does not lose it. Nothing is sent anywhere: the editor makes no network request, exactly like the kit.

Limits

  • No multi-page or multi-user model. One document, one browser, one localStorage key. There is no server, so there is no sharing, no versioning and no conflict resolution.
  • Uploads are URLs. Image and file fields take a URL. There is no asset pipeline, because there is no backend to put one in front of.
  • Rules are advisory. See the caveat above. They are a presentation tool, not an access control.
  • Not yet exercised in a real browser. The engine, the compiler and the rules are covered by the test suite in jsdom, and every starter template renders through the new path — but the editor's own interface, its drag behaviour and its iframe canvas have been reasoned about rather than clicked. That gap is recorded in the roadmap.
Navigation

Start here

Foundations

Components

See it

On this page