Exporting
Export designs from the terminal — raster images, vectors, PDF, editable PowerPoint, draw.io diagrams, .fig subsets, JSX code, HTML, Storybook stories, or a video of a prototype.
The app in Pairdraw builds no longer offers PowerPoint or draw.io export; the CLI still writes both.
Image Export
pairdraw export design.fig # PNG (default)
pairdraw export design.fig -f jpg -s 2 -q 90 # JPG at 2×, quality 90
pairdraw export design.fig -f webp -s 3 # WEBP at 3×
pairdraw export design.fig -f svg # SVG vector
pairdraw export design.fig -f pdf # PDF
pairdraw export design.fig -f pptx # editable PowerPoint
pairdraw export design.fig -f drawio # draw.io diagram
pairdraw export design.fig -f fig --page "Page 1" # export one page as .fig
pairdraw export design.fig -f fig --node 1:23 # export one node as .fig
pairdraw export design.fig -f html --css tailwind # export an HTML fragment with Tailwind classesOptions:
-f— format:png,jpg,webp,svg,pdf,pptx,drawio,jsx,tailwind-jsx,html,fig,storybook;mp4,gif, orwebmrecord a prototype (Video Export)-s— export scale (default:1)-q— quality:0–100(JPG/WEBP only)-o— output path--page— page name, or--page-id— page ID--node— specific node ID
Video Export
Record the page's prototype as a video: it plays from a top-level frame, follows each After delay interaction and its Dissolve or Smart animate on a clock of its own rather than in real time, and writes every frame, so the clip is the same on every run.
pairdraw export flow.fig -f gif --start "Hero 1" # flow.gif beside the file
pairdraw export flow.fig -f mp4 --start "Hero 1" -o hero.mp4 # needs ffmpeg from a file
pairdraw export -f mp4 --start "Hero 1" -o hero.mp4 # the running app encodes it
pairdraw export app.fig -f gif --click 1.5:"Buy button" --click 3:Close--start— top-level frame name or ID to play from (default: the selected frame, or the page's first frame)--fps— frames per second (default:30, or15for GIF, which plays at most50)-s— the start frame's size in the video (default:1);--max-edge— the longest side in pixels (default:1920; a GIF is at most960)--max-duration— seconds the clip may last at most (default:30, at most120)--tail— seconds the last frame stays when the flow ends (default:1)--click—<seconds>:<layer name or ID>, a click on a layer of the frame shown at that moment; repeat it for more clicks
The clip ends when play returns to the start frame (a GIF then loops), when nothing else happens, or at --max-duration, and the command prints each step it recorded. A later frame of another shape is centred on the page color; an overlay shows over its frame behind a scrim.
GIF works everywhere. MP4 (H.264) and WebM (VP9) are encoded with WebCodecs by the running app; from a file the CLI encodes them with ffmpeg when it is on the path with libx264 and libvpx-vp9, and otherwise says which formats work. Set PAIRDRAW_FFMPEG to name a different ffmpeg binary; an empty or whitespace-only value falls back to ffmpeg from the path. Agents record the same video through the MCP export_video tool.
Font Substitution Policy
For file-backed PNG, JPG, WEBP, and PDF exports, and for pairdraw convert, choose how missing or substituted fonts are handled:
pairdraw export design.fig -f pdf --font-policy strict
pairdraw export design.fig -f png --font-policy warn
pairdraw export design.fig -f webp --font-policy allow
pairdraw convert design.pen --font-policy strictwarn(default) — report substitutions and continue exporting.strict— stop with a nonzero exit status if font preparation cannot faithfully resolve the requested faces.allow— export without the additional font-fidelity check.
Run pairdraw fonts first to inspect affected faces. Export preparation may use configured font providers, so its result can differ from the offline file diagnostic.
convert loads fonts for .pen, draw.io, and Mermaid files, which store layout intent rather than sizes: it lays them out again with their text measured in their own fonts before writing, so strict stops it before anything is written. A Mermaid flowchart (.mmd or .mermaid) is laid out as it is read, its text measured in the fonts it is drawn in.
This policy does not apply to exports from the running app, or to SVG, PowerPoint, JSX, HTML, and .fig exports. It checks font resolution, not complete visual equivalence with Figma.
JSX Export
Export as JSX with Tailwind utility classes:
pairdraw export design.fig -f tailwind-jsx # or: -f jsx --style tailwindOutput:
<div className="flex flex-col gap-4 p-6 bg-white rounded-xl">
<p className="text-2xl font-bold text-[#1D1B20]">Card Title</p>
<p className="text-sm text-[#49454F]">Description text</p>
</div>Also supports --style pairdraw for the native JSX format (see JSX Renderer).
HTML Export
Export as an HTML fragment with inline styles by default, or Tailwind utility classes:
pairdraw export design.fig -f html
pairdraw export design.fig -f html --css tailwindUse --html standalone for a browser-openable HTML document with reset styles and a page wrapper. Standalone HTML is intended as a useful visual/code handoff, not a pixel-perfect renderer replacement:
pairdraw export design.fig -f html --html standalone --css inline
pairdraw export design.fig -f html --html standalone --css tailwind
pairdraw export design.fig -f html --html standalone --css tailwind --assets externalStandalone Tailwind output is compiled during export; it does not depend on the Tailwind browser runtime. Use --assets external to write CSS and extracted image assets next to the HTML file. Use --fonts assets with external assets to resolve detected SceneGraph text fonts through Pairdraw's configured web-font providers and emit local @font-face files.
HTML export writes each layer's name as a data-name attribute. --no-layer-names leaves the names out, and --layer-ids adds each layer's ID as data-pairdraw-node-id for tools that link markup back to the document.
A font size Tailwind does not name as a step (such as 40px or 28px) exports as an arbitrary value, text-[40px], rather than a utility like text-10 that no stylesheet generates. Named steps and token-bound sizes keep their class.
HTML export is available in file mode.
Tokens in exported code
HTML and Tailwind JSX write variable-bound properties as the design tokens they come from: a fill bound to Primary is background-color: var(--color-primary), and in Tailwind bg-primary, or bg-(--name) for a token outside Tailwind's namespaces. A layer set to another mode gets that mode's attribute, such as data-theme="dark", so the tokens resolve as the canvas draws them.
A value stays literal where CSS would not reproduce it: the layer no longer draws the variable's value, the token is unitless where a length is needed, or the layer sits in a mode that only its own condition, such as a @media query, can select. Standalone HTML includes the stylesheet for the tokens it uses; for fragments and JSX, generate it with pairdraw tokens (below).
Design Tokens
Write the document's variables as CSS custom properties:
pairdraw tokens design.fig > tokens.css
pairdraw tokens design.fig --format tailwind > theme.css
pairdraw tokens design.fig --collection Theme --type COLOREach collection's default mode goes in :root. Every other mode overrides the values that differ under its condition: [data-theme="dark"] for a Theme collection's Dark mode, or the selector or @media query the mode names. Aliases stay var() references and are declared again in each mode that changes what they point to, so switching data-theme on any element restyles everything built on it.
:root {
--color-blue-500: #3b82f5;
--color-primary: var(--color-blue-500);
}
/* Theme: Dark */
[data-theme='dark'] {
--color-primary: var(--color-blue-300);
}--format tailwind puts tokens with a Tailwind v4 namespace (--color-*, --spacing-*, --radius-*, --text-*, …) in @theme, so bg-primary and rounded-card work, and adds a @custom-variant per mode, so dark:bg-surface follows the same condition. Import the file after @import "tailwindcss";. Names come from the variable's code syntax when it names a custom property (--x or var(--x)), otherwise from its name and type: Blue/500 as a color is --color-blue-500.
Tokens that cannot be written, such as boolean variables or a condition that is not a selector or query, are listed on stderr and left out. The command works in file mode and against the running app.
W3C design tokens
--format dtcg writes the variables and styles as W3C design tokens into a folder:
pairdraw tokens design.fig --format dtcg --out tokensEach collection mode is one file, Theme/Light.tokens.json and Theme/Dark.tokens.json, in the shape Figma imports as a mode: lengths in px, times in s, booleans as numbers marked com.figma.type, and aliases to another collection naming it in com.figma.aliasData. Text and effect styles become typography and shadow tokens in styles.tokens.json, kept apart because Figma's import refuses composite tokens; a text style field bound to a variable is written as a reference to that variable's token and read back as a binding. Pairdraw also records which collection each bound field's variable is in, so a path two collections share reads back to the right one; the export warns about such references, because other tools can't tell them apart. tokens.resolver.json is a DTCG resolver that switches each collection's modes and layers the rest, for tools such as Style Dictionary. Pairdraw's own fields, such as a token's rem unit, CSS name, scopes, or clamp() expression, and each mode's condition, ride in $extensions["dev.pairdraw"], so the export reads back exactly.
Import token files into a document with the import_design_tokens tool, passing each file's path and text as the tool's arguments:
jq -Rs --arg p tokens/Tokens/Default.tokens.json '{files:[{path:$p,text:.}]}' \
tokens/Tokens/Default.tokens.json > args.json
pairdraw tool call import_design_tokens design.fig --args-file args.json --writeIt reads a file per mode grouped by folder, a resolver with the files it refers to, or a Tokens Studio file with $themes. Collections and modes with existing names, and variables and styles by name, are updated; the rest is added, and nothing is deleted. The result lists what was added, updated, and skipped, with the reason for each skip.
Checking tokens against code
--check compares the variables with a stylesheet or a project folder and lists every token that differs, without changing the document. It exits with status 1 when anything differs, so a CI job can fail when the design and the code drift apart:
pairdraw tokens design.fig --check src/app.css
pairdraw tokens design.fig --check . --jsonA folder is read as --project reads it: Tailwind v4 @theme, shadcn/ui :root and .dark, and the stylesheet components.json names. Each line names the collection, variable, and mode, the value in code and on the canvas, and whether the token changed in code, on the canvas, on both, is new in code, or is gone from code. The token_drift tool reports the same for files passed as its arguments.
--sync brings the code's changes into the document and remembers the link, with its path from the document's folder, so later checks and syncs know which side changed:
pairdraw tokens design.fig --sync src/app.css --write
pairdraw tokens design.fig --sync src/app.css --conflicts code --writeA value changed only in code, and a token new in code, always comes in. A value also changed on the canvas since the last sync is left as it is and listed, unless --conflicts code takes the code's value or --conflicts canvas keeps the canvas value. A token gone from code keeps its variable. The sync_tokens tool does the same for files passed as its arguments, and the variables dialog's Pull does it for a linked stylesheet, opening a review for the values only a person can decide.
Storybook Export
Generate one CSF3 .stories.ts file per component set or component:
pairdraw export design.fig -f storybook # React stories in ./design-stories/
pairdraw export design.fig -f storybook --framework vue -o src/stories
pairdraw export design.fig -f storybook --css tailwind # components styled with Tailwind
pairdraw export design.fig -f storybook --framework html --page "Components"
pairdraw export design.pen -f storybook -o src/stories --watch # re-export on every save
pairdraw export 'src/**/*.pen' -f storybook --beside --watch # stories next to each design
pairdraw export design.fig -f storybook --rules stories.json # stories and titles by ruleFewer stories in the sidebar
Each story file opens with a Default story, the variant the design shows at rest, with every control. Every other variant or state story is tagged variant, and each file is tagged pairdraw and page:<page>, such as page:icons. Storybook's sidebar filter selects by these tags, and .storybook/main.ts can set what it shows by default, such as one story per component and no icons page:
const config: StorybookConfig = {
// …
tags: {
variant: { defaultFilterSelection: 'exclude' },
'page:icons': { excludeFromSidebar: true }
}
}Stories and titles by rule
What the tags can't do, such as leaving components out or laying an icon set out as a gallery, a rules file decides. The export reads pairdraw.stories.json from the working directory when it is there, or the file --rules names, again on every export when watching:
{
"rules": [
{ "match": "**", "title": "Design system/{page}/{name}" },
{ "match": "Icons/**", "stories": "gallery" },
{ "match": "**/_*", "stories": "none" }
]
}A rule applies to every story file whose <page>/<name> path matches its glob, by the names in the document: the page's, and the component set's or component's, or the prefix of slash-named components, such as Icons/icon. Every matching rule applies in order, so a later rule overrides an earlier one, each field on its own. generate: false keeps static stories for a Vue or React export where it would generate a component, such as for an icon set. stories is variants, a story per variant or state, as without rules; single, the Default story alone; gallery, Default and a Gallery story laying every variant out with its name, for static stories; or none, which leaves the file out. title is the file's title, with {document}, {page}, {name}, and {path}, the title it would have, filled in; titles that end up the same are kept apart as titles always are. Rules match the document's names, never a renamed title, so renaming a file never changes which rules apply to it.
Designs next to their stories
Keep each component's design file in the component's folder and export with --beside: each document's stories, design images, and .pairdraw-stories.json manifest go into that document's own folder, next to the component's code. A Storybook stories glob such as ../src/**/*.stories.ts in .storybook/main.ts then picks them up without further configuration.
Pass several documents, or a quoted glob such as 'src/**/*.pen' that Pairdraw expands itself (Node.js 22 or later). Several documents need --beside or --output; --page works with one document only. Documents are exported one after another, and when one fails the rest are still exported before the command exits with an error. --watch watches every matched document; a document created after the watch started needs another run.
Stories are titled by the document's file name, and then the page when more than one page has components: pricing.fig gives pricing/Plan picker, so documents exported together keep their stories apart. Each variant of a component set becomes a story, and its variant properties become select controls, so switching a control shows the matching variant. A set with a behaviour gets the control's own props instead: a Switch or Checkbox has a checked boolean, a Toggle pressed, a Collapsible open, and disabled when the set draws a disabled state; hover, pressed, and focus stay stories of their own. Standalone components named with slashes, such as Button/Primary and Button/Secondary, are grouped into one Button file with a Variant control. A combination the design has no variant for throws a named error in Storybook rather than showing a different variant.
Stories render the component as HTML with inline styles, like -f html, so they need no Pairdraw runtime; --framework (react, vue, or html) only changes the wrapper and the Meta/StoryObj import from @storybook/react-vite, @storybook/vue3-vite, or @storybook/html-vite. Text uses the document's font families: the export fetches their files from the web font providers the editor uses into pairdraw/<document>/ with a fonts.css every story file imports, so stories draw in those fonts, never in a fallback first. The document's design variables go there too, as custom properties in a tokens.css every story file imports, so styles bound to variables resolve as the design draws them. A family no provider has, such as Menlo, falls back to the browser's fonts, which the export warns about; --fonts none ships no font files. Static stories don't export text, boolean, or instance-swap properties yet.
With --framework vue or --framework react, every component set and standalone component becomes a real component instead, <Name>.vue or <Name>.tsx with a <Name>.module.css (with --css tailwind, Tailwind utilities in its markup, its states as variants such as data-[state=checked]:, for a project that builds Tailwind v4), except slash-named components grouped into one file, and any a rule sets "generate": false for, which keep static stories. A component without a behaviour is the design's own elements: its root is the element the design draws, a div for a frame, and it takes the root element's own props, such as onClick and class. Its variant properties are props it sets as data-* attributes, so a State=hover variant is a prop like any other; its boolean properties are boolean props that show or hide the layers bound to them; and its slot properties are content it shows in place of the design's, a named <slot> in Vue and a ReactNode prop in React, falling back to the design's content. A component whose behaviour is a Button, Switch, Checkbox, Toggle, Collapsible, Tabs, Radio group, Toggle group, Accordion, Slider, Progress, Number field, Text field, or Textarea is built on Reka UI or on Radix UI's radix-ui package, and its interaction states, such as hover and disabled, become real :hover and data-disabled styles. Its variants are compiled into a stylesheet keyed on the states Reka and Radix set (data-state, data-disabled, hover, and focus), and every other variant property is a prop the component sets as a data-* attribute. In Vue its value is a v-model such as checked or open; in React the component takes the Radix root's props, such as checked, defaultChecked, and onCheckedChange. Its text properties are string props, defaulting to the design's words, which the layers bound to them draw, with a text control in its stories.
Tabs take the open tab as value (v-model:value, or defaultValue and onValueChange in React), named by each trigger's words as a slug, such as account or password, and starting on the first; each trigger and its panel are Reka's or Radix's Tabs parts around the design's layers, every trigger drawn like the design's other triggers and taking the first trigger's look while its tab is active, and the stories get a select control and a story per tab. A Radio group, Toggle group, or Accordion writes two components: the group, which chooses one item the same way, starting on the item the design draws on, and <Group>Item from its items' component set, built as the group's item primitive (RadioGroupItem, ToggleGroupItem, or AccordionItem with its trigger in a header) and taking the value it stands for. The group uses it once per item in its items slot, with each item's value, named by its label property or else its words, and its text values. A Slider, Progress, or Number field binds its number as value (v-model:value, or defaultValue in React, a list for Radix's slider), within the range its behaviour sets, starting where the design does; the slider's range and thumb and the progress indicator drop the place the design draws them at, since the value sets it, and stories get a range control and a story at each end. A Text field or Textarea draws its text layer as a native input or textarea binding value, which in React takes the component's props; when the design draws the field filled and empty, the empty field's words are the placeholder and its look the placeholder's, and the filled look shows while the field has text. Reka UI's number field draws the input and steppers in Vue; Radix has none, so React's is a native number input whose steppers change it by a step and which settles within its range when left. Focus on a slider's thumb or a field's input draws the control's focus state. A Radio is only generated as a group's item; a Toggle or Collapsible used on its own still becomes its own component.
Inside a generated component, an instance of another component generated in the same export uses that component rather than drawing its layers: <Switch> imported from ./Switch.vue or ./Switch, set to the variant, text, and disabled values the instance shows. A control the design draws on, such as a checked switch, starts on and stays operable: a local ref bound with v-model in Vue, defaultChecked in React. The parent only places it, so the control keeps its own look and state styles. Only an instance that draws exactly as its variant, apart from its property values and where its parent places it, uses the component; one with edited text no property sets, a fill of its own, or other changes draws its own layers, so the story keeps what the design shows. Instances of components not exported, or exported only as static stories, are drawn as before. A variant property whose default the document leaves empty starts at the default variant, the one in the set's top-left corner, which opens its stories. An icon placed from a set, unless its paths were edited, is Iconify's component, <Icon icon="lucide:bell"> from @iconify/vue or @iconify/react, which loads the icon when shown.
A layer filled with a shader plays it behind its content with the shaders library's <Shader> from shaders/vue or shaders/react, each effect a child with the preset's props and telemetry off (disableTelemetry); browsers without WebGPU show nothing in its place.
Its stories render the component, and a play function clicks the control and checks its state, so the Storybook project needs reka-ui or radix-ui installed, and @iconify/vue or @iconify/react when components hold icons, and shaders when layers fill with shaders.
Stories carry parameters.design entries for @storybook/addon-designs:
- Pairdraw — when the document path is inside the current directory, an
pairdraw://link that opens the document in the desktop app and selects the variant, or its component set when another layer shares the variant's name. The scheme addresses layers by name, so a story whose variant and component names are both shared by other layers gets no link. - Design — a 2× PNG of the variant, written to
<Name>.design/next to the story and referenced withnew URL(…, import.meta.url), so Vite bundles it. Copy the parameter onto the story of your own component to compare the implementation with the design.--no-design-imagesskips rendering; font substitution follows--font-policyas in raster export.
-o names the output directory. A .pairdraw-stories.json manifest there records which document, as a path relative to the output directory, and which page generated each story and design image; commit it with the stories. An export replaces the files that a previous export of the same document generated there, including those of components since deleted or renamed; with --page, only that page's. It refuses, before changing anything, to overwrite any other file — a hand-written story, another document's, or a stray image. A one-page export whose file names shifted onto another page's stories asks for a full export instead. Without the manifest, existing stories count as someone else's, so remove them before exporting again. --watch keeps the command running and re-exports whenever the document is saved, so Storybook's hot reload follows the design; a save that cannot be read is reported and the watch continues. A missing --page or a --font-policy strict substitution still ends the command.
Live App Mode
Omit the file to export from the running app:
pairdraw export -f png # export the selection in the active document
pairdraw export --page "Components" -f png # export every layer of a page
pairdraw export --node 1:23 -f png # export one layer, on any page--page takes a page name and --page-id a page ID from pairdraw pages; either exports that page without switching the app to it. Add --document-id to export from a document other than the active one.
Live app mode supports PNG, JPG, WEBP, SVG, and PDF. PowerPoint, JSX, HTML, Storybook, and .fig exports require a file argument. File-mode thumbnail export is not currently supported.