Sometimes, building a design system at a startup can actually slow you down. This is due to the tedious, repetitive work of having developers manually translate the values modified by designers back into code. You must automate this process so that the team can focus on essential product challenges.
Unifying the Design Language with Tokens
Do not manually map design tool values to code variables one by one. By introducing design tokens, this connection becomes data-driven.
- Primitive tokens: Define raw color values, such as
blue-500. - Semantic tokens: Specify the actual usage, such as
action.primary.bg, and reference the primitive tokens above. - CSS variable mapping: Store the semantic tokens as CSS variables.
By setting it up this way, even if a designer changes a color value, developers do not need to touch the code. The system automatically updates the CSS files. For font scales, define them mathematically by entering a Base and Ratio in Penpot’s token panel. Using the formula forces design consistency to be maintained.
Automating Penpot and GitHub Integration
Having developers manually verify design changes is inefficient. Since Penpot follows the W3C Design Tokens standard, building a pipeline is possible.
- Generate a Penpot API key.
- Create a
penpot-export.config.jsfile in the project root. Configure the tokens to extract and the save path here. - Install the
@penpot-export/clipackage and execute thenpx penpot-exportcommand.
Hundreds of token values are imported into the codebase in an instant. Human errors that occur during manual input disappear. Large-scale services like Shopify also leverage this token-based workflow to update designs instantly without modifying code.
Understanding Design Intent Through Git Reviews
Do not communicate design changes via Slack messages or verbally. Manage them with Git, which is what developers are most accustomed to.
- Create a
.github/workflows/design-sync.ymlfile to automate design token extraction. - Automatically generate a PR containing the changes using the
peter-evans/create-pull-requestaction. - Once the PR is up, check the
style(tokens)commit message and view thediffduring the code review process.
Developers can immediately understand what value changed and why through the PR. This saves time spent walking around asking why something was changed.
Coexisting with Legacy Code
Do not try to change all the code at once. Using a fallback technique where you mix existing CSS and new tokens is more realistic.
- Place the automatically generated token files in the
src/styles/tokensdirectory. - Use the
var(--new-token, #legacy-value)format in your existing CSS.
Components for which tokens have not yet been defined will retain their existing values. You can modernize the system bit by bit without worrying about the UI breaking. Start by connecting just one small color token to the pipeline. It is a way to prevent the massive technical debt that would otherwise occur in the future.
