App shell
BetaBeta — the props contract is close to final, but small breaking changes can still land.The application container: persistent navigation, header, and screen-corner chrome around changing page content, with one shared scroll policy.
The outlined area is the AppShell container. Collapse the sidebar or toggle loading: the frame stays in place while page content changes. This embedded preview uses layout="contained"; a full application uses the default viewport layout.
Examples
Collapsed sidebar
Start the sidebar as icons with defaultOpen={false} when the shell is narrow, so the page keeps its width until someone expands the navigation.
Screen corners
Pin chrome to the corners of the shell. The corners stay put when the sidebar collapses; while it is open, the start corners span its column and the column starts and ends between them.
Composition
Persistent application frame
AppShell includes SidebarProvider. Set scroll once: page uses the document, inset lets PageLayout scroll, and none lets workspace panes own scrolling. Keep the shell mounted while route content loads.
- <AppShell>
- <Sidebar>
- <SidebarContent />
- <SidebarRail />
- <AppShellContent>
- <AppShellHeader>
- <SidebarTrigger />
- <PageLayout>
- <PageHeader>
- <PageTitle />
- <PageBody>
- route content
- <PageHeader>
- <AppShellHeader>
- <Sidebar>
Screen corners
Each AppShellCorner pins a tab of chrome to one screen corner, and the skin paints it. Corners stay visible when the sidebar collapses. While the sidebar is open, the start corners span its column and the column sits between them. Place corners in the DOM where they belong in the tab order. Hide one below the sidebar breakpoint with className when the page has no room for it.
- <AppShell>
- placement="top-start"
- <AppShellCorner>
- <SidebarTrigger />
- <AppShellCorner>
- placement="top-end"
- <AppShellCorner />
- <Sidebar>
- <SidebarContent />
- <AppShellContent>
- route content
- placement="bottom-start"
- <AppShellCorner />
- placement="bottom-end"
- <AppShellCorner />
- placement="top-start"
Installation
The Control UI source installs this component from src/registry/sources/control-ui/ui/app-shell.tsx.
npx shadcn@latest add https://control-ui.dev/r/app-shell.jsonDependencies
Raw code
Primary installed source
"use client";
import type { ComponentProps, CSSProperties } from "react";import type { AppShellCornerKnobStyle } from "@/components/control-ui/knob-contracts/app-shell-corner-knobs";import type { AppShellHeaderKnobStyle } from "@/components/control-ui/knob-contracts/app-shell-header-knobs";import { cn } from "@/components/control-ui/lib/cn";import { type PageScroll, PageScrollContext, usePageScroll } from "@/components/control-ui/ui/page-layout";import { SidebarInset, type SidebarInsetProps, SidebarProvider, type SidebarProviderProps, useSidebar,} from "@/components/control-ui/ui/sidebar";
export type AppShellProps = SidebarProviderProps & { scroll?: PageScroll };
export function AppShell({ scroll = "auto", layout = "viewport", className, ...props }: AppShellProps) { const resolvedScroll = usePageScroll(scroll); return ( <PageScrollContext.Provider value={resolvedScroll}> <SidebarProvider data-app-shell="" data-scroll={resolvedScroll} layout={layout} className={cn(layout === "viewport" && (resolvedScroll === "page" ? "min-h-dvh" : "h-dvh min-h-0 overflow-hidden"), className)} {...props} /> </PageScrollContext.Provider> );}
export function AppShellContent({ className, ...props }: SidebarInsetProps) { const scroll = usePageScroll(); return <SidebarInset data-app-shell-content="" className={cn("min-h-0", scroll !== "page" && "overflow-hidden", className)} {...props} />;}
export type AppShellHeaderProps = Omit<ComponentProps<"header">, "style"> & { style?: CSSProperties & AppShellHeaderKnobStyle;};
export function AppShellHeader({ className, ...props }: AppShellHeaderProps) { return ( <header data-control-ui="app-shell" data-control-family="app-shell-header" data-slot="root" className={cn("sticky top-0 z-(--z-nav) flex shrink-0 items-center gap-2", className)} {...props} /> );}
export const appShellCornerPlacements = ["top-start", "top-end", "bottom-start", "bottom-end"] as const;
export type AppShellCornerPlacement = (typeof appShellCornerPlacements)[number];
export type AppShellCornerProps = Omit<ComponentProps<"div">, "style"> & { placement: AppShellCornerPlacement; style?: CSSProperties & AppShellCornerKnobStyle;};
export function AppShellCorner({ placement, className, ...props }: AppShellCornerProps) { const { layout } = useSidebar(); return ( <div data-control-ui="app-shell" data-control-family="app-shell-corner" data-slot="corner" data-placement={placement} className={cn(layout === "contained" ? "absolute" : "fixed", "z-(--z-nav) flex items-center", className)} {...props} /> );}
Knobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
| Knob | Syntax | Default |
|---|---|---|
--cui-app-shell-corner-size | <length-percentage> | calc(var(--control-h-md) + var(--spacing) * 3) |
--cui-app-shell-corner-inset | <length-percentage> | 0px |
--cui-app-shell-corner-padding-inline | <length-percentage> | calc(var(--spacing) * 2) |
--cui-app-shell-corner-gap | <length-percentage> | calc(var(--spacing) * 2) |
--cui-app-shell-corner-background | <color> | var(--sidebar) |
--cui-app-shell-corner-background-image | * | none |
--cui-app-shell-corner-foreground | <color> | var(--sidebar-foreground) |
--cui-app-shell-corner-border-color | <color> | var(--sidebar-border) |
--cui-app-shell-corner-border-width | <length> | 1px |
--cui-app-shell-corner-radius | <length-percentage> | min(var(--radius-panel), calc(var(--cui-app-shell-corner-size) / 2)) |
--cui-app-shell-corner-shadow | * | 0 0 transparent |
--cui-app-shell-corner-backdrop-filter | * | none |
| Knob | Syntax | Default |
|---|---|---|
--cui-app-shell-header-height | <length-percentage> | calc(var(--spacing) * 14) |
--cui-app-shell-header-padding-inline | <length-percentage> | calc(var(--spacing) * 4) |
--cui-app-shell-header-background | <color> | var(--background) |
--cui-app-shell-header-border-color | <color> | var(--border) |
--cui-app-shell-header-border-width | <length> | 1px |