DVA Vibe Academy · Class #76 · Free · No Signup
</>

Design-to-Code

You have a design. You need production code. This class teaches you to bridge that gap with AI: from Figma files and screenshots to accessible, token-driven, maintainable code. The DDS Terminal aesthetic is the worked example. Every Academy page you have read was built this way.

Duration: ~75 min Level: Intermediate Stage: Application Lane: Hydrogen Cost: $0 Signup: None
  • DDS Terminal as the case study — the real token set and pipeline behind every Academy page
  • Design tokens to production CSS — colors, fonts, spacing, elevation as custom properties
  • Accessibility gates — semantic HTML, ARIA, contrast, keyboard navigation checks
  • Paste-ready prompts — design-to-code generation and review checklist you can use today
Quick Answer

What is design-to-code?

Design-to-code is turning a visual design (Figma file, screenshot, mockup, or design system spec) into working, accessible, maintainable production code by directing AI. The real skill is not getting the AI to produce something that looks right. It is getting it to produce something that is structurally right: correct tokens, semantic HTML, scoped CSS, proper responsiveness, and zero accessibility regressions. This class teaches the discipline behind that process, using the DDS Terminal aesthetic as the first-party worked example.

Module 01

The DDS Terminal Aesthetic

Answer Capsule Every Academy page you have read uses the same design system: gold (#FFE069) on near-black (#04090c), Playfair Display for headings, DM Sans for body, JetBrains Mono for code and labels. Eight color tokens. Three font stacks. A spacing scale. An elevation system. This token set becomes the CSS custom properties that constrain every section build. That path from token definition to production section is the worked example for this entire class.

The token set

TokenValueUsage
--d2c-gold#FFE069Primary accent, headings, links, active states
--d2c-bg#04090cPage background (near-black)
--d2c-surface#0c1117Card backgrounds, callouts
--d2c-border#1e293bDividers, card borders
--d2c-text#e2e8f0Body text
--d2c-text-strong#f8fafcHeadings, emphasized text
--serifPlayfair DisplayDisplay headings (h1, h2, h3)
--sansDM SansBody text, UI elements

This is not a theoretical design system. It is the actual CSS running on the page you are reading right now. Open your browser's inspector, find the section element, and you will see these exact custom properties. That is the point: the design system is the code. There is no handoff gap because the tokens are defined once, in the section's CSS, and every rule references them.

Why this matters for design-to-code

When you give an AI agent a token file, it stops inventing arbitrary values. Instead of generating color: #e5c543 (close but wrong), it generates color: var(--d2c-gold) (exactly right). The token file is the constraint that makes AI-generated CSS maintainable. Without it, every generated component is a snowflake with its own color palette.

Module 02

Design Tokens as CSS Custom Properties

Answer Capsule Design tokens are the atomic values of your design system: colors, fonts, spacing, shadows, breakpoints. Define them as CSS custom properties on a scoped container. Every rule in your section references tokens, never hardcoded values. Search interest for “design tokens generator” has grown over 900% in the last two years. The W3C Design Tokens Community Group specification now provides a standard format for interoperability between design tools and code.
CSS — Token definition (real DDS example)
#{{ section_id }} {
  /* Color tokens */
  --d2c-gold: #FFE069;
  --d2c-bg: #04090c;
  --d2c-surface: #0c1117;
  --d2c-border: #1e293b;
  --d2c-text: #e2e8f0;
  --d2c-text-strong: #f8fafc;

  /* Font stacks */
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Spacing scale (4px base) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 64px;

  /* Elevation */
  --elev-1: 0 1px 4px rgba(0,0,0,.4);
  --elev-2: 0 4px 12px rgba(0,0,0,.5);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
}

Rules for token discipline

  • No magic numbers. Every color, font, spacing, shadow, and radius value must reference a token. If you write padding: 13px, that is a magic number. Use padding: var(--space-md) or do not use it.
  • Scoped to the section ID. Tokens are defined on #section_id, not on :root or body. This prevents leaking into other sections on the same page.
  • One source of truth. Tokens are defined once, at the top of the section's CSS. Every rule below references them. To change the entire color scheme, you change eight values.

Module 03

Component Structure

Answer Capsule Mapping a design to code starts with component structure: what is the page layout, what are the sections, what are the repeated elements. Use semantic HTML elements (section, article, nav, aside, header, footer, ul, figure) not divs for everything. Name components with a class-specific prefix (d2c- for this class) to prevent collisions. Auto-layout in Figma maps directly to CSS Flexbox.

