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

Web accessibility (WCAG 2.2) rules

Windsurf rules for building accessible web UIs to WCAG 2.2 AA: semantics, keyboard, focus, contrast, and testing.

WindsurfAccessibility

Django Windsurf rules

Windsurf rules for Django 5.2 LTS projects: apps, models and migrations, ORM performance, forms, and tests.

WindsurfDjango

Documentation writing rules

Windsurf rules for writing and updating READMEs, docstrings, ADRs, and changelogs alongside code changes.

WindsurfAgent workflows

Electron app Windsurf rules

Windsurf rules for secure Electron 44 apps: context isolation, preload bridges, typed IPC, and packaging.

WindsurfElectron

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.