Skip to Content

App shell and page header

Build the app shell with AppShell (menu per role, account, sign-out) and the top of each page with PageContainer (title, status, summary, key number, decision buttons).

The shell is what users see on every page after sign-in: logo, menu, account. The page header says where they are and what they can do. Both are props of Pro components, with no CSS of your own.

ProLayout app shellApp shell: ProLayout mix + 3-level grouped menu + 9-dot app launcher + header icons + avatar.
example.manh.run · sample dataOpen in editor ↗
The example runs when you scroll to it

Where it sits in the app tree

The shell is AppShell from manh/shell, placed in app/layout.tsx. Sign-in and sign-up pages render without it.

app/ ├── layout.tsx AppShell: menu, roles, signed-in user ├── theme.tsx primary color, radius, dark mode ├── login/page.tsx public page, no shell └── requests/page.tsx page inside the shell, starts with PageContainer

Build the shell with AppShell

app/layout.tsx only says what goes in the shell. Menu per role, sign-out, Vietnamese locale and theme come with AppShell.

app/layout.tsx
import { AppShell } from "manh/shell"; import { DashboardOutlined, FileTextOutlined, TeamOutlined } from "@ant-design/icons"; import { getUser, signOut } from "app/hooks"; import { APP_THEME } from "app/theme"; const MENU = [ { path: "/", name: "Overview", icon: <DashboardOutlined /> }, { path: "/requests", name: "Requests", icon: <FileTextOutlined /> }, { path: "/users", name: "Users", icon: <TeamOutlined />, roles: ["admin"] }, ]; export default function RootLayout() { return ( <AppShell appName="Purchase approvals" menu={MENU} roleLabels={{ admin: "Admin", staff: "Staff" }} user={getUser()} onSignOut={signOut} theme={APP_THEME} /> ); }
  • roles hides an item from users without that role. A menu group is { name, icon, children: [...] }.
  • count: () => number shows the work waiting next to a menu item, refreshed on every page change.
  • A detail page like /requests/12 still highlights Requests. Signed-out users are sent to /login.

Skip the shell on public pages

/login and /register have no shell. List other public pages, such as a booking form or an order lookup, in publicPaths. Their API sets export const access = "public".

app/layout.tsx
const PUBLIC_PATHS = ["/login", "/register", "/booking"]; <AppShell /* … */ publicPaths={PUBLIC_PATHS} />

For a whole public branch of paths, use isPublic={(p) => p.startsWith("/lookup")}.

Build your own shell with ProLayout

For a first-level menu in the top bar or a nine-dot app launcher, replace AppShell with your own ProLayout.

app/components/shell.tsx
<ProLayout layout="mix" splitMenus // level 1 in the top bar, levels 2–3 on the left siderMenuType="group" // level 2 becomes group titles, level 3 items menu={{ collapsedShowGroupTitle: true, locale: false }} route={{ path: "/", children: [ { path: "/ops", name: "Operations", icon: <AppstoreOutlined />, children: [ { path: "/ops/orders", name: "Orders", children: [{ path: "/ops/orders/all", name: "All orders" }] }, ] }, ] }} appList={[ // nine-dot button next to the logo { title: "Internal", desc: "Company apps", children: [ { title: "CRM", desc: "Customers and deals", icon: <TeamOutlined />, url: "https://crm.example.com", target: "_blank" }, ] }, ]} menuFooterRender={(p) => (p?.collapsed ? undefined : <div>v1.0</div>)} location={{ pathname }} menuItemRender={(item, dom) => <a onClick={() => item.path && nav(item.path)}>{dom}</a>} />
  • menuItemRender and location are required: without them, menu clicks don’t navigate and no item is highlighted.

  • appList: items with children render as titled groups. When every item has desc, the launcher shows large cards; otherwise it shows a compact icon grid.

  • splitMenus only makes sense with layout="mix". The active top-bar item comes from location.pathname.

  • breakpoint (default lg) collapses the left menu automatically; to control it yourself, use collapsed + onCollapse.

Page header with PageContainer

Every page inside the shell starts with PageContainer. Put each element in its own slot:

app/requests/[id:int]/page.tsx
<PageContainer header={{ title: r.title, breadcrumb: { items: [{ title: <a onClick={() => nav("/requests")}>Requests</a> }, { title: `#${r.id}` }] }, tags: <Tag color="processing">Pending</Tag>, extra: <FlowActions flow={RequestFlow} record={r} labels={RequestStatus} move={move} onDone={refresh} />, }} content={<ProDescriptions column={{ xs: 1, sm: 2, lg: 4 }}>{/* 3–4 key facts */}</ProDescriptions>} extraContent={<Statistic title="Requested amount" value={vnd(r.amount)} />} // the one number that matters > {/* … */} </PageContainer>
  • content is the summary strip under the title; extraContent holds 1–3 right-aligned numbers.
  • header.extra holds the status buttons. FlowActions shows only the moves the signed-in user may make (see Detail pages).
  • Pages with several aspects (info, history, related): tabList + tabActiveKey + onTabChange.
  • Dashboards: title is a greeting, subTitle is the to-do count (“2 requests are waiting for your approval”), and extra holds one primary button.

Good to know

  • Don’t use onBack on PageContainer, because the page crashes. Use header.breadcrumb.
  • Don’t hand-build Layout.Sider + Menu, don’t override .ant-pro-* classes, and don’t ship SettingDrawer.
  • Shell colors come from app/theme.tsx. In your own shell, use the ProLayout token, not typed color codes.

Next steps

Last updated