A Figma plugin that exports local variable collections as CSS custom properties, with an extensible generator architecture for adding more output formats in the future.
- Reads all local variable collections in your Figma file
- Exports as CSS custom properties (
--variable-name: value) - Supports all Figma variable types: Color, Number, String, Boolean, and Aliases
- Multiple mode strategies: first mode only,
data-themeattribute, or CSS class - Color format options: HEX, RGB, HSL
- Number unit options: raw,
px,rem - Optional variable prefix (e.g.
ds-→--ds-color-primary) - Copy to clipboard or download as a
.cssfile - Linear-inspired dark UI with animated splash screen
- Open Figma Desktop
- Go to Plugins → Development → Import plugin from manifest…
- Select
manifest.jsonfrom this project folder - Open any Figma file that has local variable collections
- Run the plugin from Plugins → Development → Variable Exporter
- Select the collections you want to export
- Configure options (format, color format, number unit, mode strategy)
- Click Copy to copy the output or Save to download as a
.cssfile
| Tool | Purpose |
|---|---|
| TypeScript | Plugin logic and UI |
| esbuild | Bundling — compiles TS and inlines JS/CSS into a single ui.html |
| Figma Plugin API | Reads variable collections via getLocalVariableCollectionsAsync |
Variable Exporter/
├── manifest.json # Figma plugin config (entry points, icon)
├── icon.svg # Plugin icon (128×128 rounded square)
├── build.js # esbuild build script
├── package.json
├── tsconfig.json
└── src/
├── types.ts # Shared message types (plugin ↔ UI)
├── plugin/
│ └── code.ts # Runs in Figma sandbox — reads variables, handles resize
├── generators/
│ ├── types.ts # Generator interface
│ ├── css.ts # CSS custom property generator
│ └── index.ts # Generator registry (add new formats here)
└── ui/
├── index.html # Shell HTML — JS and CSS are inlined at build time
├── index.ts # UI logic — rendering, options, copy/download
└── styles.css # Linear-inspired dark theme
The build script (build.js) uses esbuild to:
- Bundle
src/plugin/code.ts→dist/code.js(Figma sandbox) - Bundle
src/ui/index.ts→ temporary JS bundle - Inline the JS bundle and
styles.cssintosrc/ui/index.html→dist/ui.html
Figma loads dist/code.js as the plugin logic and dist/ui.html as the plugin window.
The plugin code and UI run in separate sandboxes and communicate via message passing:
UI → Plugin: { type: 'ready' } on load
{ type: 'resize', height } after every render
{ type: 'close' } on close
Plugin → UI: { type: 'collections-data', collections }
{ type: 'error', message }
- Create
src/generators/your-format.tsimplementing theGeneratorinterface:
import type { Generator } from './types';
export const yourGenerator: Generator = {
id: 'your-format',
label: 'Your Format',
fileExtension: 'txt',
generate(collections, options) {
// return the generated string
return '';
},
};- Register it in
src/generators/index.ts:
import { yourGenerator } from './your-format';
export const generators: Generator[] = [
cssGenerator,
yourGenerator, // ← add here
];It will automatically appear in the Format dropdown in the UI.
# Install dependencies
npm install
# Build once
npm run build
# Watch mode (rebuilds on file changes)
npm run watchAfter building, reload the plugin in Figma Desktop to pick up changes.