Home › React › Material UI (MUI) React Copilot path instructions

Material UI (MUI) React Copilot path instructions

Copilot instructions for React apps using Material UI: theme-first styling, sx vs styled, responsive Grid, accessible components, forms, and bundle-friendly imports.

GitHub CopilotReact

How to use

Save this as .github/instructions/mui.instructions.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

.github/instructions/mui.instructions.mdDownload  
---
applyTo: "src/**/*.tsx,src/**/*.ts"
description: Material UI conventions
---

# Material UI (MUI)

- Check the installed `@mui/material` major in `package.json` and follow that version's API (for example, the Grid API changed across majors). Don't mix in examples from other versions.
- Theme first: colors, typography, spacing, shape and component defaults live in `src/theme.ts` via `createTheme`, provided once with `ThemeProvider` and `CssBaseline` at the root. No hex colors or pixel font sizes in components; use `theme.palette.*`, `theme.typography.*`, `theme.spacing()`.
- Component-wide overrides go in `theme.components.<MuiX>.defaultProps/styleOverrides`, not repeated `sx` on every instance.
- Styling: `sx` for one-off layout tweaks; `styled()` for reusable styled components. Don't mix in another CSS-in-JS library or inline `style` objects.
- Layout with `Stack`, `Box` and `Grid` using responsive values (`{ xs: 12, md: 6 }`). Use breakpoints from the theme, not hardcoded media queries.
- Import from the package root or path imports consistently with the repo; icons from `@mui/icons-material/IconName` path imports to keep dev builds fast.
- Dark mode via the theme's color schemes or palette mode; test both if the app supports them.
- Accessibility: every `IconButton` has an `aria-label`; form fields use `TextField` `label` (not placeholder-only) and `helperText` for errors; `Dialog` has `aria-labelledby`; don't remove focus outlines.
- Forms: connect inputs to the repo's form library (React Hook Form `Controller` or equivalent) and validation schema; show errors with `error` + `helperText`.
- Data grids and date pickers come from `@mui/x-*` packages; check the license tier before using Pro/Premium-only features.
- Keep components small: page components compose feature components; no 300-line JSX trees.
- Tests with Testing Library query by role and label (`getByRole('button', { name: /save/i })`), not by MUI class names.

More: all React rules · all GitHub Copilot rules

Related rules

React + TypeScript Copilot path instructions

Path-specific Copilot instructions for React 19 + TypeScript .tsx files: components, hooks, accessibility, and tests.

GitHub CopilotReact

React 19 + Vite SPA rules

Cursor rules for React 19 single-page apps on Vite 6+ with TypeScript, hooks, and Vitest.

CursorReact

Redux Toolkit + RTK Query Copilot path instructions

Path-specific Copilot instructions for Redux Toolkit: createSlice, typed hooks, RTK Query endpoints with tags, and no legacy Redux patterns.

GitHub CopilotReact

TanStack Query v5 rules

Cursor rules for TanStack Query v5 in React: query keys, queryOptions, mutations, and cache invalidation.

CursorReact

Zustand state management Cursor rules

Cursor rules for React state with Zustand: small typed stores, selectors, actions in the store, persist and devtools middleware, and testing.

CursorReact

Angular 20 Copilot instructions

Copilot instructions for Angular 20 apps using standalone components, signals, and the new control flow.

GitHub CopilotAngular

Get the best new AI prompts every week

One short email a week: the best new prompts and rules for ChatGPT, Claude, Gemini, Midjourney, Cursor and more, plus what changed in the tools. Free, unsubscribe anytime.

Finishes on our newsletter page at beehiiv (opens in a new tab). Or subscribe directly.