App Layout is a component for building common application layouts.

Important
Scaled down examples
The examples on this page are scaled down so that their viewport-size dependant behavior can be demonstrated. Some examples change their behavior also based on your browser viewport size.
<vaadin-app-layout>
  <vaadin-drawer-toggle slot="navbar"></vaadin-drawer-toggle>
  <h1 slot="navbar">MyApp</h1>
  <vaadin-tabs slot="drawer" orientation="vertical">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
        <span>Dashboard</span>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
        <span>Orders</span>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
</vaadin-app-layout>

The layout consists of three sections: a horizontal navigation bar (navbar), a collapsible navigation drawer (drawer) and a content area. An application’s main navigation blocks should be positioned in the navbar and/or drawer while views are rendered in the content area.

App Layout is responsive and adjusts automatically to fit desktop, tablet and mobile screen sizes.

The navbar can be located on top or to the side of the drawer.

When put on top, the navbar is typically used as an application header. Application headers contain, for example, the application’s name and branding as well as actions that apply to the entire application such as notifications, settings, etc.

<vaadin-app-layout>
  <vaadin-drawer-toggle slot="navbar"></vaadin-drawer-toggle>
  <h1 slot="navbar">MyApp</h1>
  <vaadin-tabs slot="drawer" orientation="vertical">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
        <span>Dashboard</span>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
        <span>Orders</span>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
</vaadin-app-layout>

When placed to the side, the navbar is often seen as a view header, housing the view’s title, actions and secondary navigation that only relate to the current view.

<vaadin-app-layout primary-section="drawer">
  <vaadin-drawer-toggle slot="navbar"></vaadin-drawer-toggle>
  <h1 slot="navbar">Dashboard</h1>
  <vaadin-tabs slot="drawer" orientation="vertical">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
        <span>Dashboard</span>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
        <span>Orders</span>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
</vaadin-app-layout>

Drawer Toggle

Show and hide the drawer using a Drawer Toggle (or a Button). The Drawer Toggle (☰) should always be accessible (unless the drawer is empty) and is most often situated in the navbar.

Scrolling Behaviour

Mobile browsers will collapse and expand their address bars when the user scrolls down and up respectively. On iOS you can tap the status bar (signal strength, battery, clock, etc) to scroll back to the top of the page/view. To enable this effect, neither the App Layout or its parent should have their heights defined.

Note
Scrolling containers with 100% height
This behaviour is not compatible with vertically scrollable Grids, or other scrolling containers within the content area, whose height is 100%.

Bottom Navbar on Small Touchscreens

When the navbar is used for navigation, the touch-optimized navbar slot can be used to provide a separate version of the navigation at the bottom of the UI, optimized for mobile phones.

<vaadin-app-layout>
  <h1 slot="navbar">MyApp</h1>
  <vaadin-tabs slot="navbar touch-optimized" theme="equal-width-tabs">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
  <div class="content">
    <h2>View title</h2>
    <p>View content</p>
  </div>
</vaadin-app-layout>

Best Practices

Make the choice between navbar and drawer primarily based on the number of items placed in it.

The navbar is a good choice for a small number of items (3–5), as these can fit into the viewport without scrolling.

<vaadin-app-layout>
  <h1 slot="navbar">MyApp</h1>
  <vaadin-tabs slot="navbar">
    <vaadin-tab>
      <a tabindex="-1">Dashboard</a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">Orders</a>
    </vaadin-tab>
  </vaadin-tabs>
</vaadin-app-layout>

When more items need to be displayed, or if small screen support is a priority, the drawer is a better choice, as it can accommodate a longer list of links without scrolling, and collapses into a hamburger menu on small screens. Furthermore, a vertical list of items is easier for the user to scan.

<vaadin-app-layout primary-section="drawer">
  <vaadin-drawer-toggle slot="navbar"></vaadin-drawer-toggle>
  <h1 slot="navbar">Dashboard</h1>
  <vaadin-tabs slot="drawer" orientation="vertical">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
        <span>Dashboard</span>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
        <span>Orders</span>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
</vaadin-app-layout>

For applications that require multilevel or hierarchical navigation use the drawer to (at least) house the first level. The secondary (and tertiary) navigation items can be placed in either the drawer or the navbar.

<vaadin-app-layout primary-section="drawer">
  <h1 slot="drawer">MyApp</h1>
  <vaadin-tabs slot="drawer" selected="1" orientation="vertical">
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:dashboard"></iron-icon>
        <span>Dashboard</span>
      </a>
    </vaadin-tab>
    <vaadin-tab>
      <a tabindex="-1">
        <iron-icon icon="vaadin:cart"></iron-icon>
        <span>Orders</span>
      </a>
    </vaadin-tab>
  </vaadin-tabs>
  <vaadin-vertical-layout slot="navbar">
    <vaadin-horizontal-layout style="align-items: center;">
      <vaadin-drawer-toggle></vaadin-drawer-toggle>
      <h2>Orders</h2>
    </vaadin-horizontal-layout>
    <vaadin-tabs>
      <vaadin-tab>
        <a tabindex="-1">All</a>
      </vaadin-tab>
      <vaadin-tab>
        <a tabindex="-1">Open</a>
      </vaadin-tab>
    </vaadin-tabs>
  </vaadin-vertical-layout>
</vaadin-app-layout>