Layouts

A layout is a view that wraps other views. It holds the chrome every page shares, and marks where the page goes with <Slot/>. When the route changes, the router swaps the view inside the slot and leaves the layout in place.

A route picks its layout with a layout key, next to view.

Your turn

  1. Cut the <header> out of Shop.pzl and paste it into layouts/Default.pzl, above <main>.
  2. Delete the header from Playlist.pzl too. Each view now only needs its own content, so drop their <main> wrappers as well: the layout has one.
  3. In routes.js, import the layout and give both routes layout: Default.
import Default from './layouts/Default.pzl';

A route can nest further with children. The child renders at the parent view's own <Slot/>, and its path is relative to the parent's.

Chapters