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.
- 16.1 kB JS 7.7 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
No projects yet
Projects you create or join show here.
Keyboard shortcuts
- Show or hide the sidebar
- Command B⌘B
- Show or hide the side panel
- Command .⌘.
- Move to the next region
- F6F6
- Move to the previous region
- Shift F6⇧F6
- Show keyboard shortcuts
- Command /⌘/
This example also uses Empty State. Install it too:
npx shadcn@latest add checkfu/uicontext/empty-stateimport type { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Button } from "./ui/uicontext/components/Button.ts"import { AppFrame, PageBar } from "./ui/uicontext/components/AppFrame.ts"import { EmptyState } from "./ui/uicontext/components/States.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ frame: { inlineSize: "100%", blockSize: 420 } })// a whole small app: the sidebar's links and account, and a page with its header rowexport const SmallApp = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children( AppFrame(h, { app: { name: "Northwind", mark: "N", href: "#" }, agentId: "app-frame-demo", sections: [ { items: [{ id: "inbox", label: "Inbox", href: "#inbox", icon: "inbox", count: 4 }, { id: "projects", label: "Projects", href: "#projects", icon: "folder" }] }, { label: "Teams", items: [{ id: "design", label: "Design", href: "#design", dot: "#8b5cf6" }, { id: "freight", label: "Freight ops", href: "#freight", dot: "#0ea5e9" }] }, ], current: "projects", account: { name: "Ada Okafor", meta: "Northwind Freight" }, main: [ PageBar(h, { trail: [{ label: "Northwind", href: "#" }, { label: "Projects" }], actions: Button(h, { size: "sm" }).children("New project") }), EmptyState(h, { title: "No projects yet", hint: "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
| Name | Type | Description |
|---|---|---|
apprequired | { readonly name: string; readonly mark: string; readonly href: string } | — |
agentIdrequired | string | The shell's agent id, unique on the page |
sectionsrequired | FrameSection[] | — |
currentrequired | string | The 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 |
sidebarTop | View.Input | A control above the links: a "New issue" button, a search |
sidebarHeader | View.Input | In place of the brand at the top of the sidebar: a workspace switcher |
sidebar | View.Input | In place of the route links: a list of records |
mainrequired | View.Input | — |
mainLabel | string | The 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 ⌘. |
rail | View.Input | The far-start rail: a WorkspaceRail |
tabs | View.Input | Document tabs over the page: a TabStrip |
status | View.Input | The bottom strip: a StatusBar |
storageKey | string | Keeps the frame's widths and the sidebar's state in this browser, under this key |
shortcuts | ShellShortcut[] | The app's own shortcuts, listed under the frame's on ⌘/ |
sidebarId | string | The 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
| Name | Type | Description |
|---|---|---|
trailrequired | Crumb[] | — |
actions | View.Input | — |
sidebarId | string | The 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
mainlandmark named bymainLabel, and the sidebar is anavnamed for the app. - The link for
currentisaria-current="page". PageBar's breadcrumbs are anavnamed 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