Styles
Styling with Tailwind CSS
This project uses Tailwind CSS for all styling with a design system based on semantic color tokens and consistent spacing.
Overview
All styling follows these principles:
- Use Tailwind utility classes for all styling
- Never use arbitrary values (avoid
w-[123px]) - Use semantic color tokens (
primary,secondary,muted, etc.) - Use design system components (H1-H6, P-P4, Section)
Quick Links
Typography
H1-H6 and P-P4 components for consistent text styling
Tailwind CSS
Tailwind configuration, tokens, and utilities
Theming
Light/dark mode and theme customization
Color System
Colors are defined in two places:
src/config/colors.ts- Color palette definitionstailwind.config.ts- Tailwind theme configuration
Semantic Colors
Use semantic color classes instead of specific colors:
// ✅ Good - semantic colors
<div className="bg-primary text-primary-foreground">
<p className="text-muted-foreground">
// ❌ Bad - arbitrary colors
<div className="bg-blue-500 text-white">
<p className="text-gray-600">Available Tokens
| Token | Purpose |
|---|---|
background | Page background |
foreground | Primary text |
primary | Primary actions |
secondary | Secondary actions |
muted | Muted backgrounds |
muted-foreground | Muted text (60% opacity) |
accent | Accent highlights |
destructive | Destructive actions/errors |
border | Border colors |
ring | Focus rings |
Spacing Scale
Use the Tailwind spacing scale for consistent layout:
<div className="p-4 gap-2"> {/* 16px padding, 8px gap */}
<div className="mt-8 mb-4"> {/* 32px top, 16px bottom */}
<div className="space-y-6"> {/* 24px vertical spacing */}| Class | Size |
|---|---|
*-1 | 4px |
*-2 | 8px |
*-4 | 16px |
*-6 | 24px |
*-8 | 32px |
*-12 | 48px |
*-16 | 64px |
Layout Components
Section Component
Use Section for consistent page layouts:
import { Section } from "@/components/section";
<Section variant="centered" padding="xl">
<H1>Page Title</H1>
<P>Content here</P>
</Section>Section Variants
| Variant | Description |
|---|---|
default | Standard section |
centered | Centered content with max-width |
breakout | Wider content area |
bg-color | Full-width with accent background |
full-width | Full-width without padding |
call-to-action | Styled CTA block |
main-content | Main page wrapper |
Utility Functions
cn() Helper
Use the cn() helper for conditional classes:
import { cn } from "@/lib/utils";
<div className={cn(
"base-class",
isActive && "active-class",
variant === "primary" && "primary-class"
)} />This combines classes and handles conflicts intelligently using tailwind-merge.
Responsive Design
Tailwind provides responsive prefixes:
<div className="w-full md:w-1/2 lg:w-1/3">
{/* Full width on mobile, half on tablet, third on desktop */}
</div>
<p className="text-sm md:text-base lg:text-lg">
{/* Responsive text sizes */}
</p>| Prefix | Breakpoint |
|---|---|
sm: | 640px |
md: | 768px |
lg: | 1024px |
xl: | 1280px |
2xl: | 1536px |
Best Practices
- Use semantic colors - Always use color tokens like
primaryinstead of specific colors - Follow spacing scale - Use the Tailwind spacing scale for consistency
- No arbitrary values - Avoid
w-[123px]- use design tokens instead - Use typography components - Use H1-H6 and P-P4 instead of raw HTML elements
Never Use Arbitrary Values
Avoid arbitrary Tailwind values like w-[100px] or text-[#ff0000]. Use design tokens and semantic classes for consistency.