Display Modes
ThevariableDisplay option accepts three values:
- Reference (default): Shows only the CSS variable reference
- Resolved: Shows only the resolved/computed value
- Both: Shows the variable reference with the resolved value as fallback
Reference Mode
Displays the CSS variable reference without the fallback value, resulting in clean variable-based code. Figma output:var(--primary, #fff)
Reference mode output:
- Your codebase uses a design token system
- You want to maintain variable references in the output
- Fallback values are defined elsewhere in your CSS
Resolved Mode
Displays only the resolved value, removing variable references entirely. Figma output:var(--primary, #11223380)
Resolved mode output:
- Hex alpha colors are converted to
rgba()format color-mix()functions are simplified torgba()when possible
- You need static color values
- Your project doesn’t use CSS variables
- You want to see the actual computed colors
Both Mode
Displays the CSS variable reference with the resolved value as a fallback, providing maximum context. Figma output:var(--brand, #fff)
Both mode output:
- You want to see both the variable name and its value
- You’re documenting design tokens
- You need fallback values for browser compatibility
Configuration
The variable display mode is stored in preferences:Implementation Details
Type Definition
Defined intypes/codegen.ts:
Processing Logic
Implemented inutils/css.ts within the serializeCSS function:
Value Processing Pipeline
When a display mode is active, values go through this processing sequence:Plugin Integration
Plugins can transform variable references using thetransformVariable hook:
Testing Examples
From the test suite (tests/utils/css.test.ts):
Edge Cases
Variables Without Fallbacks
When a variable has no fallback value in resolved mode:Non-Dashed Variable Names
Variables without the-- prefix are normalized:
Complex Color Transformations
Resolved mode applies multiple simplifications:Use Cases
Design System Documentation
Use Both mode to show variable names alongside their values:Component Library Development
Use Reference mode for components that consume design tokens:Static Site Generation
Use Resolved mode when CSS variables aren’t supported:Related Topics
- Preferences - General preference settings
- Units - Unit conversion configuration
- Creating Plugins - Custom variable transformations
- Plugin Hooks - transformVariable hook reference