Overview
The project uses CSS Modules for component styling with a comprehensive theme system built on Radix UI Colors. Every component has a colocatedstyles.module.css file, and all styles leverage CSS custom properties from the global theme.
CSS Modules
File Organization
Every component directory contains astyles.module.css file:
Import Pattern
Import CSS modules as a default import namedstyles:
components/button/index.tsx
Naming Convention
All CSS class names use kebab-case:Conditional Class Composition
Useclsx 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:Solid colors from lightest (1) to darkest (12). Use for backgrounds, borders, and text.
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:| Color | Use Case | Variables |
|---|---|---|
blue | Info, links, primary actions | --blue-1 to --blue-12, --blue-a1 to --blue-a12 |
red | Errors, destructive actions | --red-1 to --red-12, --red-a1 to --red-a12 |
green | Success states | --green-1 to --green-12, --green-a1 to --green-a12 |
amber | Warnings | --amber-1 to --amber-12, --amber-a1 to --amber-a12 |
purple | Ideas, creative elements | --purple-1 to --purple-12, --purple-a1 to --purple-a12 |
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 instyles.typography.css:
Font Weights
Letter Spacing
Optical letter spacing values for font sizes from 12px to 48px:Shadows
A six-level shadow system with automatic dark mode support:Inset shadow for pressed/sunken elements like input fields
Subtle elevation for buttons and cards at rest
Medium elevation for dropdowns and popovers
High elevation for modals and dialogs
Very high elevation for tooltips
Maximum elevation for notification toasts
Example Usage
Layout Variables
Layout variables are defined instyles.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:| Property | Duration | Easing | Use Case |
|---|---|---|---|
color | 200ms | ease | Color changes |
background-color | 200ms | ease | Background changes |
transform | 180ms | ease | Scale/rotate/translate |
opacity | 200ms | ease | Fade in/out |
Active States
Apply scale transform on interaction:transform transition ensures smooth animation when scaling.
Data Attribute Styling
Use data attributes for variant styling instead of multiple classes:Responsive Design
The project uses CSS custom properties with safe area insets for responsive padding: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-popoverKeep
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)