Components / Dialog Service

Dialog Service

An imperative dialog store you @inject to await a dialog like a modal function call: if (await Dialog.ConfirmAsync(...)) { ... }. A single ZitsDialogOutlet near the app root renders one ZitsDialog / ZitsAlertDialog per queued entry, so every dialog rides the brain's real focus-trap, scroll-lock, and dismiss-layer lifecycle. Trigger one below. This preview is the real component running in WebAssembly.

Examples

Awaiting an action

razor
@inject ZitsDialogService Dialog

<ZitsButton OnClick="Delete">Delete</ZitsButton>

@code {
    async Task Delete()
    {
        var ok = await Dialog.ConfirmAsync(
            "Delete this item?", "This cannot be undone.",
            new ConfirmOptions(ConfirmLabel: "Delete", Destructive: true));
        if (ok) { /* delete */ }
    }
}

Setup

Register the service once at startup (alongside the brain's AddNavius()), then mount one outlet near the app root.

Program.cs csharp
builder.Services.AddNavius();
builder.Services.AddZitsUi();   // registers ZitsDialogService (scoped)
App root (once) razor
<ZitsDialogOutlet />

Installation

Terminal bash
navius add dialog

API reference

ZitsDialogService (inject it; each call awaits its result):

Prop Type Default
ConfirmAsync (title, description, ConfirmOptions?) Task<bool>
AlertAsync (title, description, AlertOptions?) Task
ShowAsync<T> (RenderFragment<DialogHandle<T>>, DialogOptions?) Task<T?>