{"content": "---\nname: mui\ndescription: Material-UI v7 component library patterns including sx prop styling, theme integration, responsive design, and MUI-specific hooks. Use when working with MUI components, styling with sx prop, theme customization, or MUI utilities.\n---\n\n# MUI v7 Patterns\n\n## Purpose\n\nMaterial-UI v7 (released March 2025) patterns for component usage, styling with sx prop, theme integration, and responsive design.\n\n**Note**: MUI v7 breaking changes from v6:\n- Deep imports no longer work - use package exports field\n- `onBackdropClick` removed from Modal - use `onClose` instead\n- All components now use standardized `slots` and `slotProps` pattern\n- CSS layers support via `enableCssLayer` config (works with Tailwind v4)\n\n## When to Use This Skill\n\n- Styling components with MUI sx prop\n- Using MUI components (Box, Grid, Paper, Typography, etc.)\n- Theme customization and usage\n- Responsive design with MUI breakpoints\n- MUI-specific utilities and hooks\n\n---\n\n## Quick Start\n\n### Basic MUI Component\n\n```typescript\nimport { Box, Typography, Button, Paper } from '@mui/material';\nimport type { SxProps, Theme } from '@mui/material';\n\nconst styles: Record> = {\n container: {\n p: 2,\n display: 'flex',\n flexDirection: 'column',\n gap: 2,\n },\n header: {\n mb: 3,\n fontSize: '1.5rem',\n fontWeight: 600,\n },\n};\n\nfunction MyComponent() {\n return (\n \n \n Title\n \n \n \n );\n}\n```\n\n---\n\n## Styling Patterns\n\n### Inline Styles (< 100 lines)\n\nFor components with simple styling, define styles at the top:\n\n```typescript\nimport type { SxProps, Theme } from '@mui/material';\n\nconst componentStyles: Record> = {\n container: {\n p: 2,\n display: 'flex',\n flexDirection: 'column',\n },\n header: {\n mb: 2,\n color: 'primary.main',\n },\n button: {\n mt: 'auto',\n alignSelf: 'flex-end',\n },\n};\n\nfunction Component() {\n return (\n \n Header\n \n \n );\n}\n```\n\n### Separate Styles File (>= 100 lines)\n\nFor complex components, create separate style file:\n\n```typescript\n// UserProfile.styles.ts\nimport type { SxProps, Theme } from '@mui/material';\n\nexport const userProfileStyles: Record> = {\n container: {\n p: 3,\n maxWidth: 800,\n mx: 'auto',\n },\n header: {\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n mb: 3,\n },\n // ... many more styles\n};\n\n// UserProfile.tsx\nimport { userProfileStyles as styles } from './UserProfile.styles';\n\nfunction UserProfile() {\n return ...;\n}\n```\n\n---\n\n## Common Components\n\n### Layout Components\n\n```typescript\n// Box - Generic container\n\n Content\n\n\n// Paper - Elevated surface\n\n Content\n\n\n// Container - Centered content with max-width\n\n Content\n\n\n// Stack - Flex container with spacing\n\n \n \n\n```\n\n### Grid System\n\n```typescript\nimport { Grid } from '@mui/material';\n\n// 12-column grid\n\n \n Left half\n \n \n Right half\n \n\n\n// Responsive grid\n\n \n Card\n \n {/* Repeat for more cards */}\n\n```\n\n### Typography\n\n```typescript\nHeading 1\nHeading 2\nBody text\nSmall text\n\n// With custom styling\n\n Custom Heading\n\n```\n\n### Buttons\n\n```typescript\n// Variants\n\n\n\n\n// Colors\n\n\n\n\n// With icons\nimport { Add as AddIcon } from '@mui/icons-material';\n\n\n```\n\n---\n\n## Theme Integration\n\n### Using Theme Values\n\n```typescript\nimport { useTheme } from '@mui/material';\n\nfunction Component() {\n const theme = useTheme();\n\n return (\n \n Themed box\n \n );\n}\n```\n\n### Theme in sx Prop\n\n```typescript\n\n Content\n\n\n// Callback for advanced usage\n ({\n color: theme.palette.primary.main,\n '&:hover': {\n color: theme.palette.primary.dark,\n },\n })}\n>\n Hover me\n\n```\n\n---\n\n## Responsive Design\n\n### Breakpoints\n\n```typescript\n// Mobile-first responsive values\n\n Responsive width\n\n\n// Responsive display\n