Back to Blog
January 17, 20267 min readGenerating UI Design

Generating UI Design System Tokens from Video Styles

R
Replay Team
Developer Advocates

TL;DR: Extracting design system tokens directly from video recordings of existing UIs using Replay offers a faster, more accurate, and behavior-driven approach compared to traditional methods.

The biggest bottleneck in building consistent, scalable UI isn't the code; it's the design system. Maintaining a comprehensive design system – especially the foundational tokens – is a constant battle against drift, inconsistency, and the sheer overhead of manual documentation. What if I told you there's a way to automatically generate design system tokens directly from existing, working UI just by recording a video?

Forget static screenshots and tedious manual inspections. We're talking about a revolutionary shift to behavior-driven token generation.

The Problem with Traditional Design Token Extraction#

Most current approaches to design token extraction rely on manual inspection, design files (Figma, Sketch), or, at best, screenshot-to-code tools. These methods are fundamentally flawed:

  • Manual Inspection: Time-consuming, error-prone, and doesn't scale.
  • Design Files: Often outdated or incomplete, failing to reflect the actual UI in production.
  • Screenshot-to-Code: Focuses solely on visual representation, missing crucial behavioral nuances and dynamic states. They don't understand why an element looks a certain way. They just see the static result.

The result? Inconsistent UIs, increased development time, and a constant struggle to maintain a single source of truth. It's a messy, inefficient, and frustrating process.

Introducing Behavior-Driven Token Generation with Replay#

Replay is a game-changer. It analyzes video recordings of UI interactions, leveraging Gemini to reconstruct working code and extract design tokens with unprecedented accuracy. This "behavior-driven" approach understands how the UI behaves, not just how it looks.

Here's the core concept: record a video of your existing UI (a component library demo, a live website, etc.). Replay analyzes the video, identifies UI elements, their states, and associated styles, and then automatically generates design system tokens (colors, typography, spacing, etc.) in a format you can directly integrate into your codebase.

This approach offers several key advantages:

  • Accuracy: Replay analyzes real, working UI, ensuring tokens accurately reflect the production environment.
  • Efficiency: Automates the token extraction process, saving significant time and effort.
  • Consistency: Enforces a single source of truth, reducing UI inconsistencies.
  • Behavioral Context: Understands dynamic states and interactions, capturing tokens that screenshot-based tools miss.
  • Scalability: Easily regenerate tokens as your UI evolves, ensuring your design system stays up-to-date.
text
> 💡 **Pro Tip:** Record videos of complex UI interactions to capture tokens associated with different states (hover, active, disabled, etc.).

Replay in Action: Generating Tokens from a Video#

Let's walk through a practical example. Suppose you want to extract design tokens from a video of a button component in your existing application.

Step 1: Record the Video#

Record a video showcasing the button in various states (default, hover, active, disabled). Ensure the video is clear and captures all relevant UI interactions.

Step 2: Upload to Replay#

Upload the video to Replay. The engine will analyze the video, identify the button component, and extract its associated styles.

Step 3: Review and Refine#

Review the extracted tokens in Replay's interface. You can refine the token names and values to match your design system conventions.

Step 4: Export and Integrate#

Export the tokens in a format suitable for your design system (e.g., JSON, CSS, JavaScript). Integrate the tokens into your codebase.

Here's an example of the generated tokens in JSON format:

json
{ "button": { "primary": { "backgroundColor": "#007bff", "textColor": "#fff", "borderColor": "#007bff", "hover": { "backgroundColor": "#0069d9", "borderColor": "#0062cc" }, "disabled": { "backgroundColor": "#e9ecef", "textColor": "#6c757d", "borderColor": "#e9ecef" } }, "secondary": { "backgroundColor": "#6c757d", "textColor": "#fff", "borderColor": "#6c757d", "hover": { "backgroundColor": "#5a6268", "borderColor": "#545b62" }, "disabled": { "backgroundColor": "#e9ecef", "textColor": "#6c757d", "borderColor": "#e9ecef" } } } }

This JSON can then be used within your application. For example, with Javascript:

typescript
import tokens from './design-tokens.json'; const buttonStyle = { backgroundColor: tokens.button.primary.backgroundColor, color: tokens.button.primary.textColor, borderColor: tokens.button.primary.borderColor, ':hover': { backgroundColor: tokens.button.primary.hover.backgroundColor, borderColor: tokens.button.primary.hover.borderColor, }, ':disabled': { backgroundColor: tokens.button.primary.disabled.backgroundColor, color: tokens.button.primary.disabled.textColor, borderColor: tokens.button.primary.disabled.borderColor, }, }; // Apply the style to your button component

This is just a basic example. Replay can extract a wide range of design tokens, including typography, spacing, shadows, and more.

Replay vs. the Competition#

How does Replay stack up against other token extraction tools?

FeatureScreenshot-to-Code ToolsManual InspectionReplay
Video Input
Behavior Analysis
Dynamic State ExtractionPartial
AccuracyLowMediumHigh
EfficiencyMediumLowHigh
ScalabilityLowLowHigh
CostVariesHigh (Time)Varies

⚠️ Warning: Screenshot-to-code tools can be misleading as they don't capture the full context of the UI. Relying solely on them can lead to inconsistencies and accessibility issues.

Beyond Basic Tokens: Capturing Complex Interactions#

Replay's behavior-driven approach shines when extracting tokens associated with complex UI interactions. Consider a dropdown menu with various states (open, closed, hover, selected).

Traditional methods would require manually inspecting the CSS for each state and meticulously documenting the associated styles. With Replay, you simply record a video of the dropdown menu in action, and the engine automatically extracts the relevant tokens for each state.

This capability is particularly valuable for maintaining design consistency across complex components and ensuring a cohesive user experience.

Integrating with Your Existing Design System#

Replay generates tokens in various formats, making it easy to integrate with your existing design system. Whether you're using CSS variables, JSON, or a custom token format, Replay can adapt to your needs.

Furthermore, Replay's API allows you to automate the token extraction and integration process, streamlining your design system workflow.

text
> 📝 **Note:** Replay supports Supabase integration, allowing you to store and manage your design tokens in a centralized database.

The Future of Design Systems#

Replay represents a paradigm shift in how we approach design system maintenance. By leveraging video analysis and behavior-driven reconstruction, we can automate the token extraction process, ensure accuracy, and maintain a single source of truth.

This not only saves time and effort but also empowers designers and developers to focus on creating exceptional user experiences, rather than wrestling with inconsistent styles and outdated documentation.

The future of design systems is automated, intelligent, and behavior-driven. Replay is leading the way. 🚀

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited usage. Paid plans are available for higher usage and access to advanced features. Check out Replay's pricing page for details.

How is Replay different from v0.dev?#

v0.dev focuses on generating UI components from text prompts, while Replay reconstructs UI from video recordings, enabling behavior-driven token extraction and code generation. They solve different problems in the UI development lifecycle. Replay is better suited for extracting and standardizing existing UI patterns, while v0.dev is ideal for prototyping and exploring new design ideas.

What file types does Replay accept?#

Replay accepts common video formats such as MP4, MOV, and WebM.

Can I use Replay to extract tokens from mobile apps?#

Yes! As long as you can record a video of the app's UI, Replay can analyze it and extract design tokens.


Ready to try behavior-driven code generation? Get started with Replay - transform any video into working code in seconds.

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free