The MDL layout component provides a responsive, scalable page structure that adapts to different browsers, screen sizes, and devices. It is composed of several key parts:
- Outer Container: A
<div> with classes mdl-layout and mdl-js-layout. Note: You cannot apply the layout directly to the <body> element; you must use a nested <div>. - Header (
mdl-layout__header): Contains the title, a menu icon for mobile navigation, and navigation links. - Drawer (
mdl-layout__drawer): A slide-out panel that appears automatically on smaller screens or can be opened via the menu icon. It can be configured as a fixed sidebar on larger screens. - Content (
mdl-layout__content): The <main> element that holds the primary page content.
By combining these elements with specific MDL classes, you can create various layout patterns such as fixed headers, scrolling headers, or fixed sidebars.
<div class="mdl-layout mdl-js-layout">
<header class="mdl-layout__header">
<div class="mdl-layout-icon"></div>
<div class="mdl-layout__header-row">
<span class="mdl-layout__title">Title</span>
<div class="mdl-layout-spacer"></div>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="#">Link</a>
</nav>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout__title">Drawer Title</span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="#">Drawer Link</a>
</nav>
</div>
<main class="mdl-layout__content">
<!-- Primary Content -->
</main>
</div>