Overlay
Low-level backdrop primitive for custom popovers and modals.
When to Use
- Open a
Dialog,Sheet, orDrawerprogrammatically from any service or handler — without managing open/closed state locally. - Show confirmation dialogs from deeply nested components or event handlers.
- Create wizard flows where each step is a separate Blazor component loaded into an overlay.
Setup required: Add
<OverlayProvider /> once near the root of your app layout (e.g. MainLayout.razor) and register OverlayService in DI.
Result: —
Confirmed: —
Setup
Register the service and add the provider to your layout:
// Program.cs
builder.Services.AddScoped<OverlayService>();
// MainLayout.razor
<OverlayProvider />API Reference
OverlayService
| Method | Returns | Description |
|---|---|---|
| ShowDialogAsync<TComponent>(title?, parameters?, options?) | Task<OverlayResult> | Opens a Dialog overlay containing TComponent. Awaitable — resolves when closed. |
| ShowSheetAsync<TComponent>(title?, side?, size?, parameters?, options?) | Task<OverlayResult> | Opens a Sheet overlay. Default side is Right. |
| ShowDrawerAsync<TComponent>(title?, parameters?, options?) | Task<OverlayResult> | Opens a Drawer overlay (slide-up). |
| ShowAlertDialogAsync(alertOptions) | Task<OverlayResult> | Opens a confirmation AlertDialog with configurable title, description, and button labels. |
| Close(overlayId, result?) | void | Closes an overlay and resolves its task with an OK result. |
| Cancel(overlayId) | void | Closes an overlay and resolves its task as cancelled. |
OverlayResult
| Property | Type | Description |
|---|---|---|
| Cancelled | bool | True when the overlay was dismissed without confirmation. |
| Data | object? | Optional return value passed to Close(id, result). |
Related Components
- Dialog — Modal dialog for direct template-based usage.
- Sheet — Slide-in panel for direct template-based usage.
- AlertDialog — Confirmation modal for destructive actions.
- Drawer — Mobile-first slide-up sheet.