3 tailwind rules available
Cursor has three Tailwind rules: a long best-practices rule covering responsive design and dark mode, and short rules on class organization and responsive layout. The file is attached to stylesheets and markup files so it applies wherever classes are written.
Cursor applies project rules stored as .mdc files in .cursor/rules. Each rule's frontmatter (description, globs, alwaysApply) decides whether it is always included, attached to matching files, chosen by the agent from its description, or only used when you @-mention it. Cursor also reads AGENTS.md in the project root and subdirectories for plain-Markdown instructions.
.cursor/rules/tailwind.mdcStarting point, not a tested configuration for your repository. Attached when files matching the globs are in context (alwaysApply: false with globs). Review the instructions, adapt the file paths and run your project's existing checks.
---
description: "Tailwind CSS development project conventions"
globs: "**/*.css,**/*.html,**/*.tsx,**/*.jsx,**/*.vue,**/*.svelte"
alwaysApply: false
---
# Tailwind CSS instructions for Cursor
## Focus for this project
- Check how dark mode is configured (media preference by default, or a class/selector strategy) before adding dark: variants.
- Extract repeated long class lists into a component, not into @apply rules, unless the project already does that.
- Keep class order consistent with prettier-plugin-tailwindcss if it is installed.
## Tailwind CSS conventions
- Identify the Tailwind version first. v4 projects import Tailwind with @import "tailwindcss"; and define design tokens with @theme in CSS; v3 projects use tailwind.config.js. Edit the one the project actually uses.
- Write complete class names in source. Tailwind detects classes as plain text, so interpolated names such as bg-${color}-500 are not generated; map values to full class strings instead.
- Use theme tokens instead of arbitrary values like text-[#3b82f6] unless the value is genuinely one-off.
- Style mobile first and add sm:/md:/lg: variants for larger screens; keep focus-visible styles on interactive elements.
## Before you finish
- Run the CSS build or dev server, a visual check of the changed component at a mobile and a desktop width, and the lint script and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass.
- Summarize which of the rules above affected the change.
- If another attached Cursor rule conflicts with this one, name both rules and follow the one with the narrower globs.
Create your own Cursor rules for Tailwind CSS and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Cursor's docs recommend keeping individual rules under 500 lines and splitting large rules into composable ones. Cursor's documentation states that it supports AGENTS.md in the project root and in subdirectories. Use AGENTS.md for plain-Markdown instructions you also want other tools to read, and .mdc rules when you need Cursor's scoping options (globs, description-based selection, always-apply).
Documentation checked 2026-11-05: Cursor docs: Rules
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You ask Cursor's agent to add dark mode to existing components and want it to follow the project's configured dark-mode strategy.
Add dark mode styles to the Card and Navbar components.
dark: variants on background, text and border classes consistent with the configured strategy, no interpolated class names, and a visual check in both modes.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.
Organize Tailwind CSS in large projects