| name | vibefigma-figma-to-react |
| description | Convert Figma designs to production-ready React components with Tailwind CSS using VibeFigma |
| triggers | ["convert figma design to react","generate react component from figma","import figma file as react code","transform figma to tailwind react","extract react components from figma","figma to code conversion","parse figma design into typescript","create react component from figma url"] |
VibeFigma - Figma to React Converter
Skill by ara.so — Design Skills collection.
VibeFigma is an open-source tool that transforms Figma designs into production-ready React components with Tailwind CSS. It uses the official Figma API to extract designs and generate clean, maintainable TypeScript/React code.
Installation
VibeFigma can be used without installation via npx, or installed globally/locally:
npx vibefigma
npm install -g vibefigma
npm install --save-dev vibefigma
Prerequisites
You need a Figma Personal Access Token:
- Go to https://www.figma.com/settings
- Scroll to Personal Access Tokens
- Click Generate new token
- Copy the token and store it securely
Set the token as an environment variable:
export FIGMA_TOKEN=your_figma_access_token
Or create a .env file:
FIGMA_TOKEN=your_figma_access_token
CLI Usage
Interactive Mode (Easiest)
npx vibefigma --interactive
The CLI will prompt you for:
- Figma URL
- Access token (if not in env)
- Output paths
Direct Command
npx vibefigma "https://www.figma.com/design/FILE_ID/FILE_NAME?node-id=NODE_ID"
npx vibefigma "https://www.figma.com/design/FILE_ID/FILE_NAME?node-id=NODE_ID" --token YOUR_TOKEN
npx vibefigma "https://www.figma.com/design/FILE_ID/FILE_NAME?node-id=NODE_ID" \
--component ./src/components/Hero.tsx \
--assets ./public/images
npx vibefigma "https://www.figma.com/design/FILE_ID/FILE_NAME?node-id=NODE_ID" --force
Common Options
npx vibefigma [url] --no-tailwind
npx vibefigma [url] --optimize
npx vibefigma [url] --clean
npx vibefigma [url] --no-responsive
npx vibefigma [url] --no-fonts
npx vibefigma [url] --no-absolute
Full CLI Options
Options:
-V, --version Output version
-t, --token <token> Figma access token (overrides FIGMA_TOKEN)
-u, --url <url> Figma file/node URL
-c, --component <path> Component output path (default: ./src/components/[ComponentName].tsx)
-a, --assets <dir> Assets directory (default: ./public)
--no-tailwind Disable Tailwind CSS
--optimize Optimize components
--clean Use AI code cleaner
--no-classes Don't generate CSS classes
--no-absolute Don't use absolute positioning
--no-responsive Disable responsive design
--no-fonts Don't include fonts
--interactive Force interactive mode
-f, --force Overwrite existing files without confirmation
-h, --help Display help
Real-World Examples
Example 1: Convert Login Form
npx vibefigma \
"https://www.figma.com/design/4i8Tp5btFPRqtkYXplnfT6/50-Web-Sign-up-log-in-designs--Community-?node-id=26-2944" \
--component ./src/components/LoginForm.tsx \
--assets ./public/login-assets \
--force
Generated output (example):
import React from 'react';
export const LoginForm: React.FC = () => {
return (
<div className="flex flex-col items-center justify-center min-h-screen bg-gray-50">
<div className="w-full max-w-md p-8 space-y-6 bg-white rounded-lg shadow-md">
<h2 className="text-2xl font-bold text-center text-gray-900">
Sign In
</h2>
<form className="space-y-4">
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email
</label>
<input
id="email"
type="email"
className="w-full px-3 py-2 mt-1 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
placeholder="you@example.com"
/>
</>
Password
Sign In
);
};
Example 2: Generate Multiple Components
mkdir -p src/components/hero
mkdir -p public/hero-assets
npx vibefigma \
"https://www.figma.com/design/YOUR_FILE_ID?node-id=HERO_NODE_ID" \
--component ./src/components/hero/Hero.tsx \
--assets ./public/hero-assets \
--optimize
Example 3: Without Tailwind (Regular CSS)
npx vibefigma \
"https://www.figma.com/design/YOUR_FILE_ID?node-id=NODE_ID" \
--no-tailwind \
--component ./src/components/CustomCard.tsx
This generates a component with inline styles or CSS modules instead of Tailwind classes.
API Server Usage
VibeFigma includes a REST API for programmatic conversions.
Starting the Server
bun install
bun run dev
bun run start
Configuration
Create .env file:
GOOGLE_GENERATIVE_AI_API_KEY=your_google_ai_key_here
PORT=3000
HOST=0.0.0.0
CORS_ORIGIN=*
FIGMA_TOKEN=your_figma_token_here
API Endpoint
interface ConversionRequest {
figmaUrl: string;
token?: string;
options?: {
useTailwind?: boolean;
optimize?: boolean;
clean?: boolean;
responsive?: boolean;
includeFonts?: boolean;
};
}
interface ConversionResponse {
component: string;
assets: Array<{
name: string;
url: string;
data?: string;
}>;
}
Example API Call
const response = await fetch('http://localhost:3000/v1/api/vibe-figma', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
figmaUrl: 'https://www.figma.com/design/FILE_ID?node-id=NODE_ID',
token: process.env.FIGMA_TOKEN,
options: {
useTailwind: true,
optimize: true,
responsive: true,
},
}),
});
const { component, assets } = await response.json();
await fs.writeFile('./src/components/Generated.tsx', component);
for (const asset of assets) {
const assetData = await fetch(asset.url);
await fs.writeFile(`./public/${asset.name}`, await assetData.arrayBuffer());
}
Common Patterns
Pattern 1: Batch Conversion Script
import { execSync } from 'child_process';
import path from 'path';
interface FigmaComponent {
name: string;
url: string;
outputPath: string;
}
const components: FigmaComponent[] = [
{
name: 'Header',
url: 'https://www.figma.com/design/FILE_ID?node-id=HEADER_NODE',
outputPath: './src/components/Header.tsx',
},
{
name: 'Footer',
url: 'https://www.figma.com/design/FILE_ID?node-id=FOOTER_NODE',
outputPath: './src/components/Footer.tsx',
},
];
for (const comp of components) {
console.log(`Converting ${comp.name}...`);
execSync(
`npx vibefigma "${comp.url}" --component ${comp.outputPath} --force`,
{ stdio: 'inherit' }
);
}
Pattern 2: CI/CD Integration
name: Sync Figma Designs
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Convert Figma to React
env:
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}
run: |
npx vibefigma "${{ vars.FIGMA_URL }}" \
--component ./src/components/DesignSystem.tsx \
--force
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: 'chore: sync Figma designs'
Pattern 3: Custom Post-Processing
import { execSync } from 'child_process';
import fs from 'fs/promises';
async function convertAndCustomize(figmaUrl: string, outputPath: string) {
execSync(
`npx vibefigma "${figmaUrl}" --component ${outputPath} --force`,
{ stdio: 'inherit' }
);
let content = await fs.readFile(outputPath, 'utf-8');
content = `import { motion } from 'framer-motion';\n${content}`;
content = content.replace(
/<div className="/g,
'<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} className="'
);
content = content.replace(/<\/div>/g, '</motion.div>');
await fs.writeFile(outputPath, content);
console.log(`✅ Generated and customized: ${outputPath}`);
}
await convertAndCustomize(
'https://www.figma.com/design/FILE_ID?node-id=NODE_ID',
);
Troubleshooting
Issue: "Invalid Figma token"
Solution: Verify your token is correct and not expired:
curl -H "X-Figma-Token: YOUR_TOKEN" \
https://api.figma.com/v1/me
Issue: "Node not found"
Solution: Ensure your Figma URL includes the correct node-id parameter:
https://www.figma.com/design/FILE_ID/FILE_NAME?node-id=123-456
Issue: Generated code has inline styles instead of Tailwind
Solution: Ensure Tailwind is not disabled:
npx vibefigma [url] --component ./output.tsx
npx vibefigma [url] --component ./output.tsx --optimize
Issue: Assets not downloading
Solution: Check asset directory permissions and path:
mkdir -p ./public/assets
npx vibefigma [url] --assets $(pwd)/public/assets
Issue: Component has positioning issues
Solution: Try disabling absolute positioning:
npx vibefigma [url] --no-absolute --responsive
Issue: Fonts not loading
Solution: Ensure font imports are enabled and Tailwind config includes fonts:
module.exports = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'system-ui', 'sans-serif'],
},
},
},
};
Integration with Development Workflow
Next.js Integration
npx vibefigma [url] \
--component ./app/components/FigmaComponent.tsx \
--assets ./public/figma-assets
Vite/React Integration
npx vibefigma [url] \
--component ./src/components/FigmaComponent.tsx \
--assets ./public/assets
Storybook Integration
import type { Meta, StoryObj } from '@storybook/react';
import { FigmaComponent } from './FigmaComponent';
const meta: Meta<typeof FigmaComponent> = {
title: 'Design System/FigmaComponent',
component: FigmaComponent,
};
export default meta;
type Story = StoryObj<typeof FigmaComponent>;
export const Default: Story = {};
Best Practices
- Version Control: Always commit generated components to track design changes over time
- Naming Conventions: Use descriptive component names that match Figma frame names
- Asset Management: Organize assets in subdirectories per component
- Review Generated Code: Always review and test generated components before production use
- Incremental Updates: Use
--force flag carefully; review diffs when regenerating existing components
- Environment Variables: Never commit tokens; always use environment variables
- AI Optimization: Use
--clean flag only when GOOGLE_GENERATIVE_AI_API_KEY is available for better code quality
Resources