Skip to content

Dialog Service

ZitsDialogService is a scoped, @inject-able queue that lets a caller await a dialog like a modal function call (await Dialog.ConfirmAsync(...)). It owns no overlay machinery itself: a single <ZitsDialogOutlet /> mounted near the app root renders one ZitsDialog (custom content) or ZitsAlertDialog (confirm/alert) per queued entry, so every dialog rides the same focus-trap/scroll-lock/portal lifecycle those wrappers already get from the composed NaviusDialog primitive. The service implements the queue, resolution, and controlled-open wiring; it composes ZitsDialog/ZitsAlertDialog (themselves NaviusDialog wrappers) rather than a primitive directly.

Terminal window
navius add dialog-service --to ./src/MyApp --namespace MyApp.Ui
@inject ZitsDialogService Dialog
<ZitsButton Variant="outline" OnClick="ConfirmAsync">Delete item</ZitsButton>
<ZitsDialogOutlet />
@code {
private async Task ConfirmAsync()
{
var ok = await Dialog.ConfirmAsync(
"Delete this item?",
"This action cannot be undone.",
new ConfirmOptions(ConfirmLabel: "Delete", Destructive: true));
}
}

ZitsDialogService is a service, not a component; it has no render parameters. Its public surface:

Member Signature Description
ConfirmAsync (string title, string description, ConfirmOptions?) -> Task<bool> Shows a confirm dialog over ZitsAlertDialog; resolves true on confirm, false on cancel/Escape.
AlertAsync (string title, string description, AlertOptions?) -> Task Shows an acknowledge-only dialog over ZitsAlertDialog; resolves on dismiss.
ShowAsync<T> (RenderFragment<DialogHandle<T>>, DialogOptions?) -> Task<T?> Shows arbitrary content over ZitsDialog; the content calls handle.Close(result)/handle.Cancel(). Dismissing via Escape/outside resolves default.

ZitsDialogOutlet takes no parameters; it renders the service’s Entries and must be mounted once (like a toast viewport).

The outlet composes the existing ZitsAlertDialog/ZitsDialog content wrappers (ZitsAlertDialogHeader/Title/Description/Footer, ZitsDialogContent) verbatim, so their normal styling surface applies; the service itself adds no classes.

Part Attribute Description
Confirm action data-destructive Present when ConfirmOptions.Destructive is true; a styling passthrough, not primitive-emitted.
Confirm/cancel/OK actions data-testid dialog-confirm / dialog-cancel / dialog-ok, fixed test hooks the outlet renders for CI to target.