shadcn/ui with Tailwind v4 Design System Guidelines
This document outlines design principles and implementation guidelines for applications using shadcn/ui with Tailwind v4. These guidelines ensure consistency, accessibility, and best practices throughout the UI development process.
Core Design Principles
1. Typography System: 4 Sizes, 2 Weights
- 4 Font Sizes Only:
- Size 1: Large headings
- Size 2: Subheadings/Important content
- Size 3: Body text
- Size 4: Small text/labels
- 2 Font Weights Only:
- Semibold: For headings and emphasis
- Regular: For body text and general content
- Consistent Hierarchy: Maintain clear visual hierarchy with limited options
2. 8pt Grid System
- All spacing values must be divisible by 8 or 4
- Examples:
- Instead of 25px padding → Use 24px (divisible by 8)
- Instead of 11px margin → Use 12px (divisible by 4)
- Consistent Rhythm: Creates visual harmony throughout the interface
3. 60/30/10 Color Rule
- 60%: Neutral color (white/light gray)
- 30%: Complementary color (dark gray/black)
- 10%: Main brand/accent color (e.g., red, blue)
- Color Balance: Prevents visual stress while maintaining hierarchy
4. Clean Visual Structure
- Logical Grouping: Related elements should be visually connected
- Deliberate Spacing: Spacing between elements should follow the grid system
- Alignment: Elements should be properly aligned within their containers
- Simplicity Over Flashiness: Focus on clarity and function first
Foundation
Tailwind v4 Integration
- Use Tailwind CSS v4 for styling: Leverage the latest Tailwind features including the new @theme directive, dynamic utility values, and OKLCH colors. Tailwind CSS v4 Documentation
- Modern browsing features: Tailwind v4 uses bleeding-edge browser features and is designed for modern browsers.
- Simplified installation: Fewer dependencies, zero configuration required in many cases.
- shadcn/ui v4 demo: Reference the demo site for component examples. shadcn/ui v4 Demo
New CSS Structure
Typography System
Font Sizes & Weights
- Strictly limit to 4 distinct sizes:
- Size 1: Large headings (largest)
- Size 2: Subheadings
- Size 3: Body text
- Size 4: Small text/labels (smallest)
- Only use 2 font weights:
- Semibold: For headings and emphasis
- Regular: For body text and most UI elements
- Common mistakes to avoid:
- Using more than 4 font sizes
- Introducing additional font weights
- Inconsistent size application
Typography Implementation
- Reference shadcn's typography primitives for consistent text styling
- Use monospace variant for numerical data when appropriate
- data-slot attribute: Every shadcn/ui primitive now has a data-slot attribute for styling
- Maintain hierarchy using consistent sizing patterns
8pt Grid System
Spacing Guidelines
Implementation
- Tailwind v4 dynamic spacing: Spacing utilities accept any value without arbitrary syntax
- Consistent component spacing: Group related elements with matching gap values
- Check responsive behavior: Ensure grid system holds at all breakpoints
60/30/10 Color Rule
Color Distribution
60%: neutral color (bg-background)
- Usually white or light gray in light mode
- Dark gray or black in dark mode
- Used for primary backgrounds, cards, containers
30%: complementary color (text-foreground)
- Usually dark gray or black in light mode
- Light gray or white in dark mode
- Used for text, icons, subtle UI elements
10%: accent color (brand color)
- Your primary brand color (red, blue, etc.)
- Used sparingly for call-to-action buttons, highlights, important indicators
- Avoid overusing to prevent visual stress
Common Mistakes
- ❌ Overusing accent colors creates visual stress
- ❌ Not enough contrast between background and text
- ❌ Too many competing accent colors (stick to one primary accent)
Implementation with shadcn/ui
Component Architecture
shadcn/ui Component Structure
- 2-layered architecture:
- Structure and behavior layer (Radix UI primitives)
- Style layer (Tailwind CSS)
- Class Variance Authority (CVA) for variant styling
- data-slot attribute for styling component parts
Implementation
- Install components individually using CLI (updated for v4) or manual installation
- Component customization: Modify components directly as needed
- Radix UI primitives: Base components for accessibility and behavior
- New-York style: Default recommended style for new projects (deprecated "default" style)
Visual Hierarchy
Design Principles
- Simplicity over flashiness: Focus on clarity and usability
- Emphasis on what matters: Highlight important elements
- Reduced cognitive load: Use consistent terminology and patterns
- Visual connection: Connect related UI elements through consistent patterns
Implementation
- Use shadcn/ui Blocks for common UI patterns
- Maintain consistent spacing between related elements
- Align elements properly within containers
- Logical grouping of related functionality
Installation & Setup
Project Setup
- CLI initialization:
npx create-next-app@latest my-app
cd my-app
npx shadcn-ui@latest init
- Manual setup: Follow the guide at Manual Installation
- components.json configuration:
{
"style": "new-york",
"rsc": true,
"tailwind": {
"config": "",
"css": "app/globals.css",
"baseColor": "neutral",
"cssVariables": true
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
Adding Components
- Use the CLI:
npx shadcn-ui@latest add button
- Install dependencies: Required for each component
- Find components: Component Reference
Advanced Features
Dark Mode
- Updated dark mode colors for better accessibility using OKLCH
- Consistent contrast ratios across light and dark themes
- Custom variant:
@custom-variant dark (&:is(.dark *))
Container Queries
- Built-in support without plugins
- Responsive components that adapt to their container size
- @min- and @max- variants** for container query ranges
Data Visualization
- Chart components: Use with consistent styling
- Consistent color patterns: Use chart-1 through chart-5 variables
Experience Design
Motion & Animation
- Consider transitions between screens and states
- Animation purpose: Enhance usability, not distract
- Consistent motion patterns: Similar elements should move similarly
Implementation
- Test experiences across the entire flow
- Design with animation in mind from the beginning
- Balance speed and smoothness for optimal user experience
Resources
Code Review Checklist
Core Design Principles
Technical Implementation
Common Issues to Flag