The DDS Academy page structure

  • Breadcrumb nav<nav aria-label="Breadcrumb">
  • Hero header<header> with eyebrow, icon, h1, deck, meta row, credential card, CTAs
  • 3-column shell — CSS Grid: sticky TOC (nav) + article + sidebar (aside)
  • Modules<section id="..."> inside the article, each with answer capsule + content
  • FAQ accordion<section> with button/div toggle pattern
  • Footer<footer> with attribution and cross-links

Every component gets a prefixed class: .d2c-hero, .d2c-shell, .d2c-toc, .d2c-article, .d2c-faq-item. The prefix prevents selector collisions when multiple sections load on the same page. Figma users who name layers with the same convention (e.g., d2c/hero, d2c/shell) get cleaner exports because the AI maps layer names to class names.

Figma auto-layout maps to Flexbox

If your Figma frame uses auto-layout with a vertical direction, gap of 16, and padding of 24, the AI generates display: flex; flex-direction: column; gap: 16px; padding: 24px;. This mapping is reliable because auto-layout and Flexbox share the same mental model. Use auto-layout in Figma for every frame and the code output will be structurally correct.

Module 04

Tool Landscape (2026)

Answer Capsule Figma has over 13 million monthly active users and holds roughly 38-40% market share in collaborative design (Figma fiscal reports, 2025). The design-to-code ecosystem now includes Figma MCP for structured data access, screenshot-to-code for visual input, and AI IDEs that generate full components from prompts. No tool produces ship-ready code without review. The global generative AI in design market is projected at ~$1.33 billion in 2026.
CategoryToolsBest forLimitation
Figma MCPFigma MCP server + AI IDEStructured design data (auto-layout, tokens, components)Requires MCP-compatible agent
Screenshot inputAny AI IDE (paste image + prompt)Quick replication of existing UIsPixel inference, no semantic structure
Specialized exportersLocofy, Builder.io, AnimaFramework-specific component generationOften requires manual component mapping
Figma nativeFigma Make, Code LayersRapid prototyping on canvasOutput may not match production patterns
App buildersv0, Lovable, BoltFull-stack MVP from prompts or designsOpinionated frameworks, limited customization

How DDS does it

DDS does not use Figma. The design system is defined directly in the task brief as token values, component structure, and layout specification. The AI agent generates the section from those constraints. This works because the design system is mature and documented. If you are starting from a Figma file, Figma MCP is the most reliable path because it gives the agent structured data instead of pixel inference.

Module 05

The Design-to-Code Workflow

Answer Capsule Four stages: input (design reference + token file), generation (AI produces the component), refinement (fix semantics, accessibility, token compliance), and integration (merge into codebase, validate, ship). The AI gets you 60-80% of the way. The refinement step is where code quality is won or lost. Over 80% of software developers now use AI tools in some part of their workflow.

Stage 1: Input

Give the agent everything it needs to avoid inventing. At minimum: your token file (CSS custom properties or JSON), the component structure (what elements in what order), and a visual reference (Figma link, screenshot, or detailed description). The more specific the input, the less you fix later.

Stage 2: Generation

Run the prompt. The AI produces HTML + CSS. For a DDS Academy section, this is typically 800-1100 lines of Liquid/HTML/CSS/JS in a single file. The output should use your tokens, not arbitrary values. If the agent invents colors or spacing, the token file was not in the prompt.

Stage 3: Refinement

This is where most people skip and should not. Review the output against your checklist: semantic HTML (not div soup), headings in order, ARIA labels on buttons, tokens used (no magic numbers), responsive at three viewports, CSS scoped to the section. Fix what is wrong. This step typically takes 15-30% of the total time but determines whether the output is maintainable or disposable.

Stage 4: Integration

Merge into your codebase. For Shopify: deploy to staging, render-verify at 1440px, 1440x680, and 390x844, then promote to MAIN with length-parity assertion. Run accessibility validation. Ship.

Module 06

Accessibility Gates

Answer Capsule AI generates accessible code only when explicitly constrained to do so. Research from the GAAD Foundation and WebAIM shows that a majority of AI models generate HTML with critical accessibility failures by default: missing ARIA labels, broken heading hierarchy, no keyboard navigation support. Your prompt must include accessibility requirements, and your review must validate them.

