Back to Blog
January 17, 20267 min readBuilding Design Tokens

Building Design Tokens from Screen Recordings of a Design System

R
Replay Team
Developer Advocates

TL;DR: Extract design tokens directly from screen recordings of your design system in action using Replay, bridging the gap between design intent and implementation.

The promise of design tokens is elegant: a single source of truth for all your UI styling, ensuring consistency and maintainability. But the reality? Design tokens often lag behind the actual design system in use. Designers iterate, components evolve, and the tokens… well, they stay put. This disconnect leads to "token drift," inconsistent UIs, and developer headaches. The traditional approach of manually updating tokens is slow, error-prone, and doesn't capture the nuances of user interaction.

The Problem with Traditional Design Token Management#

Manually managing design tokens is a thankless task. You're essentially trying to translate a visual design into a series of abstract values. This process is subjective, time-consuming, and prone to human error. Furthermore, it's difficult to capture the dynamic aspects of a design system, such as hover states, animations, and responsive behaviors.

Consider a simple button. It's not just about the

text
primary-color
and
text
secondary-color
. It's about the subtle shadow on hover, the slight transition when pressed, and how the text scales on different screen sizes. Capturing all of this in static design tokens is a challenge.

FeatureManual Token CreationScreenshot-to-CodeReplay
AccuracyLow (Subjective)Medium (Visual Only)High (Behavior-Driven)
SpeedSlowMediumFast
Dynamic BehaviorNot CapturedNot CapturedCaptured
MaintainabilityLowMediumHigh
Video Input
Behavior AnalysisPartial
Design System IntegrationManualManualSemi-Automated

Behavior-Driven Reconstruction: A New Paradigm#

What if you could automatically extract design tokens directly from a working design system? That's the power of behavior-driven reconstruction. Instead of relying on static screenshots or manual interpretation, we analyze videos of the design system in action. This allows us to capture not just the visual appearance but also the behavior of the components.

Replay leverages the power of Gemini to analyze screen recordings and reconstruct the underlying code, including the design tokens. This approach offers several advantages:

  • Accuracy: Tokens are derived directly from the source of truth – the working design system.
  • Speed: Token extraction is automated, saving you hours of manual work.
  • Dynamic Behavior: Replay captures hover states, animations, and responsive behaviors.
  • Maintainability: Tokens are automatically updated whenever the design system changes.

Building Design Tokens from Screen Recordings with Replay: A Step-by-Step Guide#

Here's how to build design tokens from screen recordings using Replay:

Step 1: Capture the Interaction#

Record a video of your design system components in action. Make sure to showcase all the different states and behaviors you want to capture (hover, focus, active, responsive). The higher the video quality, the better.

💡 Pro Tip: Focus on clear, deliberate interactions. Avoid unnecessary mouse movements or distractions.

Step 2: Upload to Replay#

Upload the video to Replay. The platform will automatically analyze the video and reconstruct the UI.

Step 3: Review and Refine#

Review the reconstructed UI and identify the components and styles you want to extract as design tokens. Replay allows you to fine-tune the extraction process, ensuring accuracy and completeness.

Step 4: Generate Design Tokens#

Generate the design tokens in your preferred format (JSON, YAML, etc.). Replay supports a variety of output formats and can be easily integrated into your existing design system workflow.

typescript
// Example of extracted design tokens (JSON) { "button": { "primary": { "backgroundColor": "#007bff", "textColor": "#fff", "hover": { "backgroundColor": "#0069d9", "boxShadow": "0 0.125rem 0.25rem rgba(0, 0, 0, 0.25)" }, "active": { "backgroundColor": "#0062cc" } }, "secondary": { "backgroundColor": "#6c757d", "textColor": "#fff", "hover": { "backgroundColor": "#5a6268" }, "active": { "backgroundColor": "#545b62" } } } }

Step 5: Integrate into Your Design System#

Integrate the generated design tokens into your design system. This typically involves updating your component libraries and CSS stylesheets.

css
/* Example of using the design tokens in CSS */ .button-primary { background-color: var(--button-primary-backgroundColor); color: var(--button-primary-textColor); } .button-primary:hover { background-color: var(--button-primary-hover-backgroundColor); box-shadow: var(--button-primary-hover-boxShadow); } .button-primary:active { background-color: var(--button-primary-active-backgroundColor); }

Beyond Static Tokens: Capturing Dynamic Behavior#

One of the key advantages of Replay is its ability to capture dynamic behavior. Traditional design tokens often focus on static values, such as colors and fonts. However, modern UIs are increasingly dynamic, with animations, transitions, and responsive behaviors.

Replay can capture these dynamic aspects and translate them into code. For example, you can record a video of a button with a hover effect, and Replay will automatically generate the CSS code for the hover state, including the transition duration and easing function.

This allows you to create design tokens that are not just about visual appearance but also about user interaction. This leads to a more consistent and engaging user experience.

⚠️ Warning: Accurately capturing complex animations may require multiple recordings or manual adjustments.

Benefits of Using Replay for Design Token Management#

  • Reduced Manual Effort: Automate the process of extracting and updating design tokens.
  • Improved Accuracy: Ensure that your tokens accurately reflect the working design system.
  • Enhanced Consistency: Maintain a consistent UI across all your applications.
  • Faster Iteration: Quickly update your design tokens whenever the design system changes.
  • Better Collaboration: Facilitate collaboration between designers and developers.
  • Capture Dynamic Behavior: Encode animations, transitions, and responsive behaviors into your tokens.
  • Supabase Integration: Seamlessly integrate with your Supabase backend for storing and managing design tokens.

Why Video, Not Screenshots?#

Screenshot-to-code tools have their place, but they fall short when it comes to capturing the intent behind the design. A screenshot is a static representation of a single moment in time. It doesn't capture the user's actions, the component's states, or the underlying logic.

Video, on the other hand, tells a story. It shows how the user interacts with the design system, how the components respond to those interactions, and the overall flow of the application. Replay analyzes this story to understand the behavior of the design system, not just its visual appearance. This is why Replay is able to generate more accurate and complete design tokens.

📝 Note: Replay uses advanced AI algorithms to filter out noise and focus on the relevant UI elements.

Frequently Asked Questions#

Is Replay free to use?#

Replay offers a free tier with limited features. Paid plans are available for more advanced functionality and higher usage limits.

How is Replay different from v0.dev?#

v0.dev primarily focuses on generating UI components from text prompts. Replay, on the other hand, focuses on reconstructing working UI from video recordings, allowing you to capture the nuances of existing design systems and user interactions. Replay excels at extracting design tokens and understanding dynamic behavior, which v0.dev does not address.

What file formats are supported for design token export?#

Replay supports JSON, YAML, CSS custom properties, and JavaScript/TypeScript modules. We are continuously adding support for more formats based on user feedback.

Can Replay handle complex animations and transitions?#

Yes, Replay can capture and represent complex animations and transitions. However, for very intricate animations, some manual refinement of the generated code may be required.


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