← Back to LabDebora’s Lab / Publication

How to build a Figma plugin that imports component APIs from code.

A practical bridge that reads TypeScript props, variants, defaults and token references instead of rebuilding coded components by hand.

Written from practice↓ Read the field note
[ 00 / Premise ]

Once code became the source of truth, I no longer wanted designers copying its structure back into Figma by hand. So I built a bridge instead of another checklist.

[ 01 / 04 ]

Define the job before opening the Plugin API

The job was not ‘generate a Figma component’. It was narrower: read a maintained component catalogue and carry names, options and token references into a place designers could inspect.

That boundary mattered. A plugin can reproduce metadata reliably; it cannot decide whether a pattern should be one component or five.

[ 02 / 04 ]

Create a catalogue code can explain

I built a TypeScript catalogue builder that describes each component’s props, variants, booleans, slots, defaults, CSS token references and Storybook metadata.

The catalogue becomes a stable interchange layer. The plugin does not need to parse an entire repository or guess intent from a screenshot.

[ 03 / 04 ]

Keep the plugin architecture small

The main plugin process reads the catalogue and creates or updates Figma nodes. A separate UI lets the designer select components, review incoming properties and see warnings before anything changes.

  1. manifest.json defines permissions and entry points.
  2. code.ts talks to the Figma Plugin API.
  3. ui.html handles selection, progress and review.
  4. Typed messages keep the two contexts explicit.
[ 04 / 04 ]

Design for partial failure

Imports fail in ordinary ways: a font is missing, a token has no match or a property changed since the last sync. I log those mismatches instead of silently inventing a substitute.

That makes the plugin useful as a diagnostic tool too. Drift becomes visible while it is still inexpensive to discuss.

[ Technical evidence ]

From a coded catalogue to an editable component.

The plugin carries component structure into Figma without flattening it. Selection begins with the maintained catalogue; the output preserves the properties designers need to work with the component.

01 / Source contract

The component already describes its usable structure.

CheckboxSize, visual states, booleans and defaults are explicit in TypeScript. The importer has a typed contract to interpret instead of inferring variants from pixels.

TypeScript source for Checkbox showing size, visual state, checked and indeterminate properties and their defaults.
02 / Catalogue to Figma

The importer begins with a real coded component.

Inside Figma, the plugin exposes the components available in the local design-system catalogue. Selection replaces rebuilding structure from a screenshot or remembering another naming convention.

Code Component Importer running inside Figma with the catalogue dropdown open over the Checkbox component documentation.
03 / Editable output

The result is a component set, not a pasted picture.

The generated Checkbox keeps 36 variants and exposes Size, Selection and State as editable Figma properties. Its source path remains visible, making the relationship with code inspectable.

Generated Checkbox component set in Figma with 36 variants and editable Size, Selection and State properties.
[ Open materials ]

What you can reuse.

Not just a conclusion: these are the working artefacts behind the argument. Open them, question them and adapt what is useful.

01

Catalogue builder

The interchange layer that extracts component structure before Figma imports it.

Read the builder
02

Plugin implementation

Manifest, plugin process and UI kept together in a small inspectable tool.

Inspect the plugin
03

Source component

The typed Checkbox contract used to create editable Figma properties.

Read Checkbox.tsx