Blocks / App shell

App shell

Sidebar, content and a skip link; at phone width the sidebar folds behind a menu.

import { AppShell, Sidebar, Nav } from "@forgeron/ui";
/01 → Default
Skip to content
Console
Home
import { AppShell, Nav, Sidebar } from "@forgeron/ui";
import { useState } from "react";

// A shell in a narrow frame: the sidebar folds behind the menu button. It starts open here.
export default function Default() {
  const [menuOpen, setMenuOpen] = useState(true);
  return (
    <div style={{ width: 340, height: 220, border: "1px solid var(--line)" }}>
      <AppShell
        frame="box"
        contentId="demo-shell-1"
        menuOpen={menuOpen}
        onMenuToggle={() => setMenuOpen((o) => !o)}
        topbar={<b>Console</b>}
        sidebar={
          <Sidebar header={<b>Maison Roy</b>}>
            <Nav
              label="Main"
              items={[
                { id: "home", label: "Home", href: "#/", current: true },
                { id: "tools", label: "Tools", href: "#/tools" },
                { id: "people", label: "People", href: "#/people" },
              ]}
              onNavigate={() => setMenuOpen(false)}
            />
          </Sidebar>
        }
      >
        <div style={{ padding: 16 }}>Home</div>
      </AppShell>
    </div>
  );
}
/02 → Console
Skip to content
Maison Roy

Home

The workspace at a glance.

Runs today
1,204
up +8%vs yesterday
Failed
3
down −50%vs yesterday
Members
48
import { Home01Icon, PackageIcon, Settings01Icon, UserGroupIcon } from "@forgeron/icons";
import { AppShell, Avatar, Icon, KpiRow, Nav, Page, Sidebar } from "@forgeron/ui";
import { useState } from "react";

const main = [
  { id: "home", label: "Home", href: "#/", icon: Home01Icon },
  { id: "tools", label: "Tools", href: "#/tools", icon: PackageIcon },
  { id: "people", label: "People", href: "#/people", icon: UserGroupIcon },
];
const account = [{ id: "settings", label: "Settings", href: "#/settings", icon: Settings01Icon }];

// A frame of the console: the shell fills its parent here (frame="box"); in an app it fills the
// window. Narrow the window below 640 px of frame and the sidebar folds behind the menu.
export default function Console() {
  const [current, setCurrent] = useState("#/");
  const [menuOpen, setMenuOpen] = useState(false);
  const items = (list: typeof main) =>
    list.map(({ icon, ...item }) => ({
      ...item,
      current: item.href === current,
      icon: <Icon icon={icon} size={12} variant="mono" />,
    }));
  const go = (href: string) => {
    setCurrent(href);
    setMenuOpen(false);
  };
  return (
    <div style={{ width: "100%", height: 420, border: "1px solid var(--line)" }}>
      <AppShell
        frame="box"
        contentId="demo-shell-2"
        menuOpen={menuOpen}
        onMenuToggle={() => setMenuOpen((o) => !o)}
        topbar={<b>Maison Roy</b>}
        sidebar={
          <Sidebar
            header={<b>Maison Roy</b>}
            footer={
              <span style={{ display: "inline-flex", alignItems: "center", gap: 8 }}>
                <Avatar name="Camille Roy" size={20} />
                Camille Roy
              </span>
            }
          >
            <Nav label="Main" items={items(main)} onNavigate={go} />
            <Nav label="Account" heading="Account" items={items(account)} onNavigate={go} />
          </Sidebar>
        }
      >
        <Page title="Home" description="The workspace at a glance.">
          <KpiRow
            items={[
              { label: "Runs today", value: "1,204", delta: 0.08, hint: "vs yesterday" },
              { label: "Failed", value: "3", delta: -0.5, better: "down", hint: "vs yesterday" },
              { label: "Members", value: "48" },
            ]}
          />
        </Page>
      </AppShell>
    </div>
  );
}
API → Props
PropTypeDefaultDescription
sidebarReactNode—Left column: a Sidebar, an AppSidebar.
topbarReactNode—Beside the menu button at phone width.
menuOpen / onMenuToggleboolean / () => void—The folded sidebar, opened by the menu button (phone width).
contentIdstring"content"Where the skip link jumps.
frame"page" | "box""page"Fills the window, or its parent: then it folds by the parent's width.
Nav items{ id, label, href, current?, badge?, icon? }[]—The links; current gets aria-current.
classNamestring—Extra classes.