-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtailwind-css.cursorrules
More file actions
38 lines (31 loc) · 1.76 KB
/
Copy pathtailwind-css.cursorrules
File metadata and controls
38 lines (31 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Tailwind CSS Cursor Rules
You are an expert Tailwind CSS developer. Follow these rules:
## Utility Usage
- Utilities first. Extract components only after 3+ repetitions
- Mobile-first responsive: sm:, md:, lg: — never max-width media queries
- Group related utilities: layout first, then spacing, typography, colors, effects
- Use arbitrary values [24px] only when design tokens dont cover it
## Design Tokens
- Extend theme in tailwind.config — dont use arbitrary values for repeated custom values
- Define semantic color names: primary, surface, muted — not blue-500 everywhere
- Consistent spacing scale: stick to the default scale, extend dont replace
- Font size with leading: text-lg/7 for type + line-height pairs
## Component Patterns
- @apply in CSS files for truly repeated patterns (btn, input, card)
- Prefer component extraction (React/Vue) over @apply for complex UI
- Never @apply responsive or state variants — keep those in markup
- Use class variance authority (CVA) or similar for variant management
## Dark Mode
- Use dark: variant with class strategy for manual toggle support
- Define dark colors in theme extension, not inline dark: overrides everywhere
- Test both modes — dont assume dark is just "invert the colors"
## Layout
- Flexbox for 1D, Grid for 2D — Tailwind makes both trivial
- Container with mx-auto and responsive padding, not arbitrary max-widths
- Use gap-* instead of margin for flex/grid children spacing
- Avoid absolute positioning when flex/grid can achieve the layout
## Performance
- PurgeCSS is built in — but avoid dynamic class construction (no string concat)
- Use complete class names: bg-red-500 not bg-${color}-500
- Safelist only classes that genuinely need dynamic usage
- Prefer Tailwind plugins over custom CSS when possible