React
Tailwind CSS v4 - a utility-first CSS framework that compiles atomic CSS classes into optimized stylesheets. This is the core framework monorepo containing the CSS compilation engine, a high-performance Rust-based class scanner (Oxide), build tool integrations (Vite, PostCSS, Webpack), CLI tools, and an automated v3-to-v4 migration system.
Tech Stack
Key Features
- Core CSS Compilation Engine
- Oxide Scanner (Rust)
- Build Tool Integrations
- v3 Compatibility Layer
- Automated Upgrade Tool
- Standalone Binary
- Browser Compilation
Entry Points
Start here when working with this codebase
packages/tailwindcss/src/index.tsMain entry point for Tailwind CSS compilation - exports compile function and core APIs
Start here when modifying core CSS generation, adding new at-rules, or changing compilation behavior
packages/@tailwindcss-cli/src/index.tsCommand-line interface entry point - handles build, watch, and init commands
Start here when adding new CLI commands or modifying CLI behavior
packages/@tailwindcss-vite/src/index.tsVite integration plugin - handles HMR, CSS transformation, and build optimization
Start here when fixing Vite-specific issues or adding Vite integration features
packages/@tailwindcss-postcss/src/index.tsPostCSS plugin integration - processes CSS through PostCSS pipeline
Start here when modifying PostCSS integration or fixing PostCSS-specific bugs
packages/@tailwindcss-upgrade/src/index.tsv3 to v4 migration tool entry - orchestrates codemods and file transformations
Start here when adding new migration codemods or fixing upgrade issues
crates/oxide/src/lib.rsHigh-performance Rust scanner for extracting Tailwind classes from source files
Start here when optimizing class extraction or adding new language support
crates/node/src/lib.rsNAPI bindings exposing Rust oxide scanner to Node.js
Start here when adding new Rust functions to expose to JavaScript
packages/@tailwindcss-browser/src/index.tsBrowser-based Tailwind compilation for playgrounds and REPLs
Start here when modifying browser-specific compilation or playground features
How to Make Changes
Common modification patterns for this codebase
Add a new CSS utility class
packages/tailwindcss/src/utilities.tsAdd utility definition to the utilities map with CSS properties and values
Pattern: Follow the pattern of existing utilities like 'flex' or 'grid' - each utility maps a class name to CSS declarations
packages/tailwindcss/src/utilities.test.tsAdd test cases for the new utility covering all variants
Pattern: Follow test structure in this file - use css() helper to verify generated CSS output
packages/tailwindcss/src/index.tsVerify utility is registered in the compilation pipeline (usually automatic)
Pattern: Check how utilities are loaded and registered in the compile function
Conventions to follow:
Add a new CSS at-rule (like @apply or @theme)
packages/tailwindcss/src/ast.tsDefine AST node type for the new at-rule if needed
Pattern: Follow AtRule interface pattern - see how @theme and @apply nodes are defined
packages/tailwindcss/src/index.tsAdd at-rule processing logic in the compile function's AST walk
Pattern: See how @theme is processed - walk the AST, identify the at-rule, transform it
packages/tailwindcss/src/index.test.tsAdd comprehensive tests for the new at-rule
Pattern: Follow existing at-rule tests - test parsing, transformation, and edge cases
Conventions to follow:
Add support for a new template language in Oxide scanner
crates/oxide/src/extractor/pre_processors/mod.rsRegister the new pre-processor module
Pattern: Follow how pug.rs and haml.rs are registered - add mod declaration and export
crates/oxide/src/extractor/pre_processors/Create new pre-processor file (e.g., svelte.rs) implementing the PreProcessor trait
Pattern: Follow crates/oxide/src/extractor/pre_processors/pug.rs - implement pre_process() to extract class-relevant content
crates/oxide/src/lib.rsWire up the pre-processor to file extension detection
Pattern: See how file extensions map to pre-processors in the Scanner implementation
crates/oxide/tests/Add integration tests for the new language
Pattern: Follow existing test patterns - create test fixtures and verify extracted candidates
Conventions to follow:
Add a new CLI command
packages/@tailwindcss-cli/src/commands/Create new command file (e.g., lint.ts) with command implementation
Pattern: Follow packages/@tailwindcss-cli/src/commands/build.ts - export default async function with args parsing
packages/@tailwindcss-cli/src/index.tsRegister the new command in the CLI router
Pattern: See how 'build' and 'init' commands are registered - add case in command switch
packages/@tailwindcss-cli/src/help.tsAdd help text for the new command
Pattern: Follow existing help text format - include usage, options, and examples
Conventions to follow:
Add a new upgrade codemod for v3 to v4 migration
packages/@tailwindcss-upgrade/src/codemods/css/Create CSS codemod if transforming CSS files
Pattern: Follow packages/@tailwindcss-upgrade/src/codemods/css/migrate-at-apply.ts - export function that transforms AST
packages/@tailwindcss-upgrade/src/codemods/template/Create template codemod if transforming HTML/JSX class attributes
Pattern: Follow packages/@tailwindcss-upgrade/src/codemods/template/migrate-legacy-classes.ts - use candidate parsing
packages/@tailwindcss-upgrade/src/codemods/config/Create config codemod if transforming tailwind.config.js
Pattern: Follow existing config codemods - use jscodeshift for AST manipulation
packages/@tailwindcss-upgrade/src/index.tsRegister the codemod in the upgrade pipeline
Pattern: See how codemods are orchestrated - add to appropriate phase (css, template, or config)
Conventions to follow:
Add integration tests for a build tool plugin
integrations/utils.tsReview test utilities and helpers available
Pattern: This file provides test harness - use candidate(), css(), and exec() helpers
integrations/vite/Add Vite integration test (or integrations/webpack/, integrations/postcss/)
Pattern: Follow existing integration test structure - create fixture, run build, assert output
vitest.config.tsVerify test is included in test configuration
Pattern: Check include patterns cover your new test directory
Conventions to follow:
Expose new Rust function to Node.js
crates/oxide/src/lib.rsImplement the core Rust function
Pattern: Follow existing public functions - use appropriate Rust types and error handling
crates/node/src/lib.rsAdd NAPI binding for the function using #[napi] macro
Pattern: Follow existing bindings like scan_files - use napi-rs types for JS interop
packages/@tailwindcss-node/src/index.tsExport the new function from the Node package
Pattern: Import from native binding and re-export with TypeScript types
crates/node/build.rsVerify build configuration if adding new dependencies
Pattern: Check NAPI build settings are correct for the new binding
Conventions to follow:
Add v3 config compatibility feature
packages/tailwindcss/src/compat/config.tsAdd config transformation logic for the v3 feature
Pattern: Follow existing config normalization - transform v3 config shape to v4 internal format
packages/tailwindcss/src/compat/plugin-api.tsUpdate plugin API compatibility if needed
Pattern: See how v3 plugin functions are adapted to v4 internals
packages/tailwindcss/src/compat/apply-config-to-theme.tsHandle theme merging for the feature
Pattern: Follow theme extension patterns - merge user config with defaults
Conventions to follow:
Coding Conventions
Standards and patterns used in this codebase
Monorepo structure: apps/ contains deployable applications, packages/ contains shared libraries
Packages: packages/@tailwindcss-browser, packages/@tailwindcss-cli, packages/@tailwindcss-nodeFile naming uses: kebab-case
vitest.config.ts, utils.ts, version-packages.mjs, build.rs, playwright.config.tsTypeScript is the primary language
All new files should be .ts or .tsxTests use .test. pattern
Test files are named like component.test.ts or placed in __tests__/Configuration is centralized in config files
Config files: vitest.config.ts, packages/@tailwindcss-browser/playwright.config.tsUse index.ts barrel files to export module public API
Each module has index.ts that re-exports public functionsTypes are defined in dedicated type files
Type files: packages/@tailwindcss-standalone/src/types.d.ts