Skip to content

App Shell

@astryxdesign/core v0.7.1 · AppShell

Usage ​

AppShell is the page frame. The default slot is the page content. topNav, sideNav, banner, and mobileNav are named slots.

vue
<script setup lang="ts">
import { AppShell } from '@astryx-vue/core/AppShell'
import { SideNav, SideNavItem } from '@astryx-vue/core/SideNav'
</script>

<template>
  <AppShell :content-padding="6">
    <template #sideNav>
      <SideNav>
        <SideNavItem href="#orders" is-selected label="Orders" />
      </SideNav>
    </template>
    <p>Orders</p>
  </AppShell>
</template>

variant is wash, surface, section, or elevated (the default). contentPadding is a spacing step for the content region. height is fill or auto. fill uses 100dvh; an inline height: 100% overrides it when the shell sits in a sized preview.

mobileNav is false or { breakpoint, isOpen, hasToggle }. The default breakpoint is md (768px). Below the breakpoint the side nav moves into a drawer. A top nav inside the shell uses that drawer instead of opening one of its own. v-model:mobile-nav-open controls the drawer, and the component emits mobileNavOpenChange.

A skip link points at #astryx-app-shell-main. The main region is a div with role="main" and tabindex="-1". With variant="elevated" and both a top nav and a side nav on a wide viewport, the content sits on a rounded backdrop.

useAppShellMobile reads the nearest shell. Outside a shell, or when mobile nav is off, isMobile and isMobileNavEnabled are false and the open and close methods do nothing.

Anatomy

ElementDescription
Page shellOutermost application frame that owns page-level navigation, responsive shell behavior, and the main content landmark.
Skip linkFirst focusable element on the page. Visually hidden until focused, then moves focus to the main content area.
BannerThe banner slot, for system-wide announcements. Renders above the top nav, inside the banner landmark.
Top navigationThe topNav slot, typically TopNav. Below the mobile breakpoint it becomes a compact bar carrying the nav toggle.
Side navigationThe sideNav slot, typically SideNav. Inline above the breakpoint, moved into the mobile drawer below it.
Main contentThe default slot, rendered in the main landmark. Scrolls internally when height is fill, and with the page when it is auto.
Mobile nav drawerGenerated below the breakpoint from the nav slots unless mobileNav disables or replaces it. A modal dialog: it traps focus and returns focus to the toggle on close.

Best practices ​

GuidancePractices
DoPut application navigation in the topNav and sideNav slots. Put page regions in Layout.
DoGive the side nav a heading so the mobile drawer has a name.
Don'tOpen a second drawer from TopNav while it is inside an AppShell. The shell already owns that drawer.
Don'tCall useAppShellMobile and assume a shell is present. Check isMobileNavEnabled.

Examples ​

Content only

Skip to content

Page Content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

A shell with no navigation, for a full-bleed page, an auth screen, or an embedded view.

Side nav only

Skip to content

Page Content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

The side nav heading carries the app identity, so a top nav is unnecessary.

Top nav only

Skip to content

Page Content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

A top nav and no side navigation, for a landing page.

Top nav with side nav

Skip to content

Page Content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

The usual frame: a top nav for the app, and a side nav for the pages.

With banner

Skip to content

Page Content

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris.

Top nav, side nav, and a dismissable info banner between the navigation and the content.