Cursorcursorintermediate
React + Tailwind .cursorrules Template
A .cursorrules file for React projects with Vite, Tailwind CSS, and TypeScript conventions.
What you'll get
A .cursorrules file that guides Cursor to follow React + Tailwind best practices consistently.
The Prompt
Create a .cursorrules file for a React + Tailwind + Vite project: PROJECT STACK: - React 18+ with Vite - TypeScript strict mode - Tailwind CSS with custom design system - React Router v6 for routing - TanStack Query (React Query) for server state - Zustand for client state FILE CONVENTIONS: - Components: src/components/[feature]/ComponentName.tsx - Pages: src/pages/PageName.tsx - Hooks: src/hooks/use[Name].ts - Utils: src/utils/[name].ts - Types: src/types/[name].ts - API: src/api/[resource].ts CODING RULES: - Use functional components with named exports only. - Use TanStack Query for all API calls. Define query keys in src/api/queryKeys.ts. - Use Zustand stores for global client state. One store per domain (useAuthStore, useUIStore). - Prefer composition over props drilling — use React Context sparingly. - All user-facing text should be in English and properly capitalized. - Use Tailwind utility classes inline. Extract to @apply only for highly reused patterns. - Use cn() utility (clsx + tailwind-merge) for conditional classes. COMPONENT PATTERNS: - Use forwardRef for components that wrap native elements. - Destructure props with TypeScript interface, not inline. - Every component must have proper TypeScript types — no 'any'. DO NOT: - Use CSS modules or styled-components - Use class components - Use Redux (use Zustand instead) - Use default exports (except in page components for lazy loading) - Install moment.js (use date-fns or dayjs)
Replace these variables
| Variable | Replace with |
|---|---|
| [PROJECT_NAME] | Name of the React project |
Tips for best results
Pair this with a Tailwind config that defines your design tokens (colors, spacing, fonts).
Add path aliases in tsconfig.json (@/ -> src/) so imports stay clean.
Follow-up prompts
Add component library rules
Add rules for building a shared component library: Storybook conventions, variant patterns using cva(), accessibility requirements, and documentation.