# Build your first page

Build a page that greets the reader with the Xui logo and counts button presses. The first click changes the message; subsequent clicks update the same label.

<div class="docs-demo-layout">

```csharp
using Xui.Core.UI;
using Xui.ToolKit.UI.Branding;
using Xui.ToolKit.UI.Design;
using Xui.ToolKit.UI.Widgets;

public sealed class FirstPage : Border
{
    public FirstPage()
    {
        var count = 0;
        var result = new Label
        {
            Text = "Ready for your first click?",
            FontFamily = "Inter",
            FontSize = 18,
            Margin = 8
        };
        var action = new Button
        {
            Id = "FirstPage.Count",
            Text = "Count a click",
            Margin = 8
        };
        action.Clicked = () => result.Text = $"You clicked {++count} times.";
        Content = new DesignSystemView(new VerticalStack { Margin = 24, Content = [new XuiLogoView { Margin = 24 }, result, action] });
    }
}
```

<figure class="docs-demo" data-demo-url="../../../wasm/?embed=1&amp;demo=first-app/first-page">
<div class="docs-demo-stage">
<img src="first-app-first-page.svg" width="400" height="600" alt="Build your first page: 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>Build your first page · <a href="first-app-first-page.cs">C# source</a> · <a href="first-app-first-page.svg">SVG</a> · <a href="../../../wasm/?embed=1&amp;demo=first-app/first-page">Open demo</a></figcaption>
</figure>

</div>


## Compose the page

`VerticalStack` lays out its children from top to bottom. The logo, label, and button are ordinary views. The stack's margin leaves space around the group; each child's margin separates it from its neighbors.

`DesignSystemView` supplies the ToolKit button with colors, typography, spacing, and shape tokens. Keep a design-system provider above ToolKit widgets. Core `Label` exposes its font and color directly; setting `FontFamily` to Inter matches the font already registered by the starter.

The outer `Border` supplies a single-content container. It does not need a border stroke for this page: containers can organize content without drawing extra decoration.

## Connect an action to state

The local `count` belongs to this page instance. `Clicked` runs when the button recognizes a click. It increments the count and assigns a new `Label.Text` value.

The label's setter requests the layout and rendering work needed for the changed text. You do not need to reconstruct the stack or manually draw the label. For a custom field that changes your own Canvas drawing, you would call `InvalidateRender()` yourself.

The button's `Id` is a stable identifier for inspection and tests. Its visible `Text` is a label for people; changing that label should not require changing a test that locates the control by ID.

## Make it yours

Change the action to add a trail, save a note, or reveal a detail. Keep the interaction's feedback next to the action so the result is obvious. Try replacing the message with a longer sentence, then narrow the window: `Label` currently draws a single line, so it does not wrap long prose automatically.

The count resets when you create a new page instance. Navigation may preserve an existing page or create a new one; [Page state and lifetime](../../navigation/page-lifetime/index.md) explains that choice.

To run this example locally:

```sh
git clone https://github.com/xuiapps/sdk.git
cd sdk
dotnet run --project Xui/Apps/DemoApp/DemoApp.Desktop.csproj -- --demo first-app/first-page
```
