layout-responsive
MUI layout components and responsive design patterns
What this skill does
# MUI Layout and Responsive Design
## Grid v2
MUI v6 ships Grid v2 as default (imported from `@mui/material/Grid`). The `size` prop
replaces the old `xs`/`sm`/`md` props. Grid v2 always uses CSS grid internally and no
longer requires the `item` prop — every direct child of a `container` is a grid item.
### Basic grid
```tsx
import Grid from '@mui/material/Grid';
import Paper from '@mui/material/Paper';
<Grid container spacing={2}>
<Grid size={12}>
<Paper sx={{ p: 2 }}>Full width header</Paper>
</Grid>
<Grid size={{ xs: 12, md: 8 }}>
<Paper sx={{ p: 2 }}>Main content (full on mobile, 8/12 on desktop)</Paper>
</Grid>
<Grid size={{ xs: 12, md: 4 }}>
<Paper sx={{ p: 2 }}>Sidebar (full on mobile, 4/12 on desktop)</Paper>
</Grid>
</Grid>
```
### size values
```tsx
// Fixed column span
<Grid size={6} /> // always 6/12
// Responsive spans
<Grid size={{ xs: 12, sm: 6, md: 4, lg: 3 }} />
// 'auto' — shrinks to content width
<Grid size="auto" />
// 'grow' — fills remaining space (equivalent to old xs="true")
<Grid size="grow" />
```
### Spacing and column/row gap
```tsx
// Uniform spacing
<Grid container spacing={3}>
// Separate column and row spacing
<Grid container columnSpacing={4} rowSpacing={2}>
// Responsive spacing
<Grid container spacing={{ xs: 1, sm: 2, md: 3 }}>
```
### Offset
```tsx
// Offset pushes the item right by n columns
<Grid container>
<Grid size={4} offset={4}>
<Paper sx={{ p: 2 }}>Centered 4-column block</Paper>
</Grid>
</Grid>
// Responsive offset
<Grid size={6} offset={{ xs: 0, md: 3 }}>
Centered on desktop, left-aligned on mobile
</Grid>
```
### Nested grid
```tsx
<Grid container spacing={2}>
<Grid size={8}>
{/* Nested grid — no additional container needed in v2 */}
<Grid container spacing={1}>
<Grid size={6}><Paper sx={{ p: 1 }}>Nested A</Paper></Grid>
<Grid size={6}><Paper sx={{ p: 1 }}>Nested B</Paper></Grid>
</Grid>
</Grid>
<Grid size={4}>
<Paper sx={{ p: 2 }}>Sidebar</Paper>
</Grid>
</Grid>
```
---
## Stack
`Stack` is a one-dimensional layout component (flexbox row or column). Simpler than Grid
for linear sequences of components.
### Basic usage
```tsx
import Stack from '@mui/material/Stack';
import Divider from '@mui/material/Divider';
// Vertical stack (default direction)
<Stack spacing={2}>
<TextField label="First name" />
<TextField label="Last name" />
<TextField label="Email" />
<Button variant="contained">Submit</Button>
</Stack>
// Horizontal row
<Stack direction="row" spacing={1} alignItems="center">
<Avatar src={user.avatar} />
<Typography>{user.name}</Typography>
<Chip label={user.role} size="small" />
</Stack>
```
### Responsive direction
```tsx
<Stack
direction={{ xs: 'column', sm: 'row' }}
spacing={{ xs: 1, sm: 2 }}
alignItems={{ xs: 'stretch', sm: 'center' }}
justifyContent="space-between"
>
<SearchInput />
<FilterPanel />
<ActionButtons />
</Stack>
```
### Divider between items
```tsx
<Stack
direction="row"
spacing={2}
divider={<Divider orientation="vertical" flexItem />}
>
<Typography>Section A</Typography>
<Typography>Section B</Typography>
<Typography>Section C</Typography>
</Stack>
```
### useFlexGap
By default Stack uses negative margin to simulate gaps. Set `useFlexGap` to use the CSS
`gap` property instead — required when children have `overflow: hidden` or when the
container has `overflow: hidden`.
```tsx
<Stack
direction="row"
spacing={2}
useFlexGap
flexWrap="wrap"
sx={{ width: '100%' }}
>
{tags.map((tag) => <Chip key={tag} label={tag} />)}
</Stack>
```
---
## Container
Centers content horizontally with a max-width. The main layout wrapper for page content.
```tsx
import Container from '@mui/material/Container';
// Responsive max-width (uses theme breakpoints)
<Container maxWidth="lg"> {/* lg = 1200px by default */}
<Typography variant="h1">Page title</Typography>
</Container>
// Exact pixel constraint
<Container maxWidth="sm"> {/* sm = 600px */}
// Disable max-width (full fluid width)
<Container maxWidth={false}>
// 'fixed' — jumps between fixed widths at each breakpoint
<Container fixed>
// Typical page layout
<Box sx={{ minHeight: '100vh', display: 'flex', flexDirection: 'column' }}>
<AppBar position="sticky">{/* ... */}</AppBar>
<Container maxWidth="xl" sx={{ flex: 1, py: 3 }}>
{children}
</Container>
<Box component="footer" sx={{ bgcolor: 'background.paper', py: 4 }}>
<Container maxWidth="xl">{/* footer content */}</Container>
</Box>
</Box>
```
---
## Box as a Layout Primitive
`Box` renders a `div` by default but accepts a `component` prop. It has full access to
the `sx` prop and system shorthands.
```tsx
import Box from '@mui/material/Box';
// Flex centering helper
<Box display="flex" alignItems="center" justifyContent="center" minHeight="100vh">
<CircularProgress />
</Box>
// Section spacing
<Box component="section" sx={{ py: { xs: 6, md: 10 } }}>
{children}
</Box>
// Scroll container
<Box sx={{ overflowY: 'auto', maxHeight: 400, '&::-webkit-scrollbar': { width: 6 } }}>
{longList}
</Box>
```
---
## Breakpoints
MUI's default breakpoints (in `px`):
| Key | Min width |
|-----|-----------|
| xs | 0 |
| sm | 600 |
| md | 900 |
| lg | 1200 |
| xl | 1536 |
### useMediaQuery
```tsx
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTheme } from '@mui/material/styles';
function ResponsiveComponent() {
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
const isTablet = useMediaQuery(theme.breakpoints.between('sm', 'md'));
const isDesktop = useMediaQuery(theme.breakpoints.up('md'));
// SSR: default to a value so the first render matches server output
const prefersDark = useMediaQuery('(prefers-color-scheme: dark)', {
defaultMatches: false,
noSsr: true,
});
return isMobile ? <MobileLayout /> : <DesktopLayout />;
}
```
### Breakpoint helpers
```tsx
// theme.breakpoints.up(key) — key and above
// theme.breakpoints.down(key) — below key (exclusive)
// theme.breakpoints.between(start, end) — start to end (exclusive end)
// theme.breakpoints.only(key) — exactly key
// In sx prop (shorthand)
<Box sx={{
display: { xs: 'none', md: 'block' }, // hide on mobile
}}>
Desktop only content
</Box>
// In styled()
const HiddenOnMobile = styled(Box)(({ theme }) => ({
[theme.breakpoints.down('md')]: {
display: 'none',
},
}));
```
---
## Common Layout Patterns
### App shell: sidebar + main content
```tsx
const DRAWER_WIDTH = 240;
function AppShell() {
const [mobileOpen, setMobileOpen] = React.useState(false);
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
const drawerContent = (
<Box>
<Toolbar />
<Divider />
<NavMenu />
</Box>
);
return (
<Box sx={{ display: 'flex' }}>
<AppBar
position="fixed"
sx={{ zIndex: (t) => t.zIndex.drawer + 1 }}
>
<Toolbar>
{isMobile && (
<IconButton color="inherit" edge="start" onClick={() => setMobileOpen(true)}>
<MenuIcon />
</IconButton>
)}
<Typography variant="h6" sx={{ flexGrow: 1 }}>My App</Typography>
</Toolbar>
</AppBar>
{/* Mobile: temporary drawer */}
<Drawer
variant="temporary"
open={mobileOpen}
onClose={() => setMobileOpen(false)}
ModalProps={{ keepMounted: true }}
sx={{
display: { xs: 'block', md: 'none' },
'& .MuiDrawer-paper': { width: DRAWER_WIDTH },
}}
>
{drawerContent}
</Drawer>
{/* Desktop: permanent drawer */}
<Drawer
variant="permanent"
sx={{
display: { xs: 'none', md: 'block' },
'& .MuiDrawer-paper': { width: DRAWER_WIDTH, boxSizing: 'border-box' },
width: DRAWERRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.