Build with AI
Chapter 2

CSS & UI Frameworks

Why Tailwind CSS v4 + daisyUI 5 is the optimal stack for AI-generated frontend code.

Why Frameworks Matter for AI

AI agents generate HTML and CSS by predicting the most likely tokens given a prompt. The framework you choose directly impacts how correct the output will be. Two principles guide the choice:

  • Training data density: How many high-quality examples of this framework exist in the training corpus?
  • Composability: How easy is it for the agent to compose correct output from smaller, well-known pieces?

Tailwind CSS excels on both dimensions. It’s the most widely used utility-first CSS framework, with extensive documentation, examples, and community patterns in LLM training data. Every class name is atomic and predictable — the agent doesn’t need to invent class names or manage cascade conflicts.

Tailwind CSS v4

Tailwind CSS is a utility-first CSS framework. Instead of writing custom CSS, you compose designs using predefined utility classes directly in your HTML.

Version 4 (released 2025) brings significant improvements relevant to AI-generated code:

v4 FeatureAI Benefit
CSS-first configurationNo tailwind.config.js needed — fewer files for the agent to manage
Automatic content detectionAgent doesn’t need to configure content paths
CSS variables for themingAgents can set theme values without understanding JS config syntax
Zero-config dark modeDark mode works out of the box with prefers-color-scheme
Simplified @importSingle line to include: @import "tailwindcss";

daisyUI 5: Semantic Components for Tailwind

daisyUI adds semantic component classes and themeable color names on top of Tailwind CSS. It provides 50+ components (buttons, cards, modals, drawers, timelines, and more) with consistent, accessible defaults.

Why daisyUI for AI-Generated Code

  • Semantic color system: Agents use bg-primary, text-base-content instead of bg-blue-600. Themes auto-adapt.
  • Component classes: Instead of assembling 7 Tailwind classes for a button, use btn btn-primary. Less room for agent error.
  • Built-in themes: 30+ pre-built themes — agents can switch themes without rewriting CSS.
  • Reduced class count: Fewer tokens needed per element = faster generation, lower cost, fewer errors.

Component Comparison: Raw vs daisyUI

Here’s a real example. Same result, different approaches:

Raw Tailwind
<button class="px-4 py-2 bg-blue-600
text-white rounded-lg font-medium
hover:bg-blue-700 focus:outline-none
focus:ring-2 focus:ring-blue-500
focus:ring-offset-2 transition-colors
disabled:opacity-50 disabled:cursor-not-allowed">
  Save Changes
</button>
daisyUI
<button class="btn btn-primary">
  Save Changes
</button>

The PageWeave Stack

PageWeave uses Tailwind CSS v4 + daisyUI 5 as its built-in frontend stack. Every PageWeave site gets both automatically. This means:

  • No build step, no npm install, no configuration
  • daisyUI 5 semantic colors (primary, base-100, secondary) available everywhere
  • AI agents output daisyUI classes directly in page HTML
  • Themes apply automatically across all components

Tool Comparison

Tailwind v4Bootstrap 5Plain CSS
AI Training DataExcellentGoodChaotic
Token EfficiencyHighMediumLow
Error SurfaceSmallMediumLarge
Theme SupportdaisyUI 30+Sass varsManual
Component LibrarydaisyUI 50+~20None
Build StepVite/CLISass compileNone
Next

Built with AI, powered by PageWeave. © 2026