Tailwind CSS v4
The theme uses the latest Tailwind CSS v4, which introduces a new configuration approach using CSS-based theming instead of JavaScript configuration files.Main Configuration File
The primary configuration is insource/css/tailwind.css:
Content Sources
Tailwind v4 uses@source directives to scan files for class names:
Custom Theme
The@theme block defines custom design tokens:
Custom Colors
Define brand colors:Custom Fonts
Add custom font families:Custom Spacing
Create dynamic spacing values:Custom Aspect Ratios
Define aspect ratio utilities:CSS Architecture
The theme organizes CSS into logical layers:Base Layer
Foundational styles applied globally:- reset.css - Browser normalization
- animations.css - Keyframe animations
- typography.css - Text styles and rhythm
- forms.css - Form element styles
- buttons.css - Button styles
Components Layer
Reusable component styles:- blog-comments.css - Blog comment styles
- yt-lite.css - YouTube embed styles
- system.css - System page styles
Utilities Layer
Custom utility classes:- utils.css - Helper utilities
Building CSS
Tailwind CSS is compiled using the Tailwind CLI:- Reads
source/css/tailwind.css - Scans source files for classes
- Generates optimized CSS
- Outputs to
theme/css/tailwind.css
Custom Utilities
Create custom utilities insource/css/utilities/utils.css:
Responsive Design
Use Tailwind’s responsive prefixes:Dark Mode
Implement dark mode with thedark: prefix:
Performance
Tailwind v4 optimizations:- Just-in-time compilation - Only generates used classes
- Fast builds - Rust-based compiler
- Small bundle size - No unused CSS
- Modern CSS - Uses native CSS features
Best Practices
Use Semantic Class Names
Extract Repeated Patterns
For frequently used combinations, create components in CSS or modules.Keep It Maintainable
- Use consistent spacing scales
- Stick to the design system
- Leverage custom theme values
- Document custom utilities
Extending the Theme
Add new design tokens to@theme: