Livestream: Best practices for building with GenUI | 5/22

Announcing Visual Copilot - Figma to production in half the time

Builder logo
builder.io
Contact SalesGo to App

Livestream: Best practices for building with GenUI | 5/22

Announcing Visual Copilot - Figma to production in half the time

Builder logo
builder.io

Blog

Home

Resources

Blog

Forum

Github

Login

Signup

×

Visual CMS

Drag-and-drop visual editor and headless CMS for any tech stack

Theme Studio for Shopify

Build and optimize your Shopify-hosted storefront, no coding required

Resources

Blog

Get StartedLogin

By providing your own Design tokens, you can define a consistent set of design values that are available to your users in the Builder Visual Editor.

  • Use design tokens to dictate specific values for CSS properties.
  • Optionally allow users to override tokens, so that the tokens are suggestions rather than required values.

This tutorial results in a basic callout with text colors, fonts, spacing, and sizes aligned with a project's codebase.

Marketing callout that says "Style? Substance? Do both" on the left with a button reading "Shop our styles now;" on the right a black and white photo of a stylish looking man with a large jacket with several patches on it.

To complete this tutorial, you need:

Begin by identifying what elements in your current design are out of sync with your brand's design aesthetic. Doing so makes it clearer which design tokens you should create.

Instead of guessing colors, font families, or even font sizes, use design tokens to lock in the correct values.

In the following image, the font family is out of sync with the brand's design. Brand colors are also missing from the design.

Advertisement developed in Builder with the text "Style? Substance? Do both" on the left-hand side and an image of a stylish man on the right-hand side; floating text points out that the styles are incorrect in this image.

Add the following code to your integrated page to register a design token. This design token will define a new value, Primary, for text colors.

Instead of inputting the direct value, use CSS variables for more modular code. For example, first define a CSS variable and value within your CSS file.

:root {
  --color-primary: #90be6d;
}

Then, replace the value within the "editor.settings" object.

{
  designTokens: {
    colors: [
      { name: "Primary", value: "var(--color-primary)" }
    ],
  }
}

Once your design token is registered, select it within the Visual Editor.

In this example, select a Text block and choose the text's Color option. An option named Primary, which is defined in the settings object, is now available. Upon selection, the color of the text changes.

Continue to add design tokens to your application as needed. The object's keys should be CSS properties in camel case. Each property should have a value of an array of one or more design tokens.

A robust example object is included below.

{
  designTokens: {
    colors: [
      { name: "Black", value: "#000000" },
      { name: "White", value: "#FFFFFF" },
      { name: "Primary", value: "var(--color-primary)" },
      { name: "Primary Light", value: "var(--color-primary-light)" },
      { name: "Primary Dark", value: "var(--color-primary-dark)" },
      { name: "Secondary", value: "var(--color-secondary)" },
      { name: "Secondary Light", value: "var(--color-secondary-light)" },
      { name: "Secondary Dark", value: "var(--color-secondary-dark)" },
    ],
    fontFamily: [
      { name: "Primary Font", value: "var(--font-family-base)" },
      { name: "Callout Font", value: "var(--font-family-callout)" },
    ],
    fontSize: [
      { name: "Base Font Size", value: "var(--font-size-base)" },
      { name: "Large Font Size", value: "var(--font-size-large)" },
      { name: "Small Font Size", value: "var(--font-size-small)" },
      { name: "Callout Font Size", value: "var(--font-size-callout)" },
    ],
  }
}

For more details on design tokens, including optional values to include in the settings object, visit Design tokens.

Was this article helpful?

Product

Visual CMS

Theme Studio for Shopify

Sign up

Login

Featured Integrations

React

Angular

Next.js

Gatsby

Get In Touch

Chat With Us

Twitter

Linkedin

Careers

© 2020 Builder.io, Inc.

Security

Privacy Policy

Terms of Service

Get the latest from Builder.io

By submitting, you agree to our Privacy Policy

  • Platform Overview

    AI Overview

  • Integrations

  • What's New

  • Figma to Code Guide

  • Composable Commerce Guide

  • Headless CMS Guide

  • Headless Commerce Guide

  • Composable DXP Guide

  • Design to Code

  • Blog

  • Knowledge Base

  • Community Forum

  • Partners

  • Templates

  • Success Stories

  • Showcase

  • Resource Center

    Glossary

© 2025 Builder.io, Inc.

Security

Privacy Policy

SaaS Terms

Compliance

Cookie Preferences

Gartner Cool Vendor 2024