Context file for AI agents working in this repository.
Radix Themes (@radix-ui/themes) is an open-source React component library optimized for fast development, easy maintenance, and accessibility. It provides a comprehensive set of pre-styled, themeable UI components built on top of Radix Primitives.
- Package name:
@radix-ui/themes - Current version: 3.x (check
packages/radix-ui-themes/package.jsonfor exact version) - License: MIT
- Documentation: https://www.radix-ui.com/themes/docs/theme
The full docs for this project are hosted at:
- Theme overview: https://www.radix-ui.com/themes/docs/theme/overview
- Component docs: https://www.radix-ui.com/themes/docs/components (e.g.,
.../components/button,.../components/dialog) - Utilities: https://www.radix-ui.com/themes/docs/utilities/box
- Releases: https://www.radix-ui.com/themes/docs/overview/releases
When you need to understand a component's API, intended behavior, or usage patterns, consult the docs at the URLs above rather than guessing. The documentation site lives in a separate repository.
This is a pnpm monorepo managed with Turborepo.
themes/
├── packages/
│ └── radix-ui-themes/ # The core library (published as @radix-ui/themes)
│ ├── src/
│ │ ├── components/ # All component source files
│ │ │ ├── _internal/ # Shared base components (not exported)
│ │ │ ├── *.tsx # Component implementations
│ │ │ ├── *.props.tsx # Component prop definitions
│ │ │ ├── *.css # Component styles
│ │ │ └── index.tsx # Public component exports
│ │ ├── helpers/ # Utility functions (prop extraction, responsive styles, etc.)
│ │ ├── props/ # Shared prop definitions (color, margin, radius, etc.)
│ │ ├── styles/
│ │ │ ├── tokens/ # Design tokens (colors, typography, radius, shadow, spacing)
│ │ │ └── utilities/ # CSS utility classes (layout, typography)
│ │ └── index.ts # Package entry point
│ ├── scripts/ # Build scripts (esbuild CJS/ESM)
│ ├── postcss.config.cjs # PostCSS config with custom plugins
│ ├── tsconfig.json
│ └── package.json
├── apps/
│ └── playground/ # Next.js App Router playground for development
│ ├── app/
│ │ ├── (themeable)/sink/ # Main component showcase (http://localhost:3000/sink)
│ │ ├── (themeable)/test/ # Test pages for specific scenarios
│ │ └── (themeable)/demo/ # Demo pages
│ ├── tests/ # Playwright visual regression tests
│ └── playwright.config.ts
├── .github/
│ ├── workflows/
│ │ ├── ci.yml # Build, lint, format check, visual regression
│ │ └── publish.yml # Publish to npm on GitHub release
│ └── CONTRIBUTING.md
├── package.json # Root monorepo config
├── pnpm-workspace.yaml
└── turbo.json
| Concern | Tool |
|---|---|
| Package manager | pnpm 10 (see .npmrc) |
| Node version | 24 (see .nvmrc) |
| Monorepo orchestration | Turborepo |
| Language | TypeScript (strict) |
| Framework | React (16.8+, 17, 18, 19 supported) |
| JS bundler | esbuild (dual CJS + ESM output) |
| CSS processing | PostCSS (nesting, custom-media, breakpoints, autoprefixer) |
| Linting | ESLint (flat config), Stylelint (for CSS) |
| Formatting | Prettier (single quotes, 100 print width, 120 for CSS) |
| Playground | Next.js (App Router) |
| Testing | Playwright (visual regression) |
Run all commands from the repository root unless stated otherwise:
# Install dependencies
pnpm install
# Start development (playground + watch mode)
pnpm dev
# Then visit http://localhost:3000/sink
# Build the library
pnpm build
# Build only the themes package
pnpm build:pkg
# Lint everything
pnpm lint
# Format code
pnpm format
# Check formatting
pnpm format:check
# Run visual regression tests
pnpm test:vr
# Update visual regression snapshots
pnpm test:vr:update
# Clean all build artifacts
pnpm cleanEach component typically consists of three co-located files:
component-name.tsx— React component implementationcomponent-name.props.tsx— Prop type definitions and default valuescomponent-name.css— Component styles using CSS custom properties and data attributes
Some complex components also have a .primitive.tsx file for lower-level behavior (e.g., checkbox-cards.primitive.tsx).
- Components use CSS custom properties (CSS variables) for theming
- Design tokens are defined in
src/styles/tokens/and include 27+ color scales from@radix-ui/colors - Responsive props use breakpoint-based classes generated via a custom PostCSS plugin (
postcss-breakpoints.cjs) - Layout utility classes are generated from
src/styles/utilities/ - The
Themecomponent wraps the app and provides theming context (appearance, accent color, gray color, radius, scaling)
- Components use a typed prop definition system in
src/props/prop-def.ts - Most visual props support responsive objects (e.g.,
size={{ initial: '1', md: '3' }}) - Common shared props:
color,highContrast,radius,variant,size,weight,asChild - Margin props (
m,mx,my,mt,mr,mb,ml) are extracted viaextractMarginProps()
The package produces:
- CJS output →
dist/cjs/(via esbuild) - ESM output →
dist/esm/(via esbuild) - Type declarations →
dist/cjs/anddist/esm/(via tsc) - CSS output → multiple CSS files at package root:
styles.css— Full styles (tokens + components + utilities)components.css— Component styles onlyutilities.css— Utility classes onlytokens.css— Design tokens onlytokens/base.css,tokens/colors/*.css— Granular token fileslayout.css,layout/*.css— Layout-only subset
- Run
pnpm devto start the playground and watch mode - Visit
http://localhost:3000/sinkto see all components - Test pages are at
http://localhost:3000/test/*for specific scenarios - Demo pages at
http://localhost:3000/demo - Always run
pnpm buildbefore submitting a PR to ensure the build succeeds - Visual regression tests compare screenshots across browsers (Chromium, Firefox, WebKit)
- Prettier for formatting (single quotes, 100 char width, 120 for CSS)
- ESLint with TypeScript, React Hooks, and jsx-a11y rules
- Stylelint for CSS (enforces selector specificity, class naming patterns)
- CSS class names follow the pattern
.rt-ComponentName(e.g.,.rt-Button,.rt-DialogContent) - CSS custom properties use
--prefix namespacing - Component files use kebab-case naming (e.g.,
alert-dialog.tsx) - Props files export a
*PropDefsobject defining allowed values and defaults - Use
classnameslibrary for conditional class merging
- PRs that fix bugs or add features should update
packages/radix-ui-themes/CHANGELOG.md - Releases follow semver and are published via GitHub Releases
- The
publish.ymlworkflow automatically publishes to npm when a GitHub release is created - Pre-releases use
pnpm publish -r --tag <alpha|beta|rc>
See release-process.md for the full release checklist.
- The documentation site is in a separate repo (
radix-ui/website), not this one - Built CSS files at the package root (e.g.,
styles.css,components.css) are gitignored — they are build artifacts - The
dist/,tokens/, andlayout/directories are also gitignored build artifacts - When modifying a component, update all three files (
.tsx,.props.tsx,.css) as needed - The
Themecomponent (theme.tsx) is the root provider — all other components must be used within it