Home › Tailwind CSS › Tailwind CSS v4 rules

Tailwind CSS v4 rules

Windsurf rules for clean, consistent, accessible Tailwind CSS v4 styling.

WindsurfTailwind CSS

How to use

Save this as .windsurf/rules/tailwind.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

.windsurf/rules/tailwind.mdDownload  
# Windsurf rules — Tailwind CSS v4

- Tailwind v4: configure design tokens in CSS with `@theme` in the main stylesheet; there is no `tailwind.config.js` unless the project already has one.
- Use theme tokens (`bg-primary`, `text-muted-foreground`, spacing scale) instead of arbitrary values like `w-[437px]` or hex colors.
- Mobile-first: base classes for small screens, then `sm:`/`md:`/`lg:` overrides.
- Merge conditional classes with `cn()` (clsx + tailwind-merge); never build class names by string concatenation (the compiler can't see them).
- Repeated class lists → extract a component, not `@apply`. Use `@apply` only for third-party markup you can't control.
- Dark mode with `dark:` variants on every color utility you add.
- Accessibility: visible `focus-visible:` styles, sufficient contrast, `sr-only` labels for icon buttons.
- Keep class order consistent (use prettier-plugin-tailwindcss).

Related rules

Phaser 3 browser game rules

Windsurf rules for 2D browser games with Phaser 3, TypeScript and Vite.

WindsurfPhaser (web games)

Next.js Windsurf rules

Windsurf (Cascade) workspace rules for Next.js + shadcn/ui projects.

WindsurfNext.js

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.