AGENTS.md
skills/material-ui-tailwind/AGENTS.mdAGENTS.md
Quality
58/100
Scores the file, not the repository.Length
738 words
14 headings · 2 code blocksRepository
99k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# Material UI and Tailwind CSS23Version 1.0.0 (Material UI v9)45> **Version notice:** This skill targets Material UI v9 (`>=9.0.0 <10.0.0`). If you are using a different major version, verify the API details before following this guidance.67> Note: For agents and LLMs combining Material UI with Tailwind CSS. Primary source for v4: `docs/data/material/integrations/tailwindcss/tailwindcss-v4.md`. v3: `docs/data/material/integrations/interoperability/interoperability.md` (Tailwind CSS v3).89---1011## Abstract1213Tailwind CSS v4 integration with Material UI is built on CSS cascade layers: MUI emits styles inside `@layer mui`, and Tailwind's `utilities` layer must come after so utilities can override without `!important`. Enable MUI's layer mode with `enableCssLayer: true` (Next.js via `AppRouterCacheProvider` / shared `createEmotionCache`) or `StyledEngineProvider` with `enableCssLayer` (Vite and other SPAs). Declare layer order (for example `@layer theme, base, mui, components, utilities`) before `@import 'tailwindcss'` (or inject the same string with `GlobalStyles` where the docs show). Tailwind CSS v3 uses a different recipe (preflight off, `important`, `StyledEngineProvider` with `injectFirst`, portal `container`). Prefer v4 for new work when possible.1415---1617## Table of contents18191. [Tailwind CSS v4 (preferred)](#tailwind-css-v4-preferred)202. [Next.js specifics](#nextjs-specifics)213. [Vite and other SPAs](#vite-and-other-spas)224. [Applying utilities to MUI components](#applying-utilities-to-mui-components)235. [Theme tokens in Tailwind (`@theme`)](#theme-tokens-in-tailwind-theme)246. [VS Code IntelliSense](#vs-code-intellisense)257. [Tailwind CSS v3 (legacy)](#tailwind-css-v3-legacy)268. [Troubleshooting](#troubleshooting)279. [Further reading](#further-reading)2829---3031## Tailwind CSS v4 (preferred)3233### Goals34351. Generate Tailwind with the `@layer` directive.362. Order layers so `mui` comes before `utilities`, so Tailwind utilities override MUI predictably.3738See [Tailwind CSS v4 integration—Overview](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#overview).3940### Layer stack (typical)4142At the top of your global CSS (example from docs):4344```css45@layer theme, base, mui, components, utilities;46@import 'tailwindcss';47```4849Adjust file paths to your app (`src/app/global.css`, `styles/global.css`, etc.).5051---5253## Next.js specifics54551. Complete the [Next.js integration—App Router](https://mui.com/material-ui/integrations/nextjs.md#app-router) or [Next.js integration—Pages Router](https://mui.com/material-ui/integrations/nextjs.md#pages-router) setup first.562. App Router: `<AppRouterCacheProvider options={{ enableCssLayer: true }}>` in the root layout. `suppressHydrationWarning` on `<html>` appears in the doc example when relevant.573. Pages Router: shared `createEmotionCache({ enableCssLayer: true })` from `@mui/material-nextjs`, passed through `documentGetInitialProps`; `AppCacheProvider` uses the same cache; layer order via `GlobalStyles` as the first child inside `AppCacheProvider`. See [Tailwind CSS v4 integration—Next.js Pages Router](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#nextjs-pages-router).5859For a concise provider checklist, see the material-ui-nextjs skill and [Next.js integration—Using other styling solutions](https://mui.com/material-ui/integrations/nextjs.md#using-other-styling-solutions).6061---6263## Vite and other SPAs64651. `StyledEngineProvider` with `enableCssLayer`.662. `GlobalStyles` injecting `@layer theme, base, mui, components, utilities;` before the app tree.6768See [Tailwind CSS v4 integration—Vite.js or any other SPA](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#vitejs-or-any-other-spa).6970Example repo: [material-ui-vite-tailwind-ts](https://github.com/mui/material-ui/tree/master/examples/material-ui-vite-tailwind-ts).7172---7374## Applying utilities to MUI components7576- `className`: root element of the component.77- `slotProps.{slot}.className`: interior [slots](https://mui.com/material-ui/customization/overriding-component-structure.md#interior-slots).7879See [Tailwind CSS v4 integration—Usage](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#usage).8081---8283## Theme tokens in Tailwind (`@theme`)8485To reuse MUI theme variables as Tailwind tokens, map `--mui-*` CSS variables into Tailwind's `@theme`. Minimal example (extend as needed):8687```css88@theme inline {89 --color-primary: var(--mui-palette-primary-main);90 --color-primary-light: var(--mui-palette-primary-light);91 --color-primary-dark: var(--mui-palette-primary-dark);92 --color-error: var(--mui-palette-error-main);93 --color-text-primary: var(--mui-palette-text-primary);94}95```9697The full token list (palette, typography, breakpoints, shadows, …) is long and maintained on the doc page. Copy the complete `@theme inline { ... }` block from [Extend Material UI classes](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#extend-material-ui-classes) when you need it all.9899See [Tailwind CSS v4 integration—Extend Material UI classes](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#extend-material-ui-classes) and the linked [playground](https://play.tailwindcss.com/mh7Ym0mGff).100101Requirement: MUI CSS theme variables (`cssVariables: true` in `createTheme`) so the `--mui-*` variables exist. Align with the material-ui-theming skill.102103---104105## VS Code IntelliSense106107For `slotProps` and similar, add `tailwindCSS.experimental.classRegex` in VS Code `settings.json` as in [Tailwind CSS v4 integration—Tailwind CSS IntelliSense for VS Code](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#tailwind-css-intellisense-for-vs-code).108109Snippet also lives in [reference.md](reference.md).110111---112113## Tailwind CSS v3 (legacy)114115Use the interoperability guide, not the v4 page:1161171. Install Tailwind v3 per upstream docs.1182. `corePlugins: { preflight: false }` so MUI `CssBaseline` owns base resets.1193. `important: '#__next'` or `'#root'`; App Router may need `id="__next"` on `<body>` manually.1204. `StyledEngineProvider` with `injectFirst` (or Emotion `prepend: true` cache) for injection order.1215. Theme `defaultProps` `container` on `Modal`, `Dialog`, `Popover`, `Popper` to the same root as `important`.122123See [Interoperability—Tailwind CSS v3](https://mui.com/material-ui/integrations/interoperability.md#tailwind-css-v3) and [Interoperability—Troubleshooting](https://mui.com/material-ui/integrations/interoperability.md#troubleshooting) (table of root IDs).124125---126127## Troubleshooting128129v4: confirm Tailwind >= v4, layer order, and DevTools cascade layers (`mui` before `utilities`). See [Tailwind CSS v4 integration—Troubleshooting](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md#troubleshooting).130131v3: verify `important` selector matches root `id`, `preflight: false`, and `injectFirst`. See the interoperability Troubleshooting subsection linked above.132133---134135## Further reading136137| Topic | Link |138| :------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------ |139| Tailwind CSS v4 + MUI | [Tailwind CSS v4 integration](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4.md) |140| CSS layers (MUI concepts) | [CSS Layers](https://mui.com/material-ui/customization/css-layers.md) |141| Interior slots | [Overriding component structure—Interior slots](https://mui.com/material-ui/customization/overriding-component-structure.md#interior-slots) |142| Tailwind v3 + MUI | [Interoperability—Tailwind CSS v3](https://mui.com/material-ui/integrations/interoperability.md#tailwind-css-v3) |143
Also in mui/material-ui
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| mui/material-uiskills/material-ui-nextjs/AGENTS.md · 99k | AGENTS.md | setupstylearchtypes+2 | 70/100 | 3 days ago | |
| mui/material-uiskills/material-ui-styling/AGENTS.md · 99k | AGENTS.md | styleui | 58/100 | 3 days ago | |
| mui/material-uiskills/material-ui-theming/AGENTS.md · 99k | AGENTS.md | setupstyleui | 58/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 2 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| aaif-goose/gooseAGENTS.md · 52k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago |
