Skip to main content

Overview

The project uses CSS Modules for component styling with a comprehensive theme system built on Radix UI Colors. Every component has a colocated styles.module.css file, and all styles leverage CSS custom properties from the global theme.

CSS Modules

File Organization

Every component directory contains a styles.module.css file:

Import Pattern

Import CSS modules as a default import named styles:
components/button/index.tsx

Naming Convention

All CSS class names use kebab-case:

Conditional Class Composition

Use clsx for composing classes conditionally:

Theme System

The theme is organized across multiple CSS files in /styles/:

Colors

The project uses Radix UI Colors for a comprehensive, accessible color system with automatic dark mode support.

Gray Scale

The primary gray scale provides 12 steps for UI elements:
color
Solid colors from lightest (1) to darkest (12). Use for backgrounds, borders, and text.
alpha color
Alpha variants with transparency. Useful for overlays and subtle backgrounds.
Example Usage

Semantic Colors

All Radix color scales are available with the same 1-12 and a1-a12 patterns:
components/callout/styles.module.css

Available Color Scales

All colors from Radix UI Colors are available:
  • Gray family: gray, mauve, slate, sage, olive, sand
  • Colors: tomato, red, ruby, crimson, pink, plum, purple, violet, iris, indigo, blue, cyan, teal, jade, green, grass, lime, mint, sky
  • Metals: bronze, gold
  • Bright: amber, yellow, orange, brown

Typography

Typography variables are defined in styles.typography.css:

Font Weights

Letter Spacing

Optical letter spacing values for font sizes from 12px to 48px:
Always pair letter spacing with font size:

Shadows

A six-level shadow system with automatic dark mode support:
inset shadow
Inset shadow for pressed/sunken elements like input fields
elevation
Subtle elevation for buttons and cards at rest
elevation
Medium elevation for dropdowns and popovers
elevation
High elevation for modals and dialogs
elevation
Very high elevation for tooltips
elevation
Maximum elevation for notification toasts
Example Usage
The shadow system automatically adapts to dark mode using color-mix when supported.

Layout Variables

Layout variables are defined in styles.css:

Size Scales

Use consistent size scales across components for visual harmony:

Button Sizes

components/button/styles.module.css

Applying to Square Elements

Transitions

Standard Timing

Use consistent transition durations and easing:

Active States

Apply scale transform on interaction:
The transform transition ensures smooth animation when scaling.

Data Attribute Styling

Use data attributes for variant styling instead of multiple classes:
This pattern keeps variant logic in CSS and reduces the need for conditional class composition in JavaScript.

Responsive Design

The project uses CSS custom properties with safe area insets for responsive padding:
This ensures content respects device notches and safe areas on mobile devices.

Dark Mode

Dark mode is handled automatically by Radix UI Colors. Each color scale has dark variants that are applied when the .dark or .dark-theme class is present:
You don’t need to write separate dark mode styles. By using the theme variables, your components automatically adapt to light and dark modes.

Best Practices

Never hardcode colors, shadows, or typography values. Always use CSS custom properties from the theme.
All CSS class names must use kebab-case: .button-primary, .nav-item, .text-selection-popover
Keep styles.module.css in the same directory as the component. Never create a separate /styles/components/ directory.
Always use the matching letter spacing variable for each font size:
  • 13px → var(--font-letter-spacing-13px)
  • 14px → var(--font-letter-spacing-14px)
  • 15px → var(--font-letter-spacing-15px)