Tokens
Design tokens are the foundation of our design system, providing a single source of truth for values like colors, spacing, typography, and more. They help maintain consistency across our products while making it easier to scale and maintain our design language.
Why Design Tokens?
Design tokens serve several crucial purposes:
- Consistency: They ensure visual consistency across all products and platforms
- Maintainability: Changes can be made in one place and propagate throughout the system
- Theme Support: They enable seamless theme switching (like dark mode)
- Platform Agnostic: The same tokens can be used across web, mobile, and other platforms
Token Types
Our design system includes two main categories of tokens:
Base Tokens
Base tokens (found in tokens.json) are the raw values that define
our design primitives. These include:
- Colors: Raw color values in various scales (e.g.,
neutralSlate.1,neutralSand.1) - Spacing: Base spacing units (e.g.,
100 = 8px,200 = 16px) - Breakpoints: Screen size breakpoints for responsive design
- Blurs: Blur values for depth effects
- Typography: Font sizes, weights, and line heights
Semantic Tokens
Semantic tokens (found in semantic-tokens.json) are contextual
aliases that map to base tokens. They provide meaningful,
context-specific names for design values. For example:
- Surface colors:
neutral.surfacefor default surfaces,neutral.surface.subtlefor subtle surfaces andneutral.surface.strongfor strong surfaces (e.g. buttons) - Foreground colors:
neutral.fgfor primary text,neutral.fg.subtlefor secondary text andneutral.fg.strongfor strong text - Border colors:
neutral.borderfor standard borders,neutral.border.subtlefor subtle borders andneutral.border.strongfor strong borders
Using Tokens in Code
With PandaCSS
import { css } from '@oztix/roadie-core/css'const styles = css({// Using semantic color tokenscolor: 'neutral.fg',bg: 'neutral.surface',borderColor: 'neutral.border',// Using spacing tokenspadding: '100', // 8pxmargin: '200', // 16pxgap: '300', // 24px// Using breakpoint tokenssm: {padding: '400' // 32px}})
With React Components
import { View } from '@oztix/roadie-components'function MyComponent() {return (<Viewpadding='100'backgroundColor='neutral.surface'color='neutral.fg'borderColor='neutral.border'>Content</View>)}
Best Practices
- Always use semantic tokens when available instead of base tokens
- Use semantic color tokens appropriately:
neutral.surfacefor default surfaces,neutral.surface.subtlefor subtle variations andneutral.surface.strongfor strong surfacesneutral.fgfor default text,neutral.fg.subtlefor subtle text andneutral.fg.strongfor strong textneutral.borderfor default borders,neutral.border.subtlefor subtle borders andneutral.border.strongfor strong borders
- Maintain dark mode compatibility by using semantic tokens that automatically adapt
- Use spacing tokens consistently:
100= 8px200= 16px300= 24px400= 32px
- Follow responsive design patterns using PandaCSS breakpoint syntax
Token Structure
Each token includes:
- A unique name
- A value or reference to another token
- A type (color, space, etc.)
- A description of its intended use
For a complete reference of all available tokens, see the Token Reference page.