Overlay Service
Open dialogs, sheets, drawers, and alert dialogs programmatically from C# code and await their results.
Quick Start
The OverlayService lets you open overlays imperatively
instead of declaring them in markup. Every method returns a
Task<OverlayResult> so you can
await the user's response and read back data they entered.
OverlayProvider is already included in the default Lumeo layout.
If you are using a custom layout, make sure to add it as shown in step 1.
Step 1 — Add the provider to your layout
Place <OverlayProvider /> once in your root layout.
It renders all active overlays.
Step 2 — Create a content component
Your content component receives an OverlayReference via
[CascadingParameter].
Call Overlay.Close(data) to return a result, or
Overlay.Cancel() to dismiss without returning data.
Step 3 — Open from code
Inject OverlayService and call one of its
Show*Async methods. The call awaits until
the user closes or cancels the overlay.
Dialog
Opens a centered modal dialog with your component as the body content. The dialog includes a title bar and close button by default.
Live Demo
Sheet
Opens a panel that slides in from any edge of the screen. Use sheets for secondary navigation, settings panels, detail views, or any content that should overlay from a specific direction.
Slide from any side
Sheet sizes
The SheetSize enum controls the width (for left/right) or
height (for top/bottom) of the sheet panel.
| Size | Description |
|---|---|
| Sm | Small — narrow panel for simple content |
| Default | Standard width — good for forms and settings |
| Lg | Large — for detail views and complex content |
| Xl | Extra large — for data tables or wide layouts |
| Full | Full width/height — covers the entire edge |
Drawer
Opens a bottom drawer, ideal for mobile-friendly interactions. Drawers slide up from the bottom of the viewport and are commonly used for action menus, date pickers, or compact forms.
Live Demo
Alert Dialog
A simple confirm/cancel dialog that requires no custom component. Pass an
AlertDialogOptions object to configure the title,
description, button text, and whether the action is destructive.
Confirm action (non-destructive)
Standard confirmation before saving or performing a significant action.
Destructive action (red confirm button)
Use IsDestructive = true to render the confirm button
with destructive styling, signaling an irreversible action.
Passing Parameters
Use OverlayParameters to pass data into your content
component. The fluent .Add() API chains
cleanly and parameters are fed to Blazor's
DynamicComponent, so they map directly to
[Parameter] properties on your component.
Building parameters (caller side)
Receiving parameters (content component)
Each key in OverlayParameters maps to a
[Parameter] property with the same name. You can also
access raw parameters through the OverlayReference.Parameters property.
Getting Results
Every Show*Async method returns a
Task<OverlayResult>. The task completes when the
user closes or cancels the overlay. Check
result.Cancelled to determine which action was taken.
Returning data from Close()
Inside your content component, call Overlay.Close(data)
to pass any object back to the caller. The data is available on
result.Data (as
object?) or via the typed helper
result.GetData<T>().
Reading the result (caller side)
Full round-trip example
This shows the complete flow: open an overlay, let the user fill a form, close it, and read the result.
Options & Customization
All overlay methods accept an optional OverlayOptions record
to control behavior and appearance.
PreventClose
Set PreventClose = true to prevent the overlay from
being dismissed by clicking outside or pressing Escape. The user must explicitly click a button
inside your content component to close the overlay.
Live Demo — PreventClose
Try clicking outside the dialog or pressing Escape. It won't close until you use a button.
Custom CSS Class
Use the Class property to add Tailwind utility classes
to the overlay container. This is especially useful for controlling width.
SheetSide and SheetSize
For sheets, SheetSide and
SheetSize are passed as direct parameters to
ShowSheetAsync. They are also available on
OverlayOptions for advanced scenarios.
Content Component Pattern
Every component rendered inside an overlay receives an
OverlayReference as a
[CascadingParameter].
This is the component's handle to control the overlay it lives in.
Complete content component example
Overlay.Parameters?.Get<int>("TeamId")
if you prefer not to declare [Parameter] properties.
API Reference
OverlayService Methods
6 methods
| Method | Returns | Description |
|---|---|---|
| ShowDialogAsync<T>(title?, parameters?, options?) | Task<OverlayResult> | Opens a centered modal dialog with component T as the body. |
| ShowSheetAsync<T>(title?, side, size, parameters?, options?) | Task<OverlayResult> | Opens a slide-in panel from the specified edge with component T. |
| ShowDrawerAsync<T>(title?, parameters?, options?) | Task<OverlayResult> | Opens a bottom drawer with component T. |
| ShowAlertDialogAsync(AlertDialogOptions) | Task<OverlayResult> | Shows a built-in confirm/cancel alert dialog. No custom component needed. |
| Close(overlayId, result?) | void | Closes a specific overlay by ID and returns data. Typically called internally via OverlayReference.Close(). |
| Cancel(overlayId) | void | Cancels a specific overlay by ID. Typically called internally via OverlayReference.Cancel(). |
OverlayResult
Returned by all Show*Async methods when the overlay closes.
| Member | Type | Description |
|---|---|---|
| Cancelled | bool | true when the user dismissed the overlay without confirming (clicked Cancel, backdrop, or pressed Escape). |
| Data | object? | The raw value passed to Overlay.Close(data). Null when cancelled or closed without data. |
| GetData<T>() | T? | Attempts to cast Data to type T. Returns default if the cast fails. |
Static factory methods:
OverlayResult.Ok(data?) and
OverlayResult.CancelResult().
OverlayReference
Cascaded into every content component. This is how your component communicates with the overlay it lives in.
| Member | Type | Description |
|---|---|---|
| Id | string | Unique identifier for this overlay instance. |
| Parameters | OverlayParameters? | The parameters passed when the overlay was opened. Use .Get<T>(name) to read values. |
| Close(result?) | void | Close the overlay and return data to the caller. Pass any object as the result. |
| Cancel() | void | Dismiss the overlay without returning data. Sets Cancelled = true on the result. |
OverlayParameters
Fluent builder for passing named values to content components.
| Method | Returns | Description |
|---|---|---|
| Add(string name, object value) | OverlayParameters | Adds a named parameter. Returns this for chaining. |
| Get<T>(string name) | T? | Retrieves a parameter by name, cast to T. Returns default if not found or wrong type. |
| ToDictionary() | Dictionary<string, object> | Converts all parameters to a dictionary. Used internally by the overlay provider. |
OverlayOptions
Record type that controls overlay appearance and behavior.
| Property | Type | Default | Description |
|---|---|---|---|
| Class | string? | null | Additional CSS classes applied to the overlay container (e.g., max-w-2xl). |
| PreventClose | bool | false | When true, prevents dismissal via backdrop click or Escape key. |
| SheetSide | SheetSide | Right | Which edge the sheet slides in from. Set automatically by ShowSheetAsync. |
| SheetSize | SheetSize | Default | Width (left/right) or height (top/bottom) of the sheet. Set automatically by ShowSheetAsync. |
AlertDialogOptions
Record type that configures the built-in alert dialog.
| Property | Type | Default | Description |
|---|---|---|---|
| Title | string | "Are you sure?" | The heading text displayed at the top of the alert dialog. |
| Description | string? | null | Optional body text explaining the action or its consequences. |
| ConfirmText | string | "Continue" | Label for the confirm/action button. |
| CancelText | string | "Cancel" | Label for the cancel/dismiss button. |
| IsDestructive | bool | false | When true, the confirm button renders with destructive styling (red). |
SheetSide Enum
| Value | Description |
|---|---|
| Top | Slides down from the top of the viewport. |
| Right | Slides in from the right edge. Default value. |
| Bottom | Slides up from the bottom of the viewport. |
| Left | Slides in from the left edge. |
SheetSize Enum
| Value | Description |
|---|---|
| Sm | Small — compact panel for simple content. |
| Default | Standard size — suitable for most forms and settings panels. |
| Lg | Large — for detail views and complex content. |
| Xl | Extra large — for data tables or wide layouts. |
| Full | Full width or height — covers the entire edge of the viewport. |