Skip to content
Blog

Mastering Design Tokens in Astryx: Color, Typography, Spacing, and More

A deep dive into Astryx's 10-category semantic token system — covering color, typography, spacing, shape, elevation, motion, icons, and illustrations.

Published on July 31, 2026

AI Assistant

Astryx uses a comprehensive semantic token system — CSS custom properties named by purpose rather than appearance. Every design value in your UI should come from these tokens, which adapt automatically when you switch themes or color modes. There are 10 token categories in total.

Token Categories Overview

CategoryPrefixExample
Color--color-*--color-accent
Spacing--spacing-*--spacing-4
Radius--radius-*--radius-container
Shadow--shadow-*--shadow-med
Typography--text-*--text-body-size
Font--font-*--font-family-body
Size--size-*--size-element-md
Duration--duration-*--duration-fast
Easing--ease-*--ease-standard
Border--border-*--border-width

Using Tokens in CSS and StyleX

Plain CSS

.my-component {
  color: var(--color-text-primary);
  background: var(--color-background-surface);
  padding: var(--spacing-4);
  border-radius: var(--radius-container);
  box-shadow: var(--shadow-low);
  font-family: var(--font-family-sans);
}

StyleX with Typed Token Imports

import * as stylex from '@stylexjs/stylex';
import { colorVars, spacingVars } from '@astryxdesign/core';

const styles = stylex.create({
  card: {
    padding: spacingVars['--spacing-4'],
    backgroundColor: colorVars['--color-background-surface'],
    borderRadius: radiusVars['--radius-container'],
  },
});

1. Color System

The color system uses semantic tokens where names describe purpose, not appearance. All colors use CSS light-dark() for automatic light/dark mode switching — no manual prefers-color-scheme media query needed.

Surface Hierarchy (4 Levels)

TokenLightDarkUsage
--color-background-body#F1F4F7#111112Page background
--color-background-surface#FFFFFF#1F1F22Sidebar, Dialog
--color-background-card#FFFFFF#1F1F22Card
--color-background-popover#FFFFFF#28292CDropdown, Tooltip, Modal

Text Colors (4 Levels)

TokenLightDark
--color-text-primary#0A1317#DFE2E5
--color-text-secondary#4E606F#AAAFB5
--color-text-disabled#A4B0BC#6F747C
--color-text-accent#0064E0#3E9EFB

Best Practices

  • Use semantic tokens instead of hex values
  • Follow the surface hierarchy: body → surface → card → popover
  • Use status colors only for their semantic meaning
  • Don’t mix accent and status colors in the same context

2. Typography

The type system uses a geometric scale: round(14 × 1.2^step). Base = 14px, ratio = 1.2.

Semantic Type Scale

LevelSizeWeightUsage
display-142px400Hero banners
heading-124px600Main heading
body14px400Main body text
supporting12px400Captions, metadata
label14px500Form labels
code14px400Code, numbers
<Heading level={1} type="display-1">Hero Title</Heading>
<Text type="body">Body text at base scale.</Text>
<Text type="label">Form Label</Text>
<Text type="supporting">Helper text, timestamps, metadata.</Text>
<Text type="code">const x = 1;</Text>

3. Spacing

A 4px-base-unit scale. All spacing values are multiples of 4px.

ValueUsage
--spacing-1 (4px)Very tight: icon next to text
--spacing-2 (8px)Close: label to input
--spacing-4 (16px)Standard: elements in same group
--spacing-6 (24px)Between sections/subgroups
--spacing-8 (32px)Between major groups or page edges
<VStack gap={4}>   {/* 16px gap */}
<HStack gap={3}>   {/* 12px gap */}

4. Shape / Radius

A 7-level radius scale:

TokenValueUsage
--radius-inner4pxInput fields, small buttons
--radius-element8pxButtons, Badge
--radius-container12pxCard, Dialog, Sheet
--radius-page28pxSpecial containers, Drawer
--radius-full9999pxCircle, Pill

5. Elevation / Shadows

3 elevation levels + 5 inset shadow tokens:

TokenUsage
--shadow-lowTooltips, subtle cards
--shadow-medDropdowns, popovers
--shadow-highDialogs, modals

6. Motion

Duration and easing tokens organized in 3 bands:

DurationValueUsage
--duration-fast150msHover, button press
--duration-normal200msState change, standard
--duration-slow300msMenu/dialog open

Always honor prefers-reduced-motion:

@media (prefers-reduced-motion: reduce) {
  .animated-element {
    transition-duration: 0.01ms !important;
  }
}

7. Icons

Astryx separates icon identity from SVG files using semantic names. Register your own icon set once at the entry point:

import { registerIcons } from '@astryxdesign/core/Icon';
import { XMarkIcon, ChevronDownIcon } from '@heroicons/react/24/outline';

registerIcons({
  close: <XMarkIcon />,
  chevronDown: <ChevronDownIcon />,
});

8. Illustrations

Illustrations are reserved for emotional/status communication — not decoration. Use them in empty states, onboarding, error states, and celebration screens:

<EmptyState
  illustration={<MyIllustration />}
  title="No results found"
  description="Try adjusting your search or filters"
  action={<Button label="Create new item" />}
/>

CLI Reference

View all tokens at any time:

npx astryx docs tokens
npx astryx docs tokens --dense   # compact for AI context
npx astryx docs color
npx astryx docs typography
npx astryx docs spacing
npx astryx docs shape
npx astryx docs elevation
npx astryx docs motion
npx astryx docs icons