The checklist

  1. Semantic HTML. Use section, article, nav, aside, header, footer, ul, ol, figure. Not div for everything.
  2. Heading hierarchy. One h1 per page. h2 for sections. h3 for subsections. No skipped levels.
  3. ARIA labels. Every button, toggle, and interactive element has an accessible name. Decorative elements have aria-hidden="true".
  4. Focus indicators. :focus-visible with a 2px solid outline offset 3px. Do not remove focus outlines.
  5. Touch targets. Minimum 44x44px for all interactive elements (WCAG 2.2 AA).
  6. Contrast. Text on background must pass WCAG AA (4.5:1 for body text, 3:1 for large text). Gold #FFE069 on #04090c passes at 11.6:1.
  7. Keyboard navigation. Tab through the entire page. Every interactive element must be reachable and operable.
  8. Screen reader test. Navigate with VoiceOver, NVDA, or JAWS. Headings should announce correctly. Landmarks should be labeled.

The compounding error trap

If an AI generates an inaccessible card component and you use it as a template, every card on every page inherits the accessibility failure. One bad pattern becomes 50 violations. Review the first instance of every repeated component against this checklist before replicating it.

Module 07

Pitfalls

Answer Capsule Four common failures in AI-generated UI code: CSS bloat (redundant selectors, inline values instead of tokens), non-semantic markup (div soup), over-broad selectors (break other sections on the page), and pixel-chasing (absolute positioning that breaks on different content). Each has a specific gate that prevents it from reaching production.

1. CSS bloat

AI models generate redundant selectors because they solve each element independently. They write color: #FFE069 on 15 different rules instead of referencing var(--d2c-gold) once and inheriting. The fix: give the agent your token file and explicitly state “use only these tokens, no hardcoded values.”

2. Div soup

AI defaults to <div> for everything because div is the safest generic element. The result: a page with no landmarks, no heading structure, and no semantic meaning. Screen readers navigate a flat wall of identical containers. The fix: specify the semantic elements in your prompt (section, article, nav, aside, figure, ul).

3. Over-broad selectors

An AI writes h2 { color: white; } thinking it is styling your section. But that rule applies to every h2 on the page, including the Shopify header and footer. On a dark-on-dark page, white headings disappear. The fix: scope every selector under #section_id and use prefixed classes (.d2c-article h2).

4. Pixel-chasing

When an AI tries to match a screenshot exactly, it uses absolute positioning, fixed widths, and magic-number margins. The output looks correct at the exact resolution of the screenshot and breaks at every other resolution. The fix: aim for structural fidelity (correct hierarchy, correct tokens, correct responsive behavior), not pixel-perfect fidelity.

Module 08

Paste-Ready Prompts & Checklist

Answer Capsule Three prompts you can paste into your AI IDE right now: a design-to-code generation prompt, a component structure prompt, and a review/fix prompt. Plus the review checklist that gates every generated component before it ships.
Prompt 1 — Design-to-Code Generation
Generate a [component name] from this design reference.

Design tokens (use ONLY these, no hardcoded values):
  --primary: [your primary color]
  --bg: [your background color]
  --surface: [your surface color]
  --text: [your text color]
  --font-display: [your display font]
  --font-body: [your body font]

Requirements:
- Semantic HTML (section, article, nav, aside, figure, ul)
- Heading hierarchy: h2 for sections, h3 for subsections
- ARIA labels on all interactive elements
- CSS scoped under #[container-id] with [prefix]- classes
- Responsive: 3-column at 1280px, 2-column at 1180px, 1-column at 768px
- No inline styles. No arbitrary color or spacing values.
- WCAG 2.2 AA: 4.5:1 contrast, 44px touch targets, focus-visible
Prompt 2 — Screenshot-to-Code
[Attach screenshot]

Replicate this UI as a [React component / HTML section / Liquid section].

Constraints:
- Use these design tokens: [paste your token file]
- Map visual elements to semantic HTML: header, nav, main, section, article
- Responsive: desktop-first, collapse to single-column at 768px
- No absolute positioning. Use Flexbox or Grid for layout.
- Include accessible labels for all buttons and icons.
- Output a single file. CSS scoped to a container ID.
Prompt 3 — Review & Fix
Review this generated component for production readiness:

