# Connect pages with NavigationShell

Give a small app a home screen and a few destinations. `NavigationShell` provides the shared structure so your page classes can stay about their content.

<div class="docs-demo-layout">

```csharp
using Xui.Core.UI;
using Xui.ToolKit.UI.Branding;
using Xui.ToolKit.UI.Design;
using Xui.ToolKit.UI.Navigation;
using Xui.ToolKit.UI.Widgets;

public sealed class PagesExample : Border
{
    public PagesExample()
    {
        Content = new DesignSystemView(new NavigationShell("Field notes", new XuiLogoView(), [new("Notebook", "Notebook", () => new NotebookPage()), new("About", "About", () => new Label { Text = "A place for small discoveries.", FontFamily = "Inter", FontSize = 16, Margin = 24 })], desktop: false));
    }

    private sealed class NotebookPage : VerticalStack
    {
        public NotebookPage()
        {
            Margin = 24;
            var count = 0;
            var note = new Label
            {
                Text = "No notes yet.",
                FontFamily = "Inter",
                FontSize = 18,
                Margin = 8
            };
            Add(note);
            Add(new Button { Text = "Add a note", Margin = 8, Clicked = () => note.Text = $"Notes: {++count}" });
        }
    }
}
```

<figure class="docs-demo" data-demo-url="../../../wasm/?embed=1&amp;demo=navigation/pages">
<div class="docs-demo-stage">
<img src="navigation-pages.svg" width="400" height="600" alt="Connect pages with NavigationShell: initial rendered view" />
<button type="button" class="docs-demo-start" hidden><span class="docs-demo-pill">Start demo</span></button>
</div>
<div class="docs-demo-actions">
<button type="button" class="docs-demo-close" hidden>Close demo</button>
<span class="docs-demo-status" role="status" aria-live="polite"></span>
</div>
<figcaption>Connect pages with NavigationShell · <a href="navigation-pages.cs">C# source</a> · <a href="navigation-pages.svg">SVG</a> · <a href="../../../wasm/?embed=1&amp;demo=navigation/pages">Open demo</a></figcaption>
</figure>

</div>


## Describe destinations once

Each `NavigationItem` contains three values: an ID used by code, a title shown to the reader, and a factory that creates its view. Use unique, nonempty IDs. The shell reserves `Home`; duplicate IDs fail during construction.

The example's `Notebook` ID stays useful even if you rename the visible title to “My notes.” Keep routes stable so tests and application actions do not depend on display wording.

Factories must return fresh, unattached views. They can close over application services or a data model, but must not return one shared view instance that is already parented elsewhere.

## Choose a presentation

The constructor's `desktop` argument selects a persistent sidebar or a mobile home-and-push experience. This choice is made when the shell is constructed. It is not a responsive breakpoint that changes automatically when the window narrows.

The starter derives the choice from `IDeviceInfo.FormFactor`. The example sets `desktop: false` explicitly so you can practice the home screen and Back action in a small frame. Set it to `true` locally to inspect the sidebar and page-state retention.

If you need to choose based on available width, own that decision in a higher-level adaptive host and preserve the application model when replacing shells. Do not assume the stock shell automatically morphs between modes.

## Open a destination from code

Keep a reference to the shell and call `shell.Navigate("Notebook")`. `Navigate` expects a registered ID; validate external input before using it as a route. The initial visible destination is Home. To start on a page, navigate after constructing the shell.

On mobile, an in-progress transition ignores another navigation request. On desktop, opening a destination creates it on first use and retains it for later selections. These differences affect where you store unsaved edits; [Page state and lifetime](../page-lifetime/index.md) covers them.

Use this shell for a short, clear menu. A deep navigation hierarchy, route parameters, or a compact icon rail requires additional app-owned navigation behavior.
