Skip to content

Style Dictionary Setup Complete

Successfully integrated Style Dictionary 5.1.1 into the CloudAlt monorepo as a centralized design token management system.

packages/design-tokens/
β”œβ”€β”€ tokens/ # Source token JSON files (3-tier hierarchy)
β”‚ β”œβ”€β”€ global/ # Global tokens (all apps)
β”‚ β”‚ β”œβ”€β”€ semantic-colors.json # Success, warning, error, info + ecosystem colors
β”‚ β”‚ └── animation.json # Transitions, durations, easing
β”‚ β”œβ”€β”€ divisions/ # Division-level tokens (shared within division)
β”‚ β”‚ β”œβ”€β”€ stay-overnight/
β”‚ β”‚ β”‚ β”œβ”€β”€ spacing.json
β”‚ β”‚ β”‚ β”œβ”€β”€ typography.json
β”‚ β”‚ β”‚ β”œβ”€β”€ shadows.json
β”‚ β”‚ β”‚ └── layout.json
β”‚ β”‚ β”œβ”€β”€ stay-match/
β”‚ β”‚ β”œβ”€β”€ roommate/
β”‚ β”‚ β”œβ”€β”€ altfinder/
β”‚ β”‚ β”œβ”€β”€ bonjour-services/
β”‚ β”‚ └── pride-city/
β”‚ └── apps/ # App-level tokens (unique to each app)
β”‚ β”œβ”€β”€ stay-overnight/
β”‚ β”‚ β”œβ”€β”€ hostguest-web.json
β”‚ β”‚ β”œβ”€β”€ pinkguest-web.json
β”‚ β”‚ β”œβ”€β”€ orangeguest-web.json
β”‚ β”‚ └── purpleguest-web.json
β”‚ β”œβ”€β”€ stay-match/
β”‚ β”‚ └── staymatch-web.json
β”‚ β”œβ”€β”€ roommate/
β”‚ β”‚ └── roommate-guru-web.json
β”‚ β”œβ”€β”€ altfinder/
β”‚ β”‚ └── altfinder-web.json
β”‚ └── bonjour-services/
β”‚ └── bonjour-services-web.json
β”œβ”€β”€ build/ # Generated platform outputs (git-committed)
β”‚ β”œβ”€β”€ css/ # CSS custom properties
β”‚ β”œβ”€β”€ scss/ # SCSS variables
β”‚ β”œβ”€β”€ js/ # JavaScript/TypeScript
β”‚ β”œβ”€β”€ tailwind/ # Tailwind config format
β”‚ β”œβ”€β”€ react-native/ # React Native TypeScript
β”‚ └── json/ # JSON for documentation
β”œβ”€β”€ style-dictionary.config.js # Build configuration
β”œβ”€β”€ package.json # Package manifest with scripts
β”œβ”€β”€ project.json # Nx configuration
β”œβ”€β”€ README.md # Comprehensive documentation
└── .gitignore # Excludes node_modules

3-Tier Hierarchical System:

  1. Global Tokens (tokens/global/)

    • Semantic colors (success, warning, error, info)
    • Ecosystem colors (pink, orange, purple, green, plum-wine, travelers-teal, hopper-lime)
    • Animation tokens (durations, easing, transitions)
  2. Division Tokens (tokens/divisions/{division}/)

    • Spacing scale (shared across all apps in division)
    • Typography (fonts, sizes, weights, line heights)
    • Shadows (elevation levels)
    • Layout (max widths, containers, border radius)
  3. App Tokens (tokens/apps/{division}/{app}.json)

    • Unique color palettes per app
    • App metadata (name, description)
    • Optional semantic color overrides

Style Dictionary successfully generates:

PlatformFileFormatUse Case
CSSbuild/css/variables.cssCSS custom propertiesWeb stylesheets
SCSSbuild/scss/_variables.scssSCSS variablesSASS/SCSS projects
JavaScriptbuild/js/tokens.jsES6 moduleReact, Vue, vanilla JS
TypeScriptbuild/js/tokens.d.tsType declarationsTypeScript projects
Tailwindbuild/tailwind/tokens.jsModule formatTailwind config
React Nativebuild/react-native/tokens.tsTypeScriptReact Native apps
JSONbuild/json/tokens.jsonNested structureDocumentation
JSONbuild/json/tokens-flat.jsonFlat structureInspection
  • Project: design-tokens configured in Nx graph
  • Build Command: yarn nx run design-tokens:build
  • Watch Mode: yarn nx run design-tokens:build:watch
  • Clean: yarn nx run design-tokens:clean
  • Lint: yarn nx run design-tokens:lint
  • README.md: Comprehensive guide with usage examples, workflows, and integration instructions
  • Inline Comments: All token files have descriptive comments
  • Type Safety: TypeScript declarations for IDE autocomplete
@import '@cloudalt-frontend/design-tokens/css';
.button {
background-color: var(--semantic-success);
padding: var(--spacing-4) var(--spacing-6);
border-radius: var(--layout-border-radius-md);
transition: all var(--transition-duration-DEFAULT) var(--transition-timing-ease);
}
/* App-specific colors */
.pinkguest-button {
background-color: var(--app-pinkguest-web-colors-primary);
color: var(--app-pinkguest-web-colors-accent);
}
packages/config/tailwind-preset.js
import tokens from '@cloudalt-frontend/design-tokens/tailwind';
export default {
theme: {
extend: tokens,
},
};
import tokens from '@cloudalt-frontend/design-tokens';
const Button = () => (
<button
style={{
backgroundColor: tokens.semantic.success,
padding: `${tokens.spacing[4]} ${tokens.spacing[6]}`,
borderRadius: tokens.layout.borderRadius.md,
}}
>
Click me
</button>
);
// Using app-specific tokens
const PinkGuestButton = () => (
<button
style={{
backgroundColor: tokens.app['pinkguest-web'].colors.primary,
color: tokens.app['pinkguest-web'].colors.accent,
}}
>
Pink Guest
</button>
);
import tokens from '@cloudalt-frontend/design-tokens/react-native';
import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({
button: {
backgroundColor: tokens.semantic.success,
padding: tokens.spacing[4],
borderRadius: tokens.layout.borderRadius.md,
},
// App-specific styling
pinkGuestButton: {
backgroundColor: tokens.app['pinkguest-web'].colors.primary,
},
});
Terminal window
# Build once
yarn nx run design-tokens:build
# Watch mode (rebuild on changes)
yarn nx run design-tokens:build:watch
# Clean generated files
yarn nx run design-tokens:clean

Add to CI/CD pipeline:

.github/workflows/build.yml
- name: Build Design Tokens
run: yarn nx run design-tokens:build

Before (packages/theme/src/tokens.ts):

  • Manual TypeScript object
  • Hard-coded values
  • No platform variants

After (with design-tokens):

packages/theme/src/tokens.ts
import tokens from '@cloudalt-frontend/design-tokens';
export const colors = {
primary: {
50: tokens.ColorPrimary50,
100: tokens.ColorPrimary100,
// ... etc
}
};

Before (packages/config/tailwind-preset.js):

  • Manually maintained theme object

After:

import tokens from '@cloudalt-frontend/design-tokens/tailwind';
export default {
theme: {
extend: tokens,
},
};

Integration:

packages/storybook/stories/DesignSystem/Colors.stories.tsx
import tokens from '@cloudalt-frontend/design-tokens';
// Use tokens to display current design system
export const BrandColors = () => (
<ColorSwatch
name="Primary 500"
color={tokens.ColorPrimary500}
/>
);

All 40+ mobile apps can now import tokens:

apps/altFinder/altFinder_app/mobile/src/theme.ts
import tokens from '@cloudalt-frontend/design-tokens/react-native';
export const theme = {
colors: {
primary: tokens.ColorPrimary500,
secondary: tokens.ColorSecondary500,
},
};
  • Before: Tokens duplicated in theme package, Tailwind config, mobile styles
  • After: Defined once in JSON, generated for all platforms
  • Auto-generated TypeScript declarations
  • IDE autocomplete for all tokens
  • Compile-time error checking
  • Same color values across web, mobile, iOS (future), Android (future)
  • Guaranteed visual consistency
  • Change token value once
  • Rebuild generates all platform files
  • Commit both source and generated files
  • Add new platforms (iOS Swift, Android XML) without changing source
  • Support multiple brands with token overrides
  • Dark mode variants easily managed
graph TD
A[Edit tokens/*.json] --> B[Run nx run design-tokens:build]
B --> C{Generate Outputs}
C --> D[CSS Variables]
C --> E[Tailwind Config]
C --> F[React Native TS]
C --> G[TypeScript/JS]
D --> H[Web Apps]
E --> H
F --> I[Mobile Apps]
G --> H
G --> I
  1. Migrate Existing Usage

    • Update packages/theme to import from design-tokens
    • Update packages/config/tailwind-preset.js to use generated tokens
    • Update Storybook stories to import from design-tokens
    • Update mobile apps to use React Native tokens
  2. Add to Build Pipeline

    • Add design-tokens:build to pre-commit hook
    • Add to CI/CD pipeline (GitHub Actions)
    • Add to Nx affected commands
  3. Documentation

    • Add design token guide to main README
    • Create examples for each platform
    • Document brand-specific overrides
  1. Brand Variants

    tokens/
    β”œβ”€β”€ core/ # Shared base tokens
    β”œβ”€β”€ altfinder/ # altFinder brand overrides
    β”œβ”€β”€ roommate/ # roommate brand overrides
    └── homestay/ # homestay brand overrides
  2. Figma Integration

    • Install Tokens Studio plugin
    • Sync design tokens from Figma
    • Automate design β†’ code workflow
  3. iOS/Android Support

    platforms: {
    ios: {
    transformGroup: 'ios-swift',
    buildPath: 'build/ios/',
    files: [{
    destination: 'StyleDictionaryColor.swift',
    format: 'ios-swift/class.swift',
    }],
    },
    android: {
    transformGroup: 'android',
    buildPath: 'build/android/',
    files: [{
    destination: 'colors.xml',
    format: 'android/resources',
    }],
    },
    }
  4. Dark Mode

    • Create tokens/themes/dark.json with overrides
    • Generate separate CSS files for dark mode
    • Use CSS custom properties for theme switching
  5. Semantic Aliases

    {
    "color": {
    "button": {
    "primary": { "value": "{color.primary.500}" }
    }
    }
    }
Terminal window
# Build tokens
yarn nx run design-tokens:build
yarn nx build design-tokens
# Watch mode
yarn nx run design-tokens:build:watch
# Clean generated files
yarn nx run design-tokens:clean
# Run from package directory
cd packages/design-tokens
yarn build
yarn build:watch
yarn clean
# Check Nx graph
yarn nx graph
# See affected projects
yarn nx affected:graph
packages/design-tokens/
β”œβ”€β”€ tokens/ # SOURCE FILES (edit these)
β”‚ β”œβ”€β”€ color.json # 🎨 Color palette
β”‚ β”œβ”€β”€ typography.json # πŸ“ Typography system
β”‚ β”œβ”€β”€ layout.json # πŸ“ Spacing, borders, shadows
β”‚ └── animation.json # ⚑ Breakpoints, transitions
β”‚
β”œβ”€β”€ build/ # GENERATED FILES (don't edit)
β”‚ β”œβ”€β”€ css/variables.css # Web CSS variables
β”‚ β”œβ”€β”€ scss/_variables.scss # SCSS variables
β”‚ β”œβ”€β”€ js/tokens.js # JavaScript ES6
β”‚ β”œβ”€β”€ js/tokens.d.ts # TypeScript declarations
β”‚ β”œβ”€β”€ tailwind/tokens.js # Tailwind config
β”‚ β”œβ”€β”€ react-native/tokens.ts # React Native
β”‚ └── json/tokens.json # Documentation
β”‚
β”œβ”€β”€ style-dictionary.config.js # Build configuration
β”œβ”€β”€ package.json # Package manifest
β”œβ”€β”€ project.json # Nx configuration
β”œβ”€β”€ README.md # Documentation
└── .gitignore # Excludes build/
  • βœ… Style Dictionary 5.1.1 installed and configured
  • βœ… 4 token categories migrated from TypeScript to JSON
  • βœ… 8 platform outputs generated successfully
  • βœ… Type-safe TypeScript declarations
  • βœ… Nx integrated with build, watch, and clean targets
  • βœ… Documented with comprehensive README and examples
  • βœ… Ready for production use across 40+ apps
  • Ensure you’re using import syntax in config (ESM)
  • Check Node version (requires Node 18+)
  • Run yarn nx run design-tokens:build
  • Check that source JSON files are valid
  • Clear build directory: yarn nx run design-tokens:clean
  • Restart TypeScript server
  • Run build to regenerate .d.ts files
  • Check that package.json types field is correct

Style Dictionary is now fully integrated into the CloudAlt monorepo, providing:

  1. Centralized token management - Single source of truth
  2. Multi-platform support - Web, mobile, and future platforms
  3. Type safety - Auto-generated TypeScript declarations
  4. Scalability - Ready for 40+ apps and multiple brands
  5. Developer experience - Simple build commands, hot reload

The foundation is set for a production-ready design system that scales across the entire monorepo! πŸŽ‰