# MD3 Layout and Responsive Design
Reference for Material Design 3's layout system: breakpoints, canonical layouts, and responsive implementation.
## Jetpack Compose and Android
The **breakpoint table** below is a **design** reference. In **Jetpack Compose**, prefer **`calculateWindowSizeClass`** (`androidx.compose.material3:material3-window-size-class`) and/or **`androidx.compose.material3.adaptive`** APIs (e.g. `currentWindowAdaptiveInfo`, list-detail scaffolds) instead of hand-rolling raw `BoxWithConstraints` width checks everywhere.
**Edge-to-edge:** Use **`enableEdgeToEdge()`** on your `Activity` (AndroidX) when you draw behind the system bars. Apply **`WindowInsets`** (`Modifier.statusBarsPadding()`, `navigationBarsPadding()`, **`imePadding()`**, `displayCutoutPadding()`, etc.) and **`Scaffold`** `contentWindowInsets` so content and **IME** behave correctly.
**Foldables:** Use **`WindowInfoTracker`**, **`FoldingFeature`**, or Jetpack WindowManager APIs — see the foldable section below; verify APIs against your dependency versions.
---
## Google I/O 2026: Expressive Layout
Material's [I/O 2026 update](https://m3.material.io/blog/whats-new-at-io26) introduced broader expressive/adaptive layout guidance:
- **Expressive layout scaffold**: Design screens to adapt across mobile, desktop, foldables, watches, XR, and other spatial form factors. In Compose, prefer Material3 adaptive scaffolds and window size classes over hard-coded phone/tablet branches.
- **8dp spacing system**: Treat spacing as tokens. Use an 8dp scale for margins, padding, gaps, and component spacing so density and device-class changes can be applied consistently.
- **Watch guidance**: Use physics-based motion, arc text styles, and edge-hugging containers. Avoid shrinking phone layouts onto a round or compact wearable screen.
- **XR guidance**: Use spatial panels and depth-based elevation. Avoid treating XR as only a larger desktop canvas; account for depth, comfort, and panel placement.
### Spacing Token Pattern
Define spacing once, then map it to context:
```kotlin
object MdSpacing {
val xxs = 4.dp
val xs = 8.dp
val sm = 16.dp
val md = 24.dp
val lg = 32.dp
val xl = 48.dp
}
```
Use spacing tokens for:
- Screen margins
- Pane gaps
- List item spacing
- Card internal padding
- Component groups and toolbars
Do not scatter raw `Dp` literals throughout reusable UI. Keep one-off values local only when they are truly component-specific.
---
## Window Size Classes
MD3 defines 5 breakpoint classes:
| Class | Width Range | Typical Devices | Columns |
|-------|-----------|----------------|---------|
| Compact | < 600dp | Phone portrait | 4 |
| Medium | 600–839dp | Tablet portrait, foldable | 8 |
| Expanded | 840–1199dp | Tablet landscape, small desktop | 12 |
| Large | 1200–1599dp | Desktop | 12 |
| Extra-large | 1600dp+ | Ultra-wide, large desktop | 12 |
### CSS Media Queries (web)
Use these for **CSS layouts**. **Compose** apps should use window size classes / adaptive APIs rather than duplicating this logic only in CSS.
```css
/* Compact (default — mobile-first) */
/* No media query needed, this is the base */
/* Medium */
@media (min-width: 600px) { }
/* Expanded */
@media (min-width: 840px) { }
/* Large */
@media (min-width: 1200px) { }
/* Extra-large */
@media (min-width: 1600px) { }
```
### dp to px Conversion
On the web, 1dp ≈ 1px at standard density. The breakpoint values translate directly to CSS pixels.
## Layout Anatomy
### Key Terms
- **Window**: The visible area of the app
- **Pane**: A layout container within the window. A pane is fixed, flexible, floating, or semi-permanent
- **Column**: A vertical content block within a pane
- **Margin**: Space between screen edge and content
- **Gutter**: Space between columns
- **Spacer**: Space between panes (in multi-pane layouts)
### Margin and Gutter Values
| Window Size | Margins | Gutters |
|-------------|---------|---------|
| Compact | 16dp | 8dp |
| Medium | 24dp | 16dp |
| Expanded | 24dp | 16dp |
| Large | 24dp | 24dp |
| Extra-large | 24dp | 24dp |
## Canonical Layouts
MD3 defines 3 canonical layouts as starting points. Always begin from one of these rather than from a raw grid.
### Feed Layout
**Use when**: Displaying a large collection of browsable items (social feed, news, product grid).
```
Compact: Single column of cards
Medium: 2-column grid
Expanded: 3-column grid
Large: 4-column grid + optional side panel
```
```html
```
```css
.md3-feed {
display: grid;
gap: 8px;
padding: 16px;
grid-template-columns: 1fr; /* Compact: 1 column */
}
@media (min-width: 600px) {
.md3-feed {
grid-template-columns: repeat(2, 1fr);
gap: 16px;
padding: 24px;
}
}
@media (min-width: 840px) {
.md3-feed {
grid-template-columns: repeat(3, 1fr);
}
}
@media (min-width: 1200px) {
.md3-feed {
grid-template-columns: repeat(4, 1fr);
gap: 24px;
}
}
```
### List-Detail Layout
**Use when**: Browsing a list of items where each has detailed content (email, file browser, contacts).
```
Compact: List view OR detail view (navigate between them)
Medium: Side-by-side list (1/3) + detail (2/3)
Expanded: Side-by-side with wider detail pane
```
```html
Item 1 Detail
Full content here...
```
```css
.md3-list-detail {
display: flex;
flex-direction: column;
min-height: 100%;
}
.md3-list-detail__list {
background: var(--md-sys-color-surface-container);
border-radius: var(--md-sys-shape-corner-large);
overflow: auto;
}
.md3-list-detail__detail {
flex: 1;
padding: 24px;
}
/* Compact: show one at a time */
@media (max-width: 599px) {
.md3-list-detail__detail { display: none; }
.md3-list-detail--detail-active .md3-list-detail__list { display: none; }
.md3-list-detail--detail-active .md3-list-detail__detail { display: block; }
}
/* Medium+: side by side */
@media (min-width: 600px) {
.md3-list-detail {
flex-direction: row;
gap: 24px;
padding: 24px;
}
.md3-list-detail__list {
width: 360px;
flex-shrink: 0;
}
}
/* Expanded: wider detail */
@media (min-width: 840px) {
.md3-list-detail__list {
width: 400px;
}
}
```
### Drag Handle for Resizable Panes
In list-detail and supporting pane layouts, users can resize panes with a drag handle:
```html