1. Replace all hardcoded color/spacing values with design token references
2. Replace all divs that should be semantic elements (section, nav, aside, ul)
3. Add missing ARIA labels on buttons and interactive elements
4. Fix heading hierarchy (h2 for sections, h3 for subsections, no skipped levels)
5. Remove duplicate CSS selectors
6. Add focus-visible styles to all interactive elements
7. Verify responsive behavior at 1440px, 1024px, and 390px
8. Scope all CSS under #[container-id]

Report what you changed and why.

The review checklist

  1. Every color value references a token (no hex, no rgb outside the token definition)
  2. Every spacing value references a token or uses the 4px base scale
  3. All CSS scoped under the section ID with prefixed classes
  4. Semantic HTML: correct elements for each component
  5. Heading hierarchy: h1 once, h2 for sections, h3 for subsections, no skips
  6. ARIA labels on buttons, toggles, and navigation landmarks
  7. Focus-visible on all interactive elements
  8. Responsive at 1440px, 1024px, 768px, 390px
  9. No absolute positioning for layout (Flexbox/Grid only)
  10. No duplicate selectors

Module 09

The Review Gate

Answer Capsule Visual correctness is not code quality. The UI looks right but the markup is div soup, the colors are hardcoded, and the headings skip from h1 to h4. The review gate catches these before integration. At DDS, no generated component ships without passing the token compliance check, the semantic structure check, and the accessibility check. This is where design-to-code connects to the storefront and theme work taught in the Hydrogen and SEO Magnet classes.

How design-to-code feeds the storefront work: the Hydrogen Masterclass teaches the framework. The Homepage Upgrade teaches layout iteration. The SEO Magnet teaches the schema and discoverability layer. The Reading & Directing Code class teaches understanding the output. Design-to-code connects all of them: it is how the design intent becomes the actual section file that carries the SEO schemas, the responsive layout, and the accessible structure.

The automation path

The review checklist is manual today. But each check is automatable: a linter can verify token compliance, axe-core can verify accessibility, and a CSS analyzer can detect duplicate selectors. Build the manual discipline first. Automate it when the pattern is stable. Workflow automation tools can reduce product development times by as much as 70%.

Key Takeaways

What You Should Remember

  • Design tokens as CSS custom properties are the constraint that makes AI-generated CSS maintainable.
  • Scope all CSS under the section ID with prefixed classes. No global selectors.
  • Semantic HTML is not optional. Specify elements in the prompt: section, article, nav, aside.
  • AI gets you 60-80% of the way. The refinement step is where quality is won or lost.
  • Pixel-perfect is a false goal. Aim for structural fidelity: correct tokens, correct hierarchy, correct responsiveness.
  • Accessibility must be in the prompt. AI does not generate accessible code by default.
  • Review every generated component before replicating. One bad pattern becomes many violations.
  • Figma MCP gives structured data. Screenshots give pixel inference. Use the best input for the task.
The Bottom Line

The Design Is the Constraint

Design-to-code is not about getting the AI to match pixels. It is about encoding your design system as a set of constraints that the AI must follow. Tokens for colors. Tokens for spacing. Semantic elements for structure. WCAG rules for accessibility. The tighter the constraints, the better the output. Every Academy page you have read was built this way: a token file, a structure specification, and an AI agent that followed the constraints. I designed the constraints, the agents did the rest. Now you know how.

Frequently Asked Questions

FAQ

Design-to-code is the process of turning a visual design input (a Figma file, a screenshot, a mockup, or a design system specification) into working, maintainable, accessible production code. In a vibe coding workflow, you direct an AI agent to generate the code from the design, then refine the output for semantics, accessibility, and integration with your existing codebase.

Four main input types: Figma files (via Figma MCP or Dev Mode exports), screenshots of existing UIs or mockups, reference websites (paste a URL and describe what to replicate), and design system specifications (color tokens, typography scales, spacing systems documented in a file the agent can read). Each input type has different accuracy and the best results come from combining a visual reference with explicit design token documentation.

Design tokens are the atomic values of a design system: colors, font families, font sizes, spacing units, border radii, shadows, and breakpoints. They are typically defined as CSS custom properties (variables) or JSON and serve as the single source of truth for both design tools and code. When you give an AI agent a token file, it generates code that uses your actual values instead of inventing arbitrary ones.

AI models prioritize solving the immediate visual request over following DRY principles. They generate redundant selectors, inline values instead of referencing tokens, and create new classes for every element instead of reusing existing ones. Without a token file to constrain them, models also invent arbitrary color values and spacing that do not match your design system. The fix is constraint-based prompting: give the agent your token file and explicitly forbid custom values.

Include accessibility requirements in your prompt: semantic HTML (headings in order, landmarks, lists for lists), ARIA labels on interactive elements, visible focus indicators, 44x44px minimum touch targets, and WCAG 2.2 AA contrast ratios. Then validate the output: run axe-core or Lighthouse, tab through the page with keyboard, and test with a screen reader. AI generates accessible code only when explicitly constrained to do so.

Figma MCP (Model Context Protocol) is a server that connects AI coding agents directly to Figma files. Instead of interpreting pixels from a screenshot, the agent reads the actual design data: auto-layout structures, component hierarchies, variable tokens, and typography definitions. This produces significantly more accurate and maintainable code than screenshot-based generation because the agent works with structured data instead of pixel inference.

The DDS Terminal aesthetic is the design system used across all DDS Vibe Academy pages. It uses gold (#FFE069) text and accents on a near-black (#04090c) background, Playfair Display for headings, DM Sans for body text, and a monospace font for code and labels. Every Academy section is built from this token set, scoped under a section ID with a class-specific prefix. This class uses the DDS Terminal system as the first-party worked example of design-to-code.

No. Pixel-perfect fidelity from AI is a false goal that leads to brittle, unmaintainable code. The AI will use absolute positioning, magic numbers, and hardcoded dimensions to match pixels, which breaks on different screen sizes and content lengths. Instead, aim for structural fidelity: the right component hierarchy, correct token usage, proper responsive behavior, and semantic HTML. Fix spacing and alignment manually after the structure is correct.

The DDS pipeline starts with a token definition (8 colors, 3 font stacks, spacing scale, elevation system) documented in the section's CSS custom properties. The operator writes a task brief specifying the design structure (hero, 3-column shell, modules, FAQ accordion, footer) and the agent generates a complete Liquid section using only those tokens. No arbitrary values are permitted. The output is audited for token compliance, accessibility, and SEO schema validity before deployment.

It depends on your input. For Figma files: use Figma MCP with an AI IDE (Cursor, Claude Code, or Antigravity) to generate code that reads your actual design data. For screenshots: use screenshot-to-code tools or paste the image directly into your AI IDE with a prompt. For rapid prototyping: use Figma Make to generate initial layouts, then hand off to code. For full-stack MVPs: tools like v0, Lovable, or Bolt generate working apps from prompts. All require human review before shipping.

Name your Figma components to match your code component names. Use auto-layout in Figma (it maps directly to CSS Flexbox). Define variants in Figma that correspond to component props in code. When using Figma MCP, the agent reads these structures and generates code that mirrors them. If you use a specialized exporter like Builder.io, you can explicitly map Figma components to existing code components in your library so the output uses your actual codebase instead of generating new markup.

Shipping AI-generated UI without reviewing the markup structure. The visual output looks correct, but the underlying HTML uses divs for everything, skips heading levels, lacks ARIA labels, uses inline styles instead of tokens, and breaks on screen readers. Visual correctness is not code quality. Always review the generated markup against your semantic structure requirements and accessibility checklist before integration.

Define your breakpoints as design tokens and include them in your prompt. Specify the layout behavior at each breakpoint (3 columns to 1 column, sidebar collapses, font sizes scale). Use CSS container queries or media queries, not JavaScript-based responsiveness. After generation, test at your target viewports. AI models often generate responsive code that works at desktop and mobile but breaks at tablet widths because they optimize for the extremes and skip the middle.

Yes. This is exactly how DDS builds Academy sections. The design system (tokens, layout structure, component patterns) is documented in the task brief. The AI agent generates a complete Liquid section file with scoped CSS, semantic HTML, JSON-LD schemas, and a schema block. The output is a single self-contained file that works within the Shopify Online Store 2.0 architecture. The key constraint is that CSS must be scoped to the section ID and JavaScript must be in a single IIFE.

Nothing. This masterclass is 100 percent free. No signup, no email, no paywall, no certificate requirement. It is part of the DDS Vibe Academy, a free AI coding curriculum built by Robert McCullock at Design Delight Studio.

Design Delight Studio

DDS Vibe Academy — 100% free, no signup, no email, no paywall.

Built by Robert McCullock — “spread free learning, the way the internet was first made to be.”