Claude Skills Guide

Claude Code Design System Tokens: A Frontend Developer Guide

Design system tokens are the foundation of consistent, scalable user interfaces. When working with Claude Code’s canvas-design skill, understanding how to use these tokens can dramatically improve your workflow and output quality. This guide walks you through practical patterns for integrating design system tokens into your frontend development process.

What Are Design System Tokens?

Design system tokens are semantic, platform-agnostic values that represent design decisions. Instead of hardcoding colors like #0066CC throughout your codebase, you use semantic tokens like primary-color or text-primary. This abstraction layer makes it easy to:

Claude Code’s canvas-design skill uses a rich set of tokens organized by category: colors, typography, spacing, shadows, and borders. Each token has a purpose-specific name that communicates its intended use.

Working with Color Tokens

Color tokens in the canvas-design skill follow a hierarchical naming convention. Here’s how to apply them effectively:

// Using color tokens in your component styles
const buttonStyles = {
  backgroundColor: 'primary.500',      // Main brand color
  color: 'white',
  borderRadius: 'md',
  padding: '4 8',                      // 4 units vertical, 8 horizontal
};

const buttonHover = {
  backgroundColor: 'primary.600',     // Darker shade for hover state
};

// Accessible text with semantic tokens
const cardTitle = {
  color: 'gray.900',
  fontSize: 'xl',
  fontWeight: 'semibold',
};

The token hierarchy uses scales from 50 to 900, where lower numbers are lighter and higher numbers are darker. This scale system allows you to create visual hierarchy without guessing hex values.

Typography Tokens for Consistent Text

Typography tokens handle font families, sizes, weights, and line heights. Here’s a practical example:

// Define typography styles using tokens
const headingStyles = {
  fontFamily: 'heading',           // Heading font family
  fontWeight: 'bold',
  lineHeight: 'tight',
  color: 'gray.900',
};

const bodyStyles = {
  fontFamily: 'body',              // Body font family  
  fontSize: 'base',                // Base font size (typically 16px)
  lineHeight: 'normal',
  color: 'gray.700',
};

const captionStyles = {
  fontSize: 'sm',                  // Small text
  color: 'gray.500',
};

Typography tokens automatically adapt to your theme configuration, making global font changes straightforward.

Spacing and Layout Tokens

Spacing tokens use a consistent scale that ensures visual rhythm throughout your interface:

// Spacing token usage
const cardContainer = {
  padding: '6',                    // Generous padding
  marginBottom: '4',               // Space between cards
  gap: '3',                        // Gap between flex children
};

const formField = {
  marginBottom: '4',               // Consistent field spacing
  paddingX: '4',                  // Horizontal padding only
};

The spacing scale typically follows: 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64. Each step increases the spacing by a consistent multiplier.

Shadow and Elevation Tokens

Shadows create depth and indicate interactive states. The canvas-design skill provides tokens for various elevation levels:

// Elevation tokens
const cardBase = {
  backgroundColor: 'white',
  borderRadius: 'lg',
  boxShadow: 'sm',                 // Subtle shadow for cards
};

const cardHover = {
  boxShadow: 'md',                 // Medium shadow on hover
  transform: 'translateY(-2px)',  // Subtle lift effect
};

const modalOverlay = {
  backgroundColor: 'blackAlpha.600', // Semi-transparent overlay
  boxShadow: 'xl',                   // Strong shadow for modals
};

Border and Radius Tokens

Consistent border and radius values tie your interface together:

// Border tokens
const inputField = {
  borderWidth: '1px',
  borderColor: 'gray.300',
  borderRadius: 'md',              // Medium rounded corners
};

const inputFocus = {
  borderColor: 'primary.500',
  boxShadow: '0 0 0 3px primary.100', // Focus ring
};

// Button variations
const buttonPrimary = {
  borderRadius: 'md',
};

const buttonPill = {
  borderRadius: 'full',            // Fully rounded (pill shape)
};

Combining Tokens for Component Patterns

The real power of design tokens emerges when you combine them into reusable component patterns:

// A button component pattern
const createButton = (variant = 'primary') => {
  const variants = {
    primary: {
      backgroundColor: 'primary.500',
      color: 'white',
      _hover: { backgroundColor: 'primary.600' },
      _active: { backgroundColor: 'primary.700' },
    },
    secondary: {
      backgroundColor: 'gray.100',
      color: 'gray.800',
      _hover: { backgroundColor: 'gray.200' },
      _active: { backgroundColor: 'gray.300' },
    },
    outline: {
      backgroundColor: 'transparent',
      borderWidth: '1px',
      borderColor: 'primary.500',
      color: 'primary.500',
      _hover: { backgroundColor: 'primary.50' },
    },
  };

  return {
    padding: '3 6',
    borderRadius: 'md',
    fontWeight: 'medium',
    transition: 'all 0.2s',
    ...variants[variant],
  };
};

Theme Customization

The canvas-design skill supports theme customization through token overrides:

// Custom theme configuration
const customTheme = {
  colors: {
    primary: {
      50: '#e6f2ff',
      100: '#b3d9ff',
      500: '#0066cc',             // Your brand blue
      600: '#0052a3',
      700: '#003d7a',
    },
  },
  fonts: {
    heading: 'Inter, system-ui, sans-serif',
    body: 'Inter, system-ui, sans-serif',
  },
  radii: {
    none: '0',
    sm: '4px',
    md: '8px',
    lg: '12px',
    full: '9999px',
  },
};

Best Practices for Token Usage

  1. Prefer semantic tokens: Use text-primary over gray-900 when the meaning is clear. Semantic tokens communicate intent.

  2. Maintain consistency: Don’t mix raw values with tokens in the same component. Stick to the token system throughout.

  3. Use scales wisely: When choosing a color or spacing value, look at the full scale first. Picking from established scales ensures visual harmony.

  4. Document custom tokens: If you create custom tokens for your project, document their purpose and usage context.

  5. Test across themes: Verify your components work with different theme configurations, especially for dark mode.

Conclusion

Design system tokens transform how you build user interfaces. By using Claude Code’s canvas-design skill token system, you create applications that are consistent, maintainable, and themable. Start with the basic color, typography, and spacing tokens, then build up to more complex component patterns as your familiarity grows.

The investment in learning token-based design pays dividends in reduced design debt, faster iteration, and more cohesive user experiences.

Built by theluckystrike — More at zovo.one