Skip to content

App shell ​

AppShell arranges a Topbar, a Sidebar, and the main content for a typical application frame. On large screens the sidebar is docked beside the content; below the lg breakpoint collapsible (the default) turns it into an off-canvas panel that Topbar opens with a toggle button. The three parts share state through a Vue injection context, so you place the slots and the wiring is automatic.

vue
<script setup lang="ts">
import { AppShell, Sidebar, Topbar } from '@myghf/ui'
</script>

<template>
  <AppShell>
    <template #topbar><Topbar>My app</Topbar></template>
    <template #sidebar><Sidebar><!-- navigation --></Sidebar></template>
    <!-- main content -->
  </AppShell>
</template>

Examples ​

The preview is bounded to a fixed height; in an app the shell fills the viewport.

vue
<script setup lang="ts">
import { AppShell, Sidebar, Topbar } from '@myghf/ui'

const links = ['Dashboard', 'Patients', 'Appointments', 'Settings']
</script>

<template>
  <div class="h-72 overflow-hidden rounded-lg border border-border">
    <AppShell class="h-full !min-h-0">
      <template #topbar>
        <Topbar><span class="text-sm font-semibold text-foreground">MYGHF</span></Topbar>
      </template>

      <template #sidebar>
        <Sidebar>
          <ul class="grid gap-1 p-3 text-sm">
            <li v-for="link in links" :key="link">
              <a
                href="#"
                class="block rounded px-2 py-1.5 text-muted transition-colors hover:bg-surface-muted hover:text-foreground"
                >{{ link }}</a
              >
            </li>
          </ul>
        </Sidebar>
      </template>

      <div class="p-4 text-sm text-muted">Main content</div>
    </AppShell>
  </div>
</template>

AppShell ​

Slots: topbar, sidebar, default (the main region).

PropTypeDefaultDescription
collapsiblebooleantrueCollapse the sidebar off-canvas below the lg breakpoint.

Renders the navigation landmark. Docked at a fixed width on lg; below lg (when the shell is collapsible) it slides in from the inline start.

PropTypeDefaultDescription
labelstring'Sidebar'Accessible name for the nav landmark.
widthstring'16rem'Docked width when not collapsible (or used standalone).

Topbar ​

Renders the header bar. When it is inside a collapsible AppShell it shows a menu button (visible below lg) that opens and closes the sidebar.

PropTypeDefaultDescription
labelstring'Toggle navigation'Accessible name for the menu button.

Accessibility ​

  • Sidebar is a nav with an aria-label; Topbar is a header. Give each landmark a distinct label if you add more of them.
  • The menu button is a real <button> with aria-expanded reflecting the open state and aria-controls pointing at the sidebar's id, so its state and target are announced.
  • Opening the sidebar shows a backdrop and enables Esc to close it; clicking the backdrop also closes it. The off-canvas panel is only rendered when relevant, so keyboard focus never lands on an invisible sidebar.

Dark mode & RTL ​

  • The shell, topbar, and sidebar use semantic tokens (bg-background, bg-surface, border-border), so they adapt to dark mode automatically.
  • The panel is anchored with logical start-0 and border-e, and its off-canvas offset is -translate-x-full in LTR with an rtl:translate-x-full counterpart, so it slides from the correct edge under dir="rtl".

Released under the MIT License.