Figma Dev Mode Basics
Dev Mode (View > Dev Mode, or toggle in top-right) shows developers exactly what they need
- CSS for layers: Copy CSS directly (padding, margin, color, font-size).
- Asset exports: Download icons, images at correct scale.
- Measurements: Spacing between elements, dimensions, alignment.
- Component mapping: Link Figma components to code components (via Code Connect or manual docs).
For designers: Before handoff, enable Dev Mode and verify measurements are correct. Use auto-layout for consistent spacing.
For developers: Inspect any layer. Copy CSS. Export assets. No guessing.
Design Tokens: The Bridge Between Design and Code
Design tokens are design decisions stored as data: colors, spacing, typography, shadows, radii. Export them as JSON, then consume in CSS, SCSS, or JavaScript.
### What Gets Tokenized
- Colors: `--color-primary: #3B6DFF;`
- Spacing: `--space-xs: 4px; --space-sm: 8px; --space-md: 16px;`
- Typography: `--font-size-body: 16px; --font-family-sans: 'Inter', sans-serif;`
- Shadows: `--shadow-sm: 0 1px 2px rgba(0,0,0,0.05);`
- Radii: `--radius-sm: 4px; --radius-md: 8px; --radius-full: 9999px;`
### Why Tokens Matter
Without tokens, developers hardcode values
```css
/* Bad: values are hardcoded */
.button {
background: #3B6DFF;
padding: 12px 20px;
border-radius: 8px;
} ```
With tokens
```css
/* Good: values reference tokens */
.button {
background: var(--color-primary);
padding: var(--space-sm) var(--space-md);
border-radius: var(--radius-md);
} ```
Change the token once, update everywhere. This keeps design and code in sync.
Exporting Design Tokens from Figma
### Method 1: Tokens Studio Plugin (Recommended)
- Install Tokens Studio (Figma plugin).
- Define tokens in Figma: Create color styles, text styles, effect styles.
- Export as JSON: Tokens Studio reads Figma styles and exports as `tokens.json`.
- Transform with Style Dictionary: Convert JSON to CSS, SCSS, JavaScript.
```bash # Install Style Dictionary npm install -g style-dictionary
# Create config cat > config.json << JSON {
"source": ["tokens.json"],
"platforms": {
"css": {
"transformGroup": "css",
"buildPath": "dist/",
"files": [{
"destination": "tokens.css",
"format": "css/variables"
}] } } } JSON
# Build tokens style-dictionary build ```
Output: `dist/tokens.css` with CSS variables.
### Method 2: Figma Variables API
Figma's Variables API exports variables directly
```javascript // Requires Figma API token const response = await fetch('https://api.figma.com/v1/files/:fileKey/variables/local', {
headers: { 'X-Figma-Token': 'YOUR_TOKEN' }
});
const variables = await response.json(); console.log(variables); ```
Transform the response into CSS
```javascript const css = variables.variableCollections.map(v => `--${v.name}: ${v.value};` ).join('\n'); ```
### Method 3: Manual Export (Small Projects)
For small projects, manually copy Figma styles
- Open Figma file.
- Go to Design Panel > Local Styles.
- Copy color hex, spacing values, font specs.
- Paste into `tokens.css`:
```css :root {
--color-primary: #3B6DFF;
--color-background: #0A0D12;
--space-xs: 4px;
--space-sm: 8px;
--font-size-body: 16px;
} ```
Component Mapping
Developers need to know which Figma component maps to which code component.
### Figma Code Connect (Official)
Code Connect links Figma components to GitHub code
- Set up Code Connect in Figma (requires GitHub integration).
- Annotate components: Map `Button/Primary` to `<Button variant="primary">`.
- Developers see code examples directly in Dev Mode.
### Manual Documentation
If Code Connect isn't set up, document mappings in a README or Notion
| Figma Component | Code Component | Props | |----------------|----------------|-------| | Button/Primary | `<Button variant="primary">` | `variant`, `size`, `disabled` | | Icon/Home | `<Icon name="home">` | `name`, `size` | | Card/Default | `<Card>` | `title`, `description`, `image` |
CSS Variable Extraction
When Dev Mode isn't enough, extract CSS directly from Figma
### Using Figma Inspect
- Select a layer in Figma.
- Enable Dev Mode.
- Copy CSS from the right panel.
- Paste into your stylesheet.
### Automating with Figma API
For batch export
```javascript // Fetch styles from Figma const response = await fetch('https://api.figma.com/v1/files/:fileKey/styles', {
headers: { 'X-Figma-Token': 'YOUR_TOKEN' }
});
const styles = await response.json(); // Process styles into CSS variables ```
Developer Best Practices
When consuming Figma handoffs
- Use Dev Mode: Don't eyeball spacing. Copy exact values.
- Reference tokens: Use CSS variables, not hardcoded values.
- Ask questions early: If a spec is unclear, ask the designer before building.
- Test at multiple sizes: Figma shows desktop; test mobile, tablet, and edge cases.
- Sync regularly: Designs change. Re-export tokens and assets when designs update.
Designer Best Practices
Before handing off
- Use auto-layout: Ensures spacing is consistent and measurable.
- Name layers clearly: Developers see layer names in Dev Mode. Use descriptive names.
- Annotate edge cases: Add notes for hover states, loading states, error states.
- Export assets at correct scale: @1x for web, @2x and @3x for mobile.
- Publish design tokens: Keep tokens.json or tokens.css up-to-date.
Figma Dev Mode, design tokens, and clear documentation turn design handoffs from guesswork into precision.