⚛️

GitHub Copilot Rules for React + Tailwind CSS

React with Tailwind CSS utility classes and hooks

ReactTailwindHooksVite
.github/copilot-instructions.md
# GitHub Copilot Instructions

## Context
You are an expert React developer using Tailwind CSS for styling and modern React patterns.

## Tech Stack
- React 19
- Tailwind CSS v4
- TypeScript
- Vite

## Conventions to Follow
- Use functional components with hooks exclusively.
- Use Tailwind CSS utility classes for all styling. Avoid custom CSS unless absolutely necessary.
- Keep components small, focused, and reusable.
- Use TypeScript interfaces for all props.
- Use `useState`, `useReducer` for local state, and context for shared state.
- Use `React.memo()` for expensive pure components.
- Extract reusable logic into custom hooks prefixed with `use`.
- Use `clsx` or `cn` utility for conditional class names.
- File naming: PascalCase for components, camelCase for utilities.

## Code Style
- Use TypeScript strict mode. Define types for all variables, parameters, and return values.
- Never use the `any` type. Use `unknown` if the type is truly uncertain, then narrow it.
- Use `const` by default. Only use `let` when reassignment is needed. Never use `var`.
- Always handle errors explicitly. Use try/catch for async operations. Never silently swallow errors.
- Use early returns (guard clauses) to reduce nesting and improve readability.
- Use descriptive, meaningful names for variables, functions, and classes. Avoid abbreviations.
- Keep functions small and focused. Each function should do one thing. Aim for under 50 lines.

## Do Not
- Do not use class components.
- Do not use inline styles.
- Do not use CSS-in-JS libraries (styled-components, emotion).
- Do not mutate state directly.
- Do not use `any` type.

About GitHub Copilot Rules for React + Tailwind CSS

The .github/copilot-instructions.md file helps GitHub Copilot understand your React + Tailwind CSS project's conventions, tech stack, and coding standards. This ensures the AI generates code that matches your team's style and follows best practices for React.

This preset includes rules for:

  • Use functional components with hooks exclusively.
  • Use Tailwind CSS utility classes for all styling. Avoid custom CSS unless absolutely necessary.
  • Keep components small, focused, and reusable.
  • Use TypeScript interfaces for all props.
  • Use `useState`, `useReducer` for local state, and context for shared state.

How to use this file

  1. Click Copy or Download above.
  2. Place the .github/copilot-instructions.md file in your project's root directory.
  3. GitHub Copilot will automatically detect and apply these rules.

Get React + Tailwind CSS Rules for Other IDEs

Other GitHub Copilot Presets