App Frame

View as Markdown

The frame every app shares: a sidebar of links that becomes a drawer on a phone, a header row with breadcrumbs and actions, and an optional rail, tabs, side panel and status bar.

No projects yet

Projects you create or join show here.

When to use

The frame every app shares: a sidebar of links that becomes a drawer on a phone, a header row with breadcrumbs and actions, and an optional rail, tabs, side panel and status bar. Use App Shell instead when you lay out the regions yourself, without the sidebar's links and header row.

Usage

import { AppFrame, PageBar } from "./ui/uicontext/components/AppFrame.ts"
export const Frame = <M>(h: Html.H<M>, current: string, page: View.Content<M>) =>	AppFrame(h, {		app: { name: "Northwind", mark: "N", href: "/" },		agentId: "app",		sections: [{ items: [{ id: "inbox", label: "Inbox", href: "/inbox", icon: "inbox" }, { id: "projects", label: "Projects", href: "/projects", icon: "folder" }] }],		current,		main: [PageBar(h, { trail: [{ label: "Northwind", href: "/" }, { label: "Projects" }] }), page],	})

API reference

AppFrameView function

Options

AppFrame options
NameTypeDescription
apprequired{ readonly name: string; readonly mark: string; readonly href: string }—
agentIdrequiredstringThe shell's agent id, unique on the page
sectionsrequiredFrameSection[]—
currentrequiredstringThe id of the link for the current route
account{ readonly name: string; readonly meta: string }Who's signed in, at the foot of the sidebar; leave it out when the rail shows them
sidebarTopView.InputA control above the links: a "New issue" button, a search
sidebarHeaderView.InputIn place of the brand at the top of the sidebar: a workspace switcher
sidebarView.InputIn place of the route links: a list of records
mainrequiredView.Input—
mainLabelstringThe main region's accessible name: the page or tab it shows
panel{ readonly open: boolean; readonly label: string; readonly content: View.Input; readonly closed: Message; readonly toggled?: Message | undefined /** false: the panel draws its own header and close button */ readonly header?: boolean | undefined }An end panel: an assistant, a detail rail; toggled answers ⌘.
railView.InputThe far-start rail: a WorkspaceRail
tabsView.InputDocument tabs over the page: a TabStrip
statusView.InputThe bottom strip: a StatusBar
storageKeystringKeeps the frame's widths and the sidebar's state in this browser, under this key
shortcutsShellShortcut[]The app's own shortcuts, listed under the frame's on ⌘/
sidebarIdstringThe sidebar's id, when every page draws its button in its own header (PageBar's sidebarId): a phone then gets no row of its own for the button

PageBarView function

Options

PageBar options
NameTypeDescription
trailrequiredCrumb[]—
actionsView.Input—
sidebarIdstringThe frame's sidebar, when it is a drawer on a phone: its button leads this row instead of a row of its own

Keyboard and accessibility

  • The page sits in a main landmark named by mainLabel, and the sidebar is a nav named for the app.
  • The link for current is aria-current="page". PageBar's breadcrumbs are a nav named Breadcrumb, and the separators are hidden from screen readers.
  • On a phone the sidebar is a drawer that closes with Escape or a press outside; ⌘. toggles the side panel.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/app-frame

Source