# Core views and ToolKit widgets

Build a small preferences panel with a card, a sound toggle, and a Reset button. Core supplies the layout and text; ToolKit supplies styled controls.

<div class="docs-demo-layout">

```csharp
using Xui.Core.UI;
using Xui.ToolKit.UI.Design;
using Xui.ToolKit.UI.Widgets;

public sealed class WidgetExample : Border
{
    public WidgetExample()
    {
        var status = new Label
        {
            Text = "Sound is off.",
            FontFamily = "Inter",
            FontSize = 18,
            Margin = 8
        };
        var toggle = new Toggle
        {
            Id = "Widgets.Sound",
            Margin = 8,
            Changed = on => status.Text = on ? "Sound is on." : "Sound is off."
        };
        var content = new VerticalStack
        {
            Margin = 24,
            Content = [new Card
            {
                Content = new Label
                {
                    Text = "Make yourself at home.",
                    FontFamily = "Inter",
                    FontSize = 18
                },
                Margin = 8
            }, status, toggle, new Button
            {
                Id = "Widgets.Reset",
                Text = "Reset",
                Variant = ButtonVariant.Outline,
                Margin = 8,
                Clicked = () =>
                {
                    toggle.IsOn = false;
                    status.Text = "Sound is off.";
                }
            }

            ]
        };
        Content = new DesignSystemView(content);
    }
}
```

<figure class="docs-demo" data-demo-url="../../../wasm/?embed=1&amp;demo=controls/widgets">
<div class="docs-demo-stage">
<img src="controls-widgets.svg" width="400" height="600" alt="Core views and ToolKit widgets: 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>Core views and ToolKit widgets · <a href="controls-widgets.cs">C# source</a> · <a href="controls-widgets.svg">SVG</a> · <a href="../../../wasm/?embed=1&amp;demo=controls/widgets">Open demo</a></figcaption>
</figure>

</div>


## Choose the layer that matches the job

Use Core views such as `Label`, `Border`, `ImageView`, `ScrollView`, and layout containers for basic presentation and composition. Use ToolKit widgets when you want shared design tokens and interaction: buttons, cards, toggles, checkboxes, radio buttons, and editable inputs.

Place `DesignSystemView` above ToolKit widgets. It resolves device information and supplies an `IDesignSystem` through the view service chain. Without a provider, a widget may have no useful theme tokens; a reference to the ToolKit assembly alone does not establish a theme.

`Card` combines a themed surface with padding around its content. `Border` is useful when you want explicit colors, border thickness, or padding without a design-system policy.

## Make state visible

`Toggle.Changed` receives the new Boolean state after a user action. The example turns that value into a sentence beside the toggle. This gives feedback beyond the thumb position and color.

The Reset action assigns `IsOn = false` and updates the label explicitly. Do not assume programmatic assignment invokes the user-change callback; model-to-view updates and user actions are distinct paths.

A `Button` exposes `Clicked` and a visible `Text`. `ButtonVariant.Filled` emphasizes a primary action; `Outline` and `Text` reduce emphasis. Use a stable `Id` for tests so a wording change does not change control identity.

## Check the interaction contract

A control that reacts to pointer clicks does not automatically support every keyboard, accessibility, or disabled-state requirement of your product. The current ToolKit button, toggle, and checkbox implementations are pointer-oriented; inspect their focus and key behavior before treating them as fully accessible form controls.

For a larger settings screen, group related choices and make labels describe the outcome. Keep controls large enough to touch, and avoid using color as the only indication of state.

Continue with [Themes and design tokens](../themes/index.md) to apply a consistent visual language and [Accessible interaction](../accessible-interaction/index.md) to evaluate the remaining interaction work.
