Getting started
Add the headless brain, register its services, mount the outlets, then drop primitives in and style them yourself. Works in any Blazor host: WebAssembly, Server, Blazor Web App, and MAUI Blazor.
- 01
Install the brain
Reference the
Navius.Primitivespackage, the headless primitives and their JavaScript engine. The engine asset is served automatically from the package's static web assets at_content/Navius.Primitives/navius-interop.js.dotnet add package Navius.Primitives --prerelease - 02
Register the services
In
Program.cs, callAddNavius()to register the portal registry and the toast queue.builder.Services.AddNavius(); - 03
Mount the outlets
Near your app root, mount a single portal outlet (for overlays that teleport out of clipping ancestors) and, if you use toasts, a manager-driven toast provider + viewport region.
<NaviusPortalOutlet /> @* If you use toasts, mount a provider + viewport region: *@ <NaviusToastProvider Manager="@Toasts"> <NaviusToastViewport /> </NaviusToastProvider> - 04
Bring your own styles
The brain ships no CSS. Style the primitives however you like (Tailwind utilities, plain CSS, CSS modules) keyed off the
data-*contract. See Styling. Prefer a ready-made styled layer? Use zits/ui..my-switch { background: #d4d4d8; border-radius: 9999px; } .my-switch[data-checked] { background: #18181b; } - 05
Use a primitive
Add a
@usingfor the component's namespace and compose it from its parts.@using Navius.Primitives.Components.Switch <NaviusSwitch @bind-Checked="_on" class="my-switch"> <NaviusSwitchThumb class="my-thumb" /> </NaviusSwitch> @code { private bool _on; }
That's it: browse the components, or read how the engine works.