Live Preview and Source
Interactive preview
UI·Your next page is taking shape...
Opening Your Next Page…
Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.
Made for Preact. Built to be yours.
Layout Block
Separate the application’s frame from the page without introducing a second theme. An inset content surface gives projects, settings and dashboards a clear boundary while the navigation remains part of the surrounding workspace. Supply navigationGroups and breadcrumbs, then render your pages through children. Routing and Account Actions Stay in Your App. Explore the working preview, copy the complete source bundle and follow the integration guide below. More about this block.
Interactive preview
Copy the Complete Composition. This block is editable Preact source. Its variant entrypoint chooses the layout; shared helpers own the responsive frame and the established navigation behavior.
Copy all files from the Code Tab into src/components/application-shell, preserving the displayed folders. The application-shell-2 folder, shared folder and the application-shell-1 navigation helpers form one source bundle. The helpers do not require mounting Shell 1.
For production, omit application-shell-2/preview.tsx, shared/preview.tsx, shared/preview-data.ts and the demo logo at application-shell-1/assets/kamod-ui-logo.svg. Keep the remaining files and the repository’s License Notice. The blocks package is private: copy the source instead of attempting to install @kamod-ch/blocks/application-shell/application-shell-2 from npm. If you already copied another new shell, reuse matching shared helpers and review local changes before replacing them.
Install only missing dependencies in the application workspace. The menu adapters require Kamod’s useDropdown, portaled DropdownContent and createRovingFocus export from @kamod-ch/ui/lib/interactive. Verify those APIs in your installed UI release.
pnpm add @kamod-ch/ui @kamod-ch/icons @kamod-ch/themes preact @preact/signalsUse the project’s existing Tailwind CSS setup. Import the theme once, ensure Tailwind scans copied files and the installed UI package, then verify a focused control and a sidebar surface in both color modes. The public entrypoint contains no preview data.
src/styles.css·4 lines@import "tailwindcss";
@import "@kamod-ch/themes/theme.css";
/* Add the UI source path documented for your project’s layout. */src/App.tsx·1 lineimport { ApplicationShell2 } from "./components/application-shell/application-shell-2";Continue with Render and Connect the Shell. If the first render is unstyled, follow Source Discovery before adding local color overrides.
Give the Frame Real Data; Keep Services in Your App. Supply the four required props—brand, navigationGroups, user and breadcrumbs—then place the route’s content inside the shell. It already provides main.
src/App.tsx·24 linesimport { Button } from "@kamod-ch/ui";
import { ApplicationShell2, type ApplicationShell2Props } from "./components/application-shell/application-shell-2";
type WorkspaceProps = Pick<ApplicationShell2Props,
"currentPath" | "onNavigate" | "onUserAction">;
export function Workspace(props: WorkspaceProps) {
return (
<ApplicationShell2
{...props}
brand={{ name: "Kamod UI", description: "Team workspace", href: "/workspace" }}
navigationGroups={[{ id: "workspace", label: "Workspace", items: [
{ id: "overview", label: "Overview", href: "/workspace" },
{ id: "settings", label: "Settings", href: "/settings" },
] }]}
user={{ name: "Alex Morgan", email: "alex@example.com" }}
breadcrumbs={[{ label: "Workspace", href: "/workspace" }, { label: "Overview" }]}
headerActions={<Button href="/help" variant="outline" size="sm">Help</Button>}
>
<h1 class="text-2xl font-semibold">Overview</h1>
<p class="mt-2 text-muted-foreground">Your route content belongs here.</p>
</ApplicationShell2>
);
}The example accepts routing and account callbacks from its parent. Ordinary links work without onNavigate. If your router intercepts navigation, preserve modified clicks and call preventDefault() only for the primary clicks it handles. Keep currentPath synchronized with the actual route and supply an explicit active flag when exact URL matching is insufficient.
Replace the sample identity with account data from your session layer. onUserAction reports account, billing, notifications or logout; none of these operations is implemented by the shell. A hidden navigation link is not an authorization boundary. Your application and service still decide which records and actions are available.
Keep page queries and mutations outside the frame. Pass the current route’s loading, empty, failure and successful content through children. Use Submission and Recovery for saves, and State Ownership when a value appears in more than one panel.
At desktop widths the sidebar starts expanded and can collapse to icons. Below 768px it becomes the existing left-side Sheet; the inset desktop margins disappear so the page keeps the available width. Do not reproduce those margins inside every route.
TypeScriptimport { useState } from "preact/hooks";
import { ApplicationShell2, type ApplicationShell2Props } from "./components/application-shell/application-shell-2";
type WorkspaceProps = Omit<ApplicationShell2Props, "open" | "defaultOpen" | "onOpenChange">;
export function ControlledWorkspace(props: WorkspaceProps) {
const [open, setOpen] = useState(true);
return <ApplicationShell2 {...props} open={open} onOpenChange={setOpen} />;
}A Small, Typed Application Boundary. The variant entrypoint exports ApplicationShell2 and ApplicationShell2Props. Data types reuse the source-backed Shell 1 contracts; the new frame adds a header action slot.
| Prop / type | Description |
|---|---|
brand | Sidebar identity, an optional logo and an optional home or workspace link. |
navigationGroups | Ordered groups of destinations, with at most one level of child links. |
user | Account name and email, with an optional avatar or custom initials. No session is inferred. |
breadcrumbs | Ordered trail; its last entry is noninteractive. Earlier entries hide below 768px. Empty arrays omit the trail. |
children | Page content inside the existing main landmark and padded content area. No placeholder content is inserted. |
currentPath | Exact URL used to match item href values. An item's explicit active value takes precedence; no router or path normalization is applied. |
onNavigate | Handles linked brand, breadcrumb and navigation activation, or a leaf action button. Native links still work without it. |
onUserAction | Receives an account menu selection. Your app implements the resulting navigation or account operation. |
open | Controls desktop expansion: true expands, false collapses to icons. Update this value in onOpenChange to respond to the toggle. |
defaultOpen | Initial desktop expansion: true (expanded). Ignored when open is supplied. Mobile sheet state is independent. |
onOpenChange | Reports requested desktop expansion in either state mode. Mobile visibility does not call this callback. |
class | Additional classes merged onto the outer SidebarProvider wrapper. |
className | Alias for class, merged after it when both are supplied. |
headerActions | Application-owned actions beside the breadcrumb trail. Keep labels compact; the header wraps at narrow widths. |
Navigation groups have stable id values, optional labels and ordered items. Each item has an id and label, optional href, icon, active and disabled, plus at most one level of items. A disabled parent disables its children; absent URLs create action buttons. Supply component references as icons, not already-rendered elements.
See the complete Navigation, Brand, User and Callback Types for individual fields. The authoritative copied definitions live in application-shell-1/types.ts; shared/types.ts extends them. Unknown DOM attributes are not forwarded to the frame.
Inspect This Variant’s Public Entry or read The Shared Frame to see where the layout choices are fixed.
Separate the application’s frame from the page without introducing a second theme. An inset content surface gives projects, settings and dashboards a clear boundary while the navigation remains part of the surrounding workspace.
Choose this composition for a product with several related screens and a stable, grouped navigation model. The visible inset is useful when page content has its own cards or forms: the shell defines the workspace and those components describe individual tasks.
The Sidebar uses its inset variant. SidebarInset supplies the single main landmark and receives the primitive’s desktop margin, rounded corners and surface treatment. The header and the route content remain inside that surface; the brand and account actions stay in the surrounding sidebar.
The layout choice is deliberately small. This excerpt from the Variant Entrypoint selects a composition in ShellFrame. It is implementation context, not an additional component you need to mount.
TypeScriptreturn <ShellFrame {...props} layout="inset" />;One Owner for Each Interaction. The core sidebar owns desktop and mobile visibility; the Menu Adapters own keyboard navigation inside dropdowns; your route owns currentPath, breadcrumbs and data. Keep those boundaries when adapting the copy instead of adding another overlay or a duplicate active-item state.
Start with the working example, then use Component Props to add only the controls this workspace needs. children receives the page, and headerActions receives optional tools such as a save button. Keep draft state in the page or its parent when it must survive navigation.
Use sidebar tokens for the outer frame and background/card token pairs for the route. Keep a consistent content gutter instead of adding a second padded wrapper around every page. Check dense tables and long forms inside the inset, not only a dashboard with short cards.
Use Sidebar Tokens for the frame and Supported Variants and Sizes for its controls. The composition follows the host’s theme; it does not create another provider or persist a separate appearance preference. Pair bg-sidebar with text-sidebar-foreground; use bg-background and text-foreground for the page. Verify those pairs with actual form fields and empty/error states, not only the preview’s filled panels.
Collapse the sidebar, open a nested destination from its icon menu, then expand it again. The route, breadcrumb and draft content should remain intact. On mobile, select a destination and confirm the sheet closes before continuing the task.
Verify the whole navigation journey. Test at 320px, 768px, 1024px and 1440px with light and dark themes, long labels and real page content. Open and close the menu twice, follow a nested destination and exercise the account menu using the keyboard. Confirm focus return after Escape, visible active states and no document-wide horizontal overflow. The preview’s search, selection and action messages are local demonstrations, not backend operations. Use the service integration guidance for callbacks, and responsive state notes for the controls available in this variant.
Use Shell 3 when the page benefits from a compact initial rail, or Shell 4 when a short, flat destination list works better above the content. Compare All Application Shells, then use The Complete Journey Check before shipping your integration.
Turn the working preview into a dependable application boundary. Add one real route and one service-backed action before expanding the navigation. The frame supplies structure; your application owns identity, permissions, records and recovery.
Mount the shell above the changing page. Replacing children should not recreate the sidebar provider on every route. Keep the same component type and avoid a route-dependent key on the shell when users expect their desktop collapse choice to survive. Derive currentPath, breadcrumbs and navigation permissions from the router/session rather than synchronizing another selected-item state.
Use stable IDs for navigation groups and items. Build static navigation outside the component; use useMemo only when its inputs actually change, such as a project ID, locale or permissions. Do not put draft text in those dependencies. Native links remain useful without a router callback; intercept only the clicks your client router handles and preserve modified clicks for opening another tab.
Keep the final breadcrumb descriptive and noninteractive. Pass an empty trail for pages that do not need one. Each shell already supplies a main landmark: start page content with its heading or a section, not a second nested main. Review State Ownership before moving values into global state.
Cancel work when its owning route changes. The shell does not fetch records or install polling timers. A page that fetches project data should release its request, subscription or observer when it unmounts or changes record. Keep pending and error states next to the action that creates them, and update a saved baseline only after the server confirms the write.
This effect belongs in a route component with projectId, setProject and setError supplied by that page. Import useEffect from preact/hooks. The cancellation guard prevents an obsolete response from replacing a newer project:
TypeScriptuseEffect(() => {
const request = new AbortController();
async function loadProject() {
try {
const response = await fetch("/api/projects/" + encodeURIComponent(projectId), {
signal: request.signal,
});
if (!response.ok) throw new Error("Project could not be loaded.");
const project = await response.json();
if (!request.signal.aborted) setProject(project);
} catch (error) {
if (!request.signal.aborted) setError(error);
}
}
void loadProject();
return () => request.abort();
}, [projectId]);Validate returned data at your service boundary. Clear the previous error and choose whether to keep stale content or display a loading state when the route changes. Aborting a browser request does not undo a server-side mutation; use your service’s retry and deduplication policy for saves. See Submission and Recovery for preserving edits after a failed submission.
Test a real journey, from opening a page to saving a change. These checks belong to your integrated application: the shell supplies the frame, while your router, forms and services supply the behavior. Work through the steps once, then repeat the journey at the sizes and settings below.
For example: open a project, change its name, save it and return to the overview. Use realistic records and a test account with limited access as well as a full-access account.
320 · 768 · 1024 · 1440pxOpen a nested destination, refresh that page, then use the browser’s Back and Forward buttons. Collapse and expand the desktop sidebar. On mobile, open the menu and choose a destination. Connect these actions through your router and navigation data.
The URL, page heading, active link and breadcrumbs agree. A direct link opens the correct page, selecting a mobile destination closes the sheet, and an unavailable destination does not navigate or run an action.
Put the pointer aside. Use Tab and Shift + Tab to reach the sidebar toggle, links and account menu. Use arrow keys inside the menu, then press Escape. Repeat with the mobile sheet and check the page with a screen reader.
Focus is visible and follows a sensible order. Controls announce useful names and their expanded state. Closing a menu or sheet with Escape returns focus to its trigger. After navigation, your app makes the new page heading discoverable.
Try the screen sizes above with a long page title, translated navigation labels and a wide table. Switch between light and dark, then zoom the browser to 200%. Review Layout and Styling if content spills outside the frame.
Text remains readable and controls stay reachable. The document does not scroll sideways; a wide table or editor scrolls inside its own area. Long names remain understandable, and text, focus rings and active items stay clear in both modes.
Type a draft, toggle the sidebar and open the account menu before saving. If your page has an inspector or another dismissible panel, close and reopen it. Decide separately what should happen when users leave the route.
Shell controls do not erase a page’s draft. State that must survive an unmounted panel lives above that panel. Navigation follows your app’s save, discard or confirmation policy; the shell does not persist drafts for you.
Try a slow request, an empty result, a failed save and an account without access. Give each case a clear message and a useful next action. Follow the submission and recovery guide when connecting a real form.
Loading eventually resolves to content or an explanation. Failed saves preserve edits and offer a safe retry. Empty pages explain how to get started. Your service checks permissions even when a navigation item is hidden.
In a production build, record a route change and a short typing session with realistic data using the browser’s performance tools. Switch records while a request is pending, then leave and revisit the page. Inspect the request and cleanup boundaries.
Typing and navigation stay responsive. An old response cannot overwrite the new record, and timers, listeners and subscriptions stop when their owner leaves. Paginate or virtualize long lists when measurements show a need; keep layout in CSS where possible.
Record the build or commit, browser, screen size and result in your release notes. For a failure, include the steps, expected behavior and a screenshot or short recording. Fix and repeat that check before calling the journey ready.
Keep the copied shell source and local changes under version control. Compare updates before replacing shared helpers, and rerun the affected checks when routing, permissions or layout change. Turn repeatable failures into focused automated tests; keep a manual keyboard and visual pass as well.
An Original Kamod Composition. This variant builds on the repository’s existing sidebar and account-menu helpers. It is not presented as a numbered port of an external design collection.
The reusable entrypoint is src/components/application-shell/application-shell-2/index.ts after copying. Compare the Repository Source with your installed UI version when an API differs. Keep a note of local layout changes and preserve the repository license when sharing a copy.
Start from the Working Integration, adjust one boundary at a time, and verify the result inside your actual application. Return to the Block Setup Guide for source ownership, routing and production checks.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Return to Bring a Complete Layout into Your App to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.