Skip to content

Design Tokens

Design Tokens in AppLaunchKit

Design tokens are the foundational elements of AppLaunchKit’s design system. They represent the smallest units of design decisions, such as colors, typography, spacing, and other visual properties. These tokens ensure consistency across your application and make it easier to maintain and update your design system.

What are Design Tokens?

Design tokens are variables that store design decisions. They act as a single source of truth for your application’s visual style, enabling you to:

  • Maintain consistency across different platforms (iOS, Android, and web)
  • Easily update the look and feel of your entire application by modifying a few token values
  • Ensure accessibility by defining appropriate color contrasts and font sizes
  • Facilitate collaboration between designers and developers by providing a shared language for design elements

In AppLaunchKit, design tokens are implemented using a combination of CSS variables (tailwind config) and JavaScript objects (gluestack-ui provider), allowing for seamless integration in both style sheets and component logic.

Key Categories of Design Tokens in AppLaunchKit

  1. Colors: Define your brand colors, UI element colors, and semantic color tokens.
  2. Typography: Specify font families, sizes, weights, and line heights.
  3. Spacing: Set consistent margins, paddings, and gaps throughout your layout.
  4. Breakpoints: Define responsive design breakpoints for various screen sizes.
  5. Shadows: Create depth and hierarchy with consistent shadow styles.
  6. Border Radii: Maintain consistent corner rounding across UI elements.

By leveraging these design tokens, you can easily customize the look and feel of your AppLaunchKit-based application while maintaining a cohesive and professional design across all platforms.

Add/Edit Design Tokens

To customize the design tokens in AppLaunchKit, you’ll need to update values in two key files:

  1. The tailwind.config.js file
  2. The gluestack-ui provider configuration file

Both of these files are used for both web and native applications, ensuring consistency across platforms.

Updating Tailwind Config

To update a token in the tailwind.config.js file:

  1. Open the tailwind.config.js file in your project root.
  2. Locate the relevant section (e.g., colors, fontSize, spacing).
  3. Modify the value of the token you wish to change.

For example, to change the primary-500 color token, you would update the colors object in the tailwind.config.js file:

tailwind.config.js
colors: {
primary: {
500:'rgb(var(--color-primary-500)/<alpha-value>)', // we will update the value of the css-variable depending on the theme (light or dark or ....)
},
}

and the value of the css-variable will be updated depending on the theme (light or dark or …) in the gluestack-ui-provider/config.ts file:

gluestack-ui-provider/config.ts
const config = {
light: vars({
...,
'--color-primary-500': '51 51 51',
...
}),
dark: vars({
...,
'--color-primary-500': '240 240 240',
...
}),
};

Updating Gluestack-UI Provider

To update a token in the gluestack-ui provider configuration file:

  1. Open the gluestack-ui.config.js file in your project root.
  2. Locate the relevant section (e.g., colors, fontSize, spacing).
  3. Modify the value of the token you wish to change.