> Markdown version of [App Layout 2 Migration Guide](https://vaadin.com/docs/v14/flow/upgrading/v10-13/app-layout-v2-migration-guide). Section index: [llms.txt](https://vaadin.com/docs/v14/flow/llms.txt)

# App Layout 2 Migration Guide

Version 2 of `AppLayout` is introduced in Vaadin 14 and comes with several breaking changes.

## <a id="routing"></a>Routing

`AbstractAppRouterLayout` was removed. `AppLayout` itself now implements `RouterLayout`. If you have a view like that extended `AbstractRouterLayout`

```java
public class MyView extends AbstractRouterLayout {
    ...
}
```

It should now extend AppLayout

```java
public class MyView extends AppLayout {
    ...
}
```

## <a id="menu"></a>Menu

`AppLayoutMenu` and `AppLayoutMenuItem` were removed. The same functionality can be achieved by using `vaadin-tabs`. `AppLayoutMenu` can be directly replaced with `Tabs`.

```java
Tabs menu = new Tabs();
tabs.setWidthFull();
```

To mimick AppLayoutMenu’s look, use horizontal orientation and place the menu in the navbar.

```java
tabs.setOrientation(Tabs.Orientation.HORIZONTAL);
appLayout.addToNavbar(true, tabs);
```

Use `vaadin-tab` for menu items. To create a navigation item, the recommended approach is to add a router link inside the tab.

```java
RouterLink link = new RouterLink(null,TargetView.class);
link.add(VaadinIcon.ARROW_RIGHT.create());
link.add("link text");
Tab tab = new Tab();
tab.add(link);
tabs.add(tab);
```

Additionally, use the appropriate theme variant to place the icon on top of the tab.

```
tab.addThemeVariants(TabVariant.LUMO_ICON_ON_TOP);
```

## <a id="branding-on-navbar"></a>Branding on navbar

To keep the same look of the previous version with the branding on the top left and having the menu center, add both elements to the navbar.

```java
Span appName = new Span("Branding");
appName.addClassName("hide-on-mobile");

this.addToNavbar(true, appName, tabs);
```

and add some styles to shared-styles.html

```html
<dom-module id="app-layout-theme" theme-for="vaadin-app-layout">
  <template>
    <style>
      [part="navbar"] {
        align-items: center;
        justify-content: center;
      }
      [part="navbar"]::after {
        content: '';
      }
      [part="navbar"] ::slotted(*:first-child),
      [part="navbar"]::after {
        flex: 1 0 0.001px;
      }
      @media (max-width: 425px) {
        [part="navbar"] ::slotted(.hide-on-mobile) {
          display: none;
        }
        [part="navbar"]::after {
          content: none;
        }
    }
    </style>
  </template>
</dom-module>

<custom-style>
  <style>
    vaadin-app-layout vaadin-tab a:hover {
      text-decoration: none;
    }
    vaadin-app-layout vaadin-tab:not([selected]) a {
      color: var(--lumo-contrast-60pct);
    }
    vaadin-app-layout vaadin-tab iron-icon {
      margin: 0 4px;
      width: var(--lumo-icon-size-m);
      height: var(--lumo-icon-size-m);
      padding: .25rem;
      box-sizing: border-box!important;
    }
  </style>
</custom-style>
```

## <a id="new-drawertoggle-to-open-or-close-the-drawer"></a>New `DrawerToggle` to open or close the drawer.

To use it, add a instance to the component, tipically to the navbar. It will cause a button to appear that will toggle the navbar when clicked.

```java
appLayout.addToNavbar(new DrawerToggle());
```

`03AFD16E-8142-42FA-8D8C-124D761C2BDF`
