Token-aware colors and fonts
Design tokens keep your site consistent across light and dark themes in Framer. When a user connects a color or shadow variable to a code component, Framer does not pass a string. It passes an object like { "value": "#000000" }
. If your component expects a plain string, styles can break or silently reset.
Making your component token aware fixes this. It lets you accept both direct values and connected tokens without any extra setup.
Why it matters
Teams use variables for themes and brand systems. If your component can read token objects correctly, it will match theme changes instantly and behave like Framer’s built-in components. If not, colors and shadows can fail in real projects.
Example
This uses a tiny parseToken
helper to unwrap { value: ... }
for colors and shadows. It also includes applyFont
to handle extended font controls correctly.
What about fonts
Framer does not let you connect text style tokens to code components yet. You should still handle extended font controls safely. Read font.fontSize
first, normalize lineHeight
, and use tabular numerals for stable numbers. That keeps typography predictable and prepares your components for future text style variables.
Pro tip
Keep parseToken
in a shared utils file and use it across all your components. Apply it anywhere you read colors, shadows, or gradients. Once you add this, your components become theme safe by default.