# radix-ui/themes architecture

> Architecture diagram of the GitHub repository radix-ui/themes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/radix-ui/themes
- Repository: https://github.com/radix-ui/themes

## Overview

##### Main Components Structure

a. Core Library Components
- Base Components (from _internal folder)
- UI Components (buttons, dialogs, etc.)
- Layout Components (flex, grid, container)
- Typography Components (text, heading, etc.)
- Relationships between base components and their implementations

b. Styling System
- Utilities (layout, flexbox, grid)
- Breakpoints system
- Theme configuration

c. Helper Functions
- A "Helpers" module containing:
- Prop extractors
- Style processors
- Utility functions

##### Specific Implementation Details

a. Component Architecture
**BaseComponent (Internal)**
- ↓
**Component Implementation**
- ↓
**Props Interface**
- ↓
**Styles (CSS Modules)**

b. Theme System
**Theme Provider**
- ↓
- ↓
**Component Styles**

##### Key Relationships

- Theme context flow through components
- Base component inheritance patterns
- Style token consumption
- Prop system integration

##### External Dependencies
Integration with:
- React
- CSS Modules
- PostCSS system
- Build tools (esbuild)

##### Development Tools Integration
Include:
- Playground app connection
- Testing infrastructure
- Build pipeline

**┌─ Radix Themes Library ─────────────────────┐**

- ┌─ Components ─┐  ┌─ Styling System ─┐    │
- Base         │  │ Tokens           │    │
- UI Elements  │←─│ Utilities        │    │
- Layout       │  │ Theme Config     │    │
- ┘  └─────────────────┘     │
- ↑               ↑                  │
- ┌─ Helpers ──┐  ┌─ Build System ─┐       │
- Props      │  │ ESBuild        │       │
- Styles     │  │ PostCSS        │       │
- ┘  └─────────────────┘     │

- ┘

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph RadixThemes["Radix Themes Library"]
        subgraph Components["Component Layer"]
            BaseComp["Base Components"]
            UIComp["UI Components"]
            LayoutComp["Layout Components"]
            TypoComp["Typography Components"]
            
            BaseComp --> UIComp
            BaseComp --> LayoutComp
            BaseComp --> TypoComp
        end

        subgraph Styling["Styling System"]
            ThemeSystem["Theme Provider"]
            StyleTokens["Style Tokens"]
            StyleUtils["Style Utilities"]
            Breakpoints["Breakpoints System"]
            
            ThemeSystem --> StyleTokens
            ThemeSystem --> StyleUtils
            ThemeSystem --> Breakpoints
        end

        subgraph Support["Support Systems"]
            Helpers["Helper Functions"]
            Props["Props System"]
            Build["Build System"]
            Playground["Playground"]
        end

        %% Main relationships
        Styling --> Components
        Support --> Components
        Support --> Styling
    end

    %% Click events
    click BaseComp "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/components/_internal/"
    click UIComp "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/components/"
    click ThemeSystem "https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/theme.tsx"
    click StyleTokens "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/styles/tokens/"
    click StyleUtils "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/styles/utilities/"
    click Breakpoints "https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/styles/breakpoints.css"
    click Helpers "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/helpers/"
    click Props "https://github.com/radix-ui/themes/tree/main/packages/radix-ui-themes/src/props/"
    click LayoutComp "https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/container.tsx"
    click TypoComp "https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/src/components/text.tsx"
    click Build "https://github.com/radix-ui/themes/blob/main/packages/radix-ui-themes/esbuild-cjs.mjs"
    click Playground "https://github.com/radix-ui/themes/tree/main/apps/playground/"

    %% Styling
    classDef component fill:#2563eb,color:#fff
    classDef styling fill:#16a34a,color:#fff
    classDef support fill:#ca8a04,color:#fff
    
    class BaseComp,UIComp,LayoutComp,TypoComp component
    class ThemeSystem,StyleTokens,StyleUtils,Breakpoints styling
    class Helpers,Props,Build,Playground support
```
