Skip to main content brightness_auto motion_photos_off palette download more_vert
toc

Layout

Layout adapts an app to the window with window size classes, a column grid, margins and panes.

Layout adapts an app to the window. The window size class (see Adaptive layout) sets the layout tokens on :root:

  • --md-sys-layout-columns: 4 at compact, 8 at medium and expanded, 12 from large up.
  • --md-sys-layout-margin: 16px at compact, 24px above.
  • --md-sys-layout-spacer: the gutter between columns, 16px at compact, 24px above.

Window size classes and grid

Link to “Window size classes and grid”

.md-layout-grid lays its children out on the column grid, with the margin as inline padding and the spacer as the gap.

Inbox Drafts Sent
<div class="md-layout-grid">
  <md-gb-button color="tonal">Inbox</md-gb-button>
  <md-gb-button color="tonal">Drafts</md-gb-button>
  <md-gb-button color="tonal">Sent</md-gb-button>
</div>

Add .md-window to an element so its direct children follow that element's width instead of the viewport.

Inbox Drafts
<div class="md-window">
  <div class="md-layout-grid">
    <md-gb-button color="tonal">Inbox</md-gb-button>
    <md-gb-button color="tonal">Drafts</md-gb-button>
  </div>
</div>

To react in code, observe the class of the window or of an element:

HTMLJS
<output id="size-class" aria-live="polite"></output>

On a foldable device, the fold's position and size are available as --md-sys-layout-fold-left and --md-sys-layout-fold-width (vertical fold) or --md-sys-layout-fold-top and --md-sys-layout-fold-height (horizontal fold). To react in code, observe the fold. The callback gets null when there is none.

HTMLJS
<output id="fold" aria-live="polite">No fold</output>
Install Material Web 3.0

Your browser did not offer to install the docs as an app. Install them from the browser instead:

Close
Send feedback
Bug Documentation Idea

Opens a new GitHub issue for material-components/material-web in a new tab, with this filled in.

Cancel Open issue