Isomer Studio

@elastic/isomer-studio is a learning and testing shell for any Isomer pack. Run it in a pack's package directory, and it shows:

  • a Home page with what the Studio is for, a primitive search, where to start, featured primitives with live previews, the surfaces the runtime renders, and what it loaded;
  • a gallery of every primitive, grouped as the pack's authoring groups are, whose React previews mount as they near the viewport and unmount once well past it. Previews are pictures: they are hidden from assistive technology and take no input, so a link drawn inside one does not respond. Each tile's Open in Workbench link opens its example. Each preview sits in a well at least 16:9, a slide's shape, so a slide's preview does not shift the page as it arrives; a taller preview grows its well when it first mounts, and a shorter one leaves space below it;
  • a Reference page per primitive, with its purpose, guidance, props and live examples to teach its use;
  • a Workbench for editing a composition and seeing its live preview;
  • a composition editor that loads and shares a whole composition by URL, like the TypeScript Playground;
  • the same composition on every surface the runtime has: React, HTML, Snapshot, PNG, Slack, Markdown and text.

It ships as a command-line tool, not a React library. EUI, Emotion and Monaco are bundled into it, so a pack never takes them as dependencies.

npx @elastic/isomer-studio init
npx @elastic/isomer-studio
npx @elastic/isomer-studio build --out dist/studio --base /studio/
npx @elastic/isomer-studio check --report studio-report.json
		
  1. a config for the packs the package exports
  2. a local server with hot updates
  3. a static site
  4. a headless CI gate

Each command reads isomer-studio.config.ts (or .tsx or .js) from the current directory unless --config names another file, and without one says to run init; see init. Nothing needs installing first: the Studio uses the pack's React, SDK and zod, and brings the runtime. To pin the version, install @elastic/isomer-studio as a dev dependency and run npx isomer-studio; a config type-checks either way, with @elastic/isomer-runtime installed for its createIsomerRuntime import (see Typing the config). In this repository, pnpm studio:dev runs the Studio from source against the root config.

To try what has merged to main since the last release, run npx @elastic/isomer-studio@next, with any command and flags after it. next is a snapshot of every Isomer package, published on each push to main that changes one, as a prerelease of the patch after the latest release (<major>.<minor>.<patch + 1>-main.<UTC commit time>.g<short sha>) that latest and the latest release's caret range never select. The Studio still loads the SDK, and the runtime when the pack has one, from the pack, so a pack on a released SDK keeps it; install the SDK and runtime at @next as well to try their unreleased changes.

In the interface, Reference teaches how and when to use each primitive, while Workbench is where you edit compositions.

The Workbench: a composition's JSX beside its Web, PNG, Slack, Markdown and text output

init writes one like this, registering each pack the package's entry exports. It types the config with StudioConfig from the SDK, which the pack already has, so the pack's type checker passes it without the Studio installed; in a project that installs the Studio, it uses defineStudioConfig instead:

// isomer-studio.config.ts
import { createIsomerRuntime } from '@elastic/isomer-runtime';
import type { StudioConfig } from '@elastic/isomer-sdk';

import { myPack } from './src/index';

export default {
  title: 'my-pack',
  runtime: createIsomerRuntime({ packs: [myPack] }),
} satisfies StudioConfig;
		

That is enough for a pack whose primitives render inside a plain view. A pack with a frame that needs a particular root, or with styling the React surface must load, adds previewExample and stylesheet; see The config.

Home: the hero, featured primitives with live previews, the surfaces, and what the config loaded

The Reference page for the slides pack's pipeline primitive

  • Home. An empty hash, #/home, and the mark in the header open Home, and so does an unknown hash or app id, with a notice that names the address and leaves it in the address bar. A hot update that adds the missing app opens it. Home is a full page in the current color mode, without the header or the primitive nav. It leads with the config's title and the color mode switch, then the question the Studio answers, what it is for, a count of primitives, groups and surfaces, and links to the gallery, the Workbench, the composition editor and the Isomer documentation. Below are the featured primitives (the config's featured, or six drawn at random), each with a live preview of its first example and links to its Reference page and the Workbench; then one composition, every surface: a tile for each surface the runtime renders, with what it is; then what the config loaded: packs, apps and views. With no apps or no views, that section says how to add them and links to the documentation. Home's own search, under the hero's headline, finds a primitive by name or purpose and opens it in the mode last used, with the same ⌘K shortcut as the header search on every other page.
  • Navigation. With one pack, the sidebar lists primitives under that pack's authoring groups, in the pack's group order and alphabetically within each group. With more than one pack, each pack is a labelled group holding its groups; group titles are labelled groups too, not headings, so they do not repeat a page's own outline. Primitives no group claims are listed last, under Uncategorized. Each group collapses, the browser remembers which are closed, and a filter opens every group it matches. Resting the pointer on a name shows its first example and purpose. On a phone-width screen the sidebar leaves the page and the header's menu button opens it over the content (Commands has the details). A "Skip to content" link is the first tab stop; it moves focus to the page and closes the phone menu. Each page sets the browser tab's title (for example "Pipeline · Workbench · Isomer Studio"), and focus moves to the page when it changes. A link that names no primitive opens the first one, with a notice that names the link. Reference pages are at #/docs/<type>/<example>, the gallery at #/docs/gallery (#/docs/gallery/<group> scrolls to a group's heading), and the Workbench at #/dev/<type>/<example>. In the editor, Tab indents; Control+M (Control+Shift+M on macOS) lets Tab move focus out of it.
  • Surfaces. The Workbench preview starts with every output selected, in one column at every width. The Outputs menu checks the outputs to compare: with every output selected, choosing one shows it at full size, and choosing another adds it. Rendered or Output source applies to every card at once. The Reference example card starts on the first surface, with the example picker on the left and the same menu on the right. Its view selector switches among Rendered, Output source, and Example source; the latter shows the example as JSX or JSON.
  • Zoom. With one surface picked, the preview's zoom menu scales the React, HTML, Snapshot and PNG previews: Fit width shrinks a preview to the panel's width and never enlarges it, and fixed levels run from 50% to 200%.
  • Preview background. Visual previews sit on a dotted grid with a subtle shadow around the render in both color modes, making render boundaries and transparent areas visible. The grid and shadow stay at a fixed size as the render zooms.
  • Color mode. The header, and Home, offer Light, Dark, and System. System follows the operating system, including when it changes. The choice is remembered per browser, and previews render in the resolved mode. The Workbench keeps the editor's subdued background and uses a deeper output-pane background and plain dotted preview canvases to distinguish the working areas in both modes.

Composition, above Gallery in the sidebar, opens #/compose: the Workbench for one whole composition rather than one primitive's example. Write it as JSX, with the composition's title, subtitle, theme and meta as props of <Composition>, or as JSON, which the editor checks against the runtime's composition schema. A draft with no theme previews in the Studio's color mode. Its toolbar copies the source, copies a link, downloads it as composition.tsx or composition.json, and starts a new composition from a starter or any primitive's example. The per-primitive Workbench's Open in the composition editor carries its draft across.

The composition editor: a slide composition's JSX beside its Web and PNG output

The address bar carries the draft, so copying it shares what you see, and a reload keeps it. A bare #/compose reopens the last draft in this browser, or, on a first visit, the first example of the config's first featured primitive, else of the first primitive in the nav. A link that fails to load says why and keeps the draft already in the editor, unsaved edits included; with none, it opens what a bare #/compose would. The query takes:

Parameter Loads
code Source the editor compressed into the link: UTF-8, raw deflate, then base64url. Copy a link writes one, and warns when it is longer than 8,000 characters.
src Source fetched from an https: URL, or one on the Studio's origin, without credentials, up to 1 MB and within 10 seconds. The server must allow cross-origin requests. Prefer it to a link longer than about 8,000 characters.
lang jsx or json. Without it, src's extension decides (.tsx and .jsx are JSX), else whether the source opens with { or [.
example <type>/<index>, one of the pack's examples, composed through the config's compose or previewExample. The draft leaves out the theme the Studio composed it in.

A draft over 1 MB is too large for any link, src included, since a fetched source has the same cap. Once this browser saves it, the address becomes a bare #/compose, which reopens it. If the browser cannot store it, the address is left unchanged, so it may not lead back to any earlier draft, and a warning says a reload would lose it. To share one, download it, or split it into smaller compositions. The Workbench's Open in the composition editor is disabled for a draft that prints to more than 1 MB.

JSON from a link is only data, so it renders at once. JSX from a link is code that runs in the page, and under dev it can reach the Studio's server, so the preview waits behind Run this code until you have read it, and it is not saved as this browser's draft until then. JSX this browser tab wrote or ran runs without asking.

  • Node 22.13 or later.
  • react and react-dom 18.2 or later, below 19, in the pack, because EUI's peer range stops there.
  • @elastic/isomer-sdk and zod, which the pack already has. @elastic/isomer-runtime comes with the Studio when the pack does not have it.

The config, the pack and React load from the pack's own node_modules. The Studio stops when the pack's React is not 18, or when the config and @elastic/isomer-runtime see different copies of it.

This repository's reference pack has a config at packages/isomer-primitives-slides/isomer-studio.config.ts. Its Studio is deployed with these docs at elastic.github.io/isomer/studio-app/, PNGs included.

The root isomer-studio.config.ts gathers every in-repo pack with images: false. pnpm studio:dev runs it, and each PR's CI uploads a build of it; see Review a pull request.

These docs build in two places, and the app only in one:

  • GitHub Pages hosts the docs at /isomer/studio/ and the app beside them at /isomer/studio-app/, so neither overwrites the other.
  • Codex previews of a docs change carry the docs only. Links to the app point at its Pages URL, and a PR's app preview is the CI artifact.
  • PNGs of edited compositions. A static site has PNGs for the examples it prerendered and nothing else; an edited composition shows "PNG previews of edited compositions need isomer-studio dev". See Static sites.
  • PDFs on a static site. Only dev writes PDFs, so an app's renderPdf is undefined in a static build.
  • Slack tag elements. slack-blocks-to-jsx cannot draw rich-text tag elements, so toned values render blank in the Slack preview. The Block Kit is valid, so check passes it.
  • Web fonts in the app. The app loads no web fonts, so EUI's Inter falls back to the system font.