tailwindcss
Cursor rule2.1k starsChanged 10 months agoMITView on GitHub
Best practices for using Tailwind CSS
12 other projects use a version of this.
Trending
Quiet since September.thin dataabout the whole repository
Most recently taken up by
- compozy/compozytheir own version, first seen Oct 1, 2026
- SkotAlexsander/skillstheir own version, first seen Sep 16, 2026
- Rikinshah787/agent-skills-production-skillstheir own version, first seen Aug 10, 2026
- weiweimhy/agent-skillstheir own version, first seen Jul 1, 2026
- joabgonzalez/ai-agents-skillstheir own version, first seen Jun 8, 2026
- FelipeAngeli/skillstheir own version, first seen Apr 10, 2026
Who's talking about agentset-ai/agentset
- A Hacker News story“Show HN: Agentset – Open-source RAG with vector DB, embeddings, and API built-in”Hacker News · Oct 17, 2025 · 6 points
- A Hacker News story“Show HN: Agentset – An open-source RAG platform for AI apps”Hacker News · May 15, 2025 · 4 points
- colinhacks/zod“Unhandled `undefined` in `to-json-schema`'s `flattenRef` method”GitHub · Jan 14, 2026 · 2 reactions
- agentset-ai/partition-api-v2“Add EU region support”GitHub · Sep 27, 2026
- sudosubin/agents.nix“agent-skills.github.agentset-ai.agentset: init at 0-unstable-2026-01-26”GitHub · Sep 25, 2026
The biggest 5 of 8 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 8
Talked about on GitHub and Hacker News (8 times).
On GitHub · 6
- Jan 14, 2026Unhandled `undefined` in `to-json-schema`'s `flattenRef` method — colinhacks/zod2 reactions · 2 comments
- Sep 27, 2026Add EU region support — agentset-ai/partition-api-v20 reactions
- Sep 25, 2026agent-skills.github.agentset-ai.agentset: init at 0-unstable-2026-01-26 — sudosubin/agents.nix0 reactions
- Aug 1, 2026docs: add Agentset to LLM knowledge tools — xlabs-club/awesome-x-ops0 reactions
- Jan 31, 2026Add Agentset to Frameworks section — Yigtwxx/awesome-rag-production0 reactions
1 more on GitHub
- Oct 26, 2025Add missing email validation — better-auth/better-auth0 reactions · 5 comments
On Hacker News · 2
- Oct 17, 2025Show HN: Agentset – Open-source RAG with vector DB, embeddings, and API built-in6 points
- May 15, 2025Show HN: Agentset – An open-source RAG platform for AI apps4 points
Used with
Projects with it also use app-renderer-systems, refactoring-analysis and 7 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
pedronauckSkillapp-renderer-systems
Create, extend, or debug frontend domain modules organized under systems/. Covers adapters, Query hooks, local state, and public exports; excludes generic components and backend implementation.
Also in 3 projects that use this
pedronauckSkillrefactoring-analysis
Audit code quality and architectural health or plan refactoring using Fowler code smells and techniques; write prioritized findings to docs/_refacs/. Excludes formatting, performance, and security audits.
Also in 3 projects that use this
barisariburnuSkilltanstack
Expert assistance for TanStack Router, Query (v5), and Table (v8). Use when users need help with file-based routing, type-safe navigation, data loading, search params, queries, mutations, optimistic updates, infinite queries, table state management, or debugging TanStack libraries.
Also in 3 projects that use this
rohitg00Skilltypescript-advanced
Advanced TypeScript patterns including generics, conditional types, mapped types, template literals, and type guards
Also in 3 projects that use this
rogue-dev-studioSkillnodejs
Node.js development environment. Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `nodejs` work when listed in TEAM.yaml or explicitly requested.
Also in 3 projects that use this
VercelSkillreact
React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.
Also in 6 projects that use this
- +1 more from pedronauck
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- compozy/compozy★ 2.8ksame name
- pedronauck/skills★ 633same name
- Mindrally/skills★ 266same name
- martinholovsky/claude-skills-generator★ 47same name
- joabgonzalez/ai-agents-skills★ 9same name
- akornmeier/claude-config★ 4same name
- FelipeAngeli/skills★ 2same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- Rikinshah787/agent-skills-production-skills★ 2same name
- michelve/hugin-cowork★ 1same name
2 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository13 other files it gives its agents.
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- docs/CLAUDE.mdCLAUDE.md
- animationsCursor rule
- .cursor/rules/clean-code.mdcCursor rule
- .cursor/rules/nextjs.mdcCursor rule
- .cursor/rules/project-structure.mdcCursor rule
- .cursor/rules/shadcn.mdcCursor rule
- baseline-uiSkill
- fixing-accessibilitySkill
- fixing-metadataSkill
- react-emailSkill
- trigger-dev-tasksSkill
- vercel-react-best-practicesSkill
The file
Show its rules and text
We split this tailwind.mdc into the rules it gives an agent
35 rules. 0 are common, 23 are distinctive, and 12 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
23
Distinctive
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Always use Tailwind CSS v4.1+: - Ensure the codebase is using the latest version
- Distinctive: line 12
Do not use deprecated or removed utilities: - ALWAYS use the replacement
- Very specific: line 13
Never use
@apply: - Use CSS variables, the --spacing() function, or framework components instead - Distinctive: line 14
Check for redundant classes: - Remove any classes that aren't necessary
- Distinctive: line 21
Always read the upgrade documentation first: - Read https://tailwindcss.com/docs/upgrade-guide and …
- Distinctive: line 22
Ensure the git repository is in a clean state before starting
- Very specific: line 26
Run the upgrade command: npx @tailwindcss/upgrade@latest for both major and minor updates
- Distinctive: line 29
Test thoroughly across your application
- Distinctive: line 113
Use padding on parent containers: instead of bottom margins on the last child
- Distinctive: line 123
Always use fixed line heights from the spacing scale: - Don't use named values
- Very specific: line 182
Use the plain dark: variant pattern
- Distinctive: line 183
Put light mode styles first, then dark mode styles
- Very specific: line 184
Ensure dark: variant comes before other variants
- Very specific: line 196
Use the new bg-radial or bg-radial-[<position>] to create radial gradients
- Very specific: line 197
Use the new bg-conic or bg-conic-* to create conic gradients
- Very specific: line 229
Use the dedicated --spacing() function for spacing calculations:
- Distinctive: line 239
Use CSS to extend theme values:
- Very specific: line 259
Use the @container class and size variants:
- Very specific: line 274
Use container-based units like cqw for responsive sizing:
- Distinctive: line 284
Use text-shadow-\* utilities from text-shadow-2xs to text-shadow-lg:
- Distinctive: line 294
Use the new composable mask utilities for image and gradient masks:
- Distinctive: line 314
Don't add utilities to parents that you override in children:
- Distinctive: line 333
Keep utility classes in templates/JSX
- Distinctive: line 334
Use data attributes for complex state-based styling
- Distinctive: line 340
Use nesting when styling both parent and children
- Distinctive: line 341
Avoid empty parent selectors
- Very specific: line 363
Using old opacity utilities: - Always use /opacity syntax like bg-red-500/60
- Distinctive: line 364
Redundant breakpoint classes: - Only specify changes
- Distinctive: line 365
Space utilities in flex/grid: - Always use gap
- Very specific: line 366
Leading utilities: - Use line-height modifiers like text-sm/6
- Distinctive: line 367
Arbitrary values: - Use the design scale
- Distinctive: line 368
@apply directive: - Use components or CSS variables
- Distinctive: line 369
min-h-screen on mobile: - Use min-h-dvh
- Distinctive: line 370
Separate width/height: - Use size utilities when equal
- Very specific: line 371
Arbitrary values: - Always use Tailwind's predefined scale whenever possible (e.g., use ml-4 over ml-[16px])
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
name: tailwindcss
description: Best practices for using Tailwind CSS
alwaysApply: true
---
# Tailwind CSS Rules and Best Practices
## Core Principles
- **Always use Tailwind CSS v4.1+** - Ensure the codebase is using the latest version
- **Do not use deprecated or removed utilities** - ALWAYS use the replacement
- **Never use `@apply`** - Use CSS variables, the `--spacing()` function, or framework components instead
- **Check for redundant classes** - Remove any classes that aren't necessary
- **Group elements logically** to simplify responsive tweaks later
## Upgrading to Tailwind CSS v4
### Before Upgrading
- **Always read the upgrade documentation first** - Read https://tailwindcss.com/docs/upgrade-guide and https://tailwindcss.com/blog/tailwindcss-v4 before starting an upgrade.
- Ensure the git repository is in a clean state before starting
### Upgrade Process
1. Run the upgrade command: `npx @tailwindcss/upgrade@latest` for both major and minor updates
2. The tool will convert JavaScript config files to the new CSS format
3. Review all changes extensively to clean up any false positives
4. Test thoroughly across your application
## Breaking Changes Reference
### Removed Utilities (NEVER use these in v4)
| ❌ Deprecated | ✅ Replacement |
| ----------------------- | ------------------------------------------------- |
| `bg-opacity-*` | Use opacity modifiers like `bg-black/50` |
| `text-opacity-*` | Use opacity modifiers like `text-black/50` |
| `border-opacity-*` | Use opacity modifiers like `border-black/50` |
| `divide-opacity-*` | Use opacity modifiers like `divide-black/50` |
| `ring-opacity-*` | Use opacity modifiers like `ring-black/50` |
| `placeholder-opacity-*` | Use opacity modifiers like `placeholder-black/50` |
| `flex-shrink-*` | `shrink-*` |
| `flex-grow-*` | `grow-*` |
| `overflow-ellipsis` | `text-ellipsis` |
| `decoration-slice` | `box-decoration-slice` |
| `decoration-clone` | `box-decoration-clone` |
### Renamed Utilities (ALWAYS use the v4 name)
| ❌ v3 | ✅ v4 |
| ------------------ | ------------------ |
| `bg-gradient-*` | `bg-linear-*` |
| `shadow-sm` | `shadow-xs` |
| `shadow` | `shadow-sm` |
| `drop-shadow-sm` | `drop-shadow-xs` |
| `drop-shadow` | `drop-shadow-sm` |
| `blur-sm` | `blur-xs` |
| `blur` | `blur-sm` |
| `backdrop-blur-sm` | `backdrop-blur-xs` |
| `backdrop-blur` | `backdrop-blur-sm` |
| `rounded-sm` | `rounded-xs` |
| `rounded` | `rounded-sm` |
| `outline-none` | `outline-hidden` |
| `ring` | `ring-3` |
## Layout and Spacing Rules
### Flexbox and Grid Spacing
#### Always use gap utilities for internal spacing
Gap provides consistent spacing without edge cases (no extra space on last items). It's cleaner and more maintainable than margins on children.
```html
<!-- ❌ Don't do this -->
<div class="flex">
<div class="mr-4">Item 1</div>
<div class="mr-4">Item 2</div>
<div>Item 3</div>
<!-- No margin on last -->
</div>
<!-- ✅ Do this instead -->
<div class="flex gap-4">
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</div>
```
#### Gap vs Space utilities
- **Never use `space-x-*` or `space-y-*` in flex/grid layouts** - always use gap
- Space utilities add margins to children and have issues with wrapped items
- Gap works correctly with flex-wrap and all flex directions
```html
<!-- ❌ Avoid space utilities in flex containers -->
<div class="flex flex-wrap space-x-4">
<!-- Space utilities break with wrapped items -->
</div>
<!-- ✅ Use gap for consistent spacing -->
<div class="flex flex-wrap gap-4">
<!-- Gap works perfectly with wrapping -->
</div>
```
### General Spacing Guidelines
- **Prefer top and left margins** over bottom and right margins (unless conditionally rendered)
- **Use padding on parent containers** instead of bottom margins on the last child
- **Always use `min-h-dvh` instead of `min-h-screen`** - `min-h-screen` is buggy on mobile Safari
- **Prefer `size-*` utilities** over separate `w-*` and `h-*` when setting equal dimensions
- For max-widths, prefer the container scale (e.g., `max-w-2xs` over `max-w-72`)
## Typography Rules
### Line Heights
- **Never use `leading-*` classes** - Always use line height modifiers with text size
- **Always use fixed line heights from the spacing scale** - Don't use named values
```html
<!-- ❌ Don't do this -->
<p class="text-base leading-7">Text with separate line height</p>
<p class="text-lg leading-relaxed">Text with named line height</p>
<!-- ✅ Do this instead -->
<p class="text-base/7">Text with line height modifier</p>
<p class="text-lg/8">Text with specific line height</p>
```
### Font Size Reference
Be precise with font sizes - know the actual pixel values:
- `text-xs` = 12px
- `text-sm` = 14px
- `text-base` = 16px
- `text-lg` = 18px
- `text-xl` = 20px
## Color and Opacity
### Opacity Modifiers
**Never use `bg-opacity-*`, `text-opacity-*`, etc.** - use the opacity modifier syntax:
```html
<!-- ❌ Don't do this -->
<div class="bg-opacity-60 bg-red-500">Old opacity syntax</div>
<!-- ✅ Do this instead -->
<div class="bg-red-500/60">Modern opacity syntax</div>
```
## Responsive Design
### Breakpoint Optimization
- **Check for redundant classes across breakpoints**
- **Only add breakpoint variants when values change**
```html
<!-- ❌ Redundant breakpoint classes -->
<div class="px-4 md:px-4 lg:px-4">
<!-- md:px-4 and lg:px-4 are redundant -->
</div>
<!-- ✅ Efficient breakpoint usage -->
<div class="px-4 lg:px-8">
<!-- Only specify when value changes -->
</div>
```
## Dark Mode
### Dark Mode Best Practices
- Use the plain `dark:` variant pattern
- Put light mode styles first, then dark mode styles
- Ensure `dark:` variant comes before other variants
```html
<!-- ✅ Correct dark mode pattern -->
<div class="bg-white text-black dark:bg-black dark:text-white">
<button class="hover:bg-gray-100 dark:hover:bg-gray-800">Click me</button>
</div>
```
## Gradient Utilities
- **ALWAYS Use `bg-linear-*` instead of `bg-gradient-*` utilities** - The gradient utilities were renamed in v4
- Use the new `bg-radial` or `bg-radial-[<position>]` to create radial gradients
- Use the new `bg-conic` or `bg-conic-*` to create conic gradients
```html
<!-- ✅ Use the new gradient utilities -->
<div class="h-14 bg-linear-to-br from-violet-500 to-fuchsia-500"></div>
<div
class="size-18 bg-radial-[at_50%_75%] from-sky-200 via-blue-400 to-indigo-900 to-90%"
></div>
<div
class="size-24 bg-conic-180 from-indigo-600 via-indigo-50 to-indigo-600"
></div>
<!-- ❌ Do not use bg-gradient-* utilities -->
<div class="h-14 bg-gradient-to-br from-violet-500 to-fuchsia-500"></div>
```
## Working with CSS Variables
### Accessing Theme Values
Tailwind CSS v4 exposes all theme values as CSS variables:
```css
/* Access colors, and other theme values */
.custom-element {
background: var(--color-red-500);
border-radius: var(--radius-lg);
}
```
### The `--spacing()` Function
Use the dedicated `--spacing()` function for spacing calculations:
```css
.custom-class {
margin-top: calc(100vh - --spacing(16));
}
```
### Extending theme values
Use CSS to extend theme values:
```css
@import "tailwindcss";
@theme {
--color-mint-500: oklch(0.72 0.11 178);
}
```
```html
<div class="bg-mint-500">
<!-- ... -->
</div>
```
## New v4 Features
### Container Queries
Use the `@container` class and size variants:
```html
<article class="@container">
<div class="flex flex-col @md:flex-row @lg:gap-8">
<img class="w-full @md:w-48" />
<div class="mt-4 @md:mt-0">
<!-- Content adapts to container size -->
</div>
</div>
</article>
```
### Container Query Units
Use container-based units like `cqw` for responsive sizing:
```html
<div class="@container">
<h1 class="text-[50cqw]">Responsive to container width</h1>
</div>
```
### Text Shadows (v4.1)
Use text-shadow-\* utilities from text-shadow-2xs to text-shadow-lg:
```html
<!-- ✅ Text shadow examples -->
<h1 class="text-shadow-lg">Large shadow</h1>
<p class="text-shadow-sm/50">Small shadow with opacity</p>
```
### Masking (v4.1)
Use the new composable mask utilities for image and gradient masks:
```html
<!-- ✅ Linear gradient masks on specific sides -->
<div class="mask-t-from-50%">Top fade</div>
<div class="mask-b-from-20% mask-b-to-80%">Bottom gradient</div>
<div class="mask-linear-from-white mask-linear-to-black/60">
Fade from white to black
</div>
<!-- ✅ Radial gradient masks -->
<div class="mask-radial-[100%_100%] mask-radial-from-75% mask-radial-at-left">
Radial mask
</div>
```
## Component Patterns
### Avoiding Utility Inheritance
Don't add utilities to parents that you override in children:
```html
<!-- ❌ Avoid this pattern -->
<div class="text-center">
<h1>Centered Heading</h1>
<div class="text-left">Left-aligned content</div>
</div>
<!-- ✅ Better approach -->
<div>
<h1 class="text-center">Centered Heading</h1>
<div>Left-aligned content</div>
</div>
```
### Component Extraction
- Extract repeated patterns into framework components, not CSS classes
- Keep utility classes in templates/JSX
- Use data attributes for complex state-based styling
## CSS Best Practices
### Nesting Guidelines
- Use nesting when styling both parent and children
- Avoid empty parent selectors
```css
/* ✅ Good nesting - parent has styles */
.card {
padding: --spacing(4);
> .card-title {
font-weight: bold;
}
}
/* ❌ Avoid empty parents */
ul {
> li {
/* Parent has no styles */
}
}
```
## Common Pitfalls to Avoid
1. **Using old opacity utilities** - Always use `/opacity` syntax like `bg-red-500/60`
2. **Redundant breakpoint classes** - Only specify changes
3. **Space utilities in flex/grid** - Always use gap
4. **Leading utilities** - Use line-height modifiers like `text-sm/6`
5. **Arbitrary values** - Use the design scale
6. **@apply directive** - Use components or CSS variables
7. **min-h-screen on mobile** - Use min-h-dvh
8. **Separate width/height** - Use size utilities when equal
9. **Arbitrary values** - Always use Tailwind's predefined scale whenever possible (e.g., use `ml-4` over `ml-[16px]`)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

