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


Interactive Live Preview
Try it. Make it yours.

Variant 3 of 8

Live Preview and Source

Open
Setting the scene...

Interactive preview

Add This Block

One download. One working screen. Start with an existing Preact app; the prepared folder includes the shell and every helper it needs. Add it to your project, check the two prerequisites below, then paste the example. You can customize it afterward.

  1. Download and Add the Folder

    Download and unzip the block. Move the extracted application-shell folder into src/components. Keep the folder together; its internal imports are ready to use.

    Download Shell 3
    Check the location

    src/components/application-shell/application-shell-3/index.ts. The archive leaves out demo files, so there is nothing to clean up. If you already have an application-shell folder, compare its files before merging to keep your customizations. The Code Tab remains available when you want to inspect the implementation.

  2. Check Your Dependencies

    Already using Kamod? Keep your installed packages and check that the dependencies below are present. Otherwise, run the command in your app’s folder using your usual package manager.

    Show the install command
    Install PackagesTerminal
    pnpm add @kamod-ch/ui @kamod-ch/icons @kamod-ch/themes preact @preact/signals

    Use a UI release that includes useDropdown, the portal prop on DropdownContent, and createRovingFocus from @kamod-ch/ui/lib/interactive. An error about these exports means the installed UI release needs updating. The shell itself is local source, not a separate npm package to install.

  3. Check Your Styles

    If Kamod components already look correct in your app, go straight to the working example. Otherwise, connect Tailwind and the theme once before rendering the shell.

    Set up styles for the first time

    Follow the CSS Setup Guide to connect Tailwind CSS v4 to your build. For a stylesheet at src/styles.cssand dependencies in your app’s node_modules, use:

    src/styles.css5 lines
    @import "tailwindcss";
    @import "@kamod-ch/themes/theme.css";
    
    @source "../node_modules/@kamod-ch/ui/dist/**/*.{js,mjs}";
    @source "./components/application-shell";

    Import this stylesheet from your app’s entry file with import "./styles.css". Keep existing theme imports instead of adding duplicates. Source paths are relative to the stylesheet; adjust them for a different folder layout. Starting without an app? The Getting Started Guide covers that foundation.

Your First Working Screen

Get the first screen running before connecting services. This example supplies the shell’s required data and a single Home destination. It needs no router adapter or state wrapper.

Paste the Example

In a new app, use this as src/App.tsx and render Appfrom your existing entry file. In an existing app, use it as a layout example and keep your current pages. The sample assumes the app’s Home page is at /.

src/App.tsx20 lines
import { HouseIcon } from "@kamod-ch/icons/lucide";
import { ApplicationShell3 } from "./components/application-shell/application-shell-3";

export default function App() {
  return (
    <ApplicationShell3
      brand={{ name: "Kamod UI", description: "My workspace" }}
      navigationGroups={[{
        id: "workspace",
        items: [{ id: "home", label: "Home", href: "/", icon: HouseIcon }],
      }]}
      user={{ name: "Alex Morgan", email: "alex@example.com" }}
      breadcrumbs={[{ label: "Home" }]}
      currentPath="/"
    >
      <h1 class="text-2xl font-semibold">Your workspace is ready</h1>
      <p class="mt-2 text-muted-foreground">Build your first page here.</p>
    </ApplicationShell3>
  );
}
Your first checkpoint

A compact icon rail should appear beside the page. Use the header toggle to expand the labels. On a small screen, the same control opens a navigation sheet. If the layout looks unstyled, return to the styles step. The account menu opens, but its actions remain inactive until you connect them below.

Make It Yours

Make three small changes to the example, in this order. You can leave the shell’s internal files alone.

Give it your identity
Replace brand with your workspace name and user with the signed-in person. The shell creates initials automatically; a logo and avatar are optional.
Put your page inside
Replace the sample heading and paragraph with your content. Keep one shell around your pages; it already provides the main landmark and page padding.
Add your real destinations
Add items to navigationGroups with a stable id, a short label, a real href and a recognizable icon. Update currentPath and breadcrumbs for the current page. Ordinary links work without a callback.
When you’re ready: routing and account actions

With a client router, pass its current route to currentPath and connect its navigation function through onNavigate. The shared navigation example preserves open-in-new-tab and other browser shortcuts. Breadcrumbs are supplied by your app, not generated from the navigation tree.

Connect onUserAction to your account, billing, notifications and sign-out handlers. It reports account, billing, notificationsor logout; opening or selecting the menu alone does not perform those actions. Keep authentication and permission checks in your app.

For nested destinations, custom header controls and typed data, continue to Props and Data.

Try the Navigation

The compact rail is already the default. Let the built-in toggle manage it while you build your page. Add defaultOpen={true} only if you want labels visible on the first desktop render. Mobile navigation opens separately and always includes labels.

Before moving on, try the toggle, a navigation link and keyboard focus at desktop and mobile widths. You now have a reusable frame for the rest of your app. If you later need to remember the desktop state, follow the controlled state and persistence guide; it uses the same open and onOpenChange contract.

Props and Data

A Small, Typed Application Boundary. The variant entrypoint exports ApplicationShell3 and ApplicationShell3Props. Data types reuse the source-backed Shell 1 contracts; the new frame adds a header action slot.

Component Props

ApplicationShell3 props
Prop / typeDescription
brand
ApplicationShellBrand
Sidebar identity, an optional logo and an optional home or workspace link.
navigationGroups
readonly ApplicationShellNavigationGroup[]
Ordered groups of destinations, with at most one level of child links.
user
ApplicationShellUser
Account name and email, with an optional avatar or custom initials. No session is inferred.
breadcrumbs
readonly ApplicationShellDestination[]
Ordered trail; its last entry is noninteractive. Earlier entries hide below 768px. Empty arrays omit the trail.
children
ComponentChildren
Page content inside the existing main landmark and padded content area. No placeholder content is inserted.
currentPath
string
Exact URL used to match item href values. An item's explicit active value takes precedence; no router or path normalization is applied.
onNavigate
ApplicationShellNavigate
Handles linked brand, breadcrumb and navigation activation, or a leaf action button. Native links still work without it.
onUserAction
(action: ApplicationShellUserAction) => void
Receives an account menu selection. Your app implements the resulting navigation or account operation.
open
boolean
Controls desktop expansion: true expands, false collapses to icons. Update this value in onOpenChange to respond to the toggle.
defaultOpen
boolean
Initial desktop expansion: false (icon rail). Ignored when open is supplied. Mobile sheet state is independent.
onOpenChange
(open: boolean) => void
Reports requested desktop expansion in either state mode. Mobile visibility does not call this callback.
class
string
Additional classes merged onto the outer SidebarProvider wrapper.
className
string
Alias for class, merged after it when both are supplied.
headerActions
ComponentChildren
Application-owned actions beside the breadcrumb trail. Keep labels compact; the header wraps at narrow widths.

Data Contracts

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.

About the Compact Navigation Rail

Give the page most of the available width from the first render. The shell begins with a compact icon rail, while every destination retains a label through tooltips, accessible names and the expanded navigation view.

When to Choose It

Choose the rail for frequent users moving between a familiar set of tools, especially editors, deployment consoles and data-heavy pages. Keep an expanded alternative available when names are unfamiliar or several destinations have similar icons.

Composition

The same SidebarProvider and nested-menu adapters used by Shell 1 own interaction. This composition changes the initial desktop expansion to false. Collapsed branches use portaled menus so the navigation’s scroll container cannot cut off their destinations.

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.

Usage PatternTypeScript
return <ShellFrame {...props} layout="rail" />;

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.

Appearance

Choose a recognizable icon for each primary destination and keep the same icon family. The core sidebar controls rail width; avoid setting a separate width on the content to compensate. Use supported size and variant props inside the page rather than shrinking all controls to match the rail.

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.

Verify the Journey

Open the Library branch with the keyboard while collapsed, move between its menu items and dismiss it with Escape. Verify focus returns to the branch trigger. Then test an expanded branch and a mobile destination; each presentation must reach the same location.

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 2 for a more visible navigation hierarchy, or Shell 6 when the task also needs contextual information beside its main working area. Compare All Application Shells, then use The Complete Journey Check before shipping your integration.

Prepare for Production

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.

Routes and State Ownership

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.

Requests and Cleanup

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:

Usage PatternTypeScript
useEffect(() => {
  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.

Release Checks

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.

Start with one real journey

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.

Screen widths
320 · 768 · 1024 · 1440px
Appearance
Light + dark · your app’s theme
Content
Long labels · empty + busy pages
  1. Follow the route

    Try this

    Open 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.

    Looks right when

    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.

  2. Take the keyboard route

    Try this

    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.

    Looks right when

    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.

  3. Give the layout a stretch

    Try this

    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.

    Looks right when

    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.

  4. Keep unfinished work safe

    Try this

    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.

    Looks right when

    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.

  5. Make the unhappy paths useful

    Try this

    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.

    Looks right when

    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.

  6. Check the work behind the screen

    Try this

    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.

    Looks right when

    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.

Leave a trail for the next release

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.

Source and Next Steps

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-3/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.

Take the Next Useful Step

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.

Connect the Foundation

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.

Build the Surrounding Screen

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.

Make the Result Hold Up

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.