Add a layout

Layouts are used to define the structure of your page. Apollux has multiple layout options (two at the moment and more in the future), they mostly differ by how the navigation experience is handled.

  • <ApolluxCollapseLayout> :
    This layout is provided by apollux-layout-collapse layer, it has better navigation experience when few items are needed to be displayed.
  • <ApolluxSidebarLayout> :
    This layout is provided by apollux-layout-sidebar layer, it's the default layout used on the demo app.
  • <ApolluxTopnavLayout> :
    This layout is provided by apollux-layout-topnav layer, it features a top navigation when you have fewer items to show.

Enable layout layers

To keep things simple, we grouped each layout in a dedicated nuxt layer, so they have their own set of components, composables, configuration and dependencies.

To enable a layout, you need to add it to the extends section of your .app/nuxt.config.ts file.

.app/nuxt.config.ts
To learn more about layers, check out the layers section

Assign layout to a page

Components that are defined in .app/pages/ (and any other pages/ folders of enabled layers) will be considered as pages. You can assign a layout to a page by adding the layout property to the definePageMeta macro.

.app/pages/index.vue

Set default layout

Instead of setting the layout on each page, you can create a .app/layouts/default.vue component that will be used as the default layout for all pages. In this component, you just have to include the main component of the layout you want to use, in this case we use <ApolluxCollapseLayout>

.app/layouts/default.vue

Layout app config

As layouts differ by how the navigation experience is handled, they also have their own set of configuration options. In order to have a great developer experience, we defined a dedicated schema for each layout so you can have autocompletion in your .app/app.config.ts file.

This configuration depends on each layout, you'll be able to learn more about each one of these in the dedicated layout documentation, but here is a quick configuration example for the sidebar layout.

.app/app.config.ts

Find more information about how to setup navigation in the sidebar layout configuration documentation.

Force empty layout

You should still be able to optout from the default layout by setting the layout property to empty on a page.

.app/pages/index.vue
Take a look at the .demo/pages/layouts/projects/board/[slug].vue page, which has advanced layout configuration.

Useful resources: