Open Dialogs
0Dialog IDs
NoneThe DialogProvider manages modal and non-modal dialogs with proper stacking, focus trapping, ESC/backdrop handling, and accessibility features.
Display the current dialog stack status.
Open Dialogs
0Dialog IDs
NoneClick to open a basic modal dialog with title, content, and close button. Modal dialogs trap focus and block interaction with background content.
Opens modal with backdrop
@inject IDialogService DialogService
<FodButton OnClick="@OpenBasicDialog">Open Basic Dialog</FodButton>
@code {
private void OpenBasicDialog()
{
DialogService.Show<BasicDialogContent>(new DialogOptions
{
Title = "Basic Dialog",
CloseOnEsc = true,
CloseOnBackdrop = true,
ShowCloseButton = true
});
}
}Configure dialog behavior with CloseOnEsc and CloseOnBackdrop options.
DialogService.Show<ConfigurableDialogContent>(new DialogOptions
{
Title = "Configurable Dialog",
CloseOnEsc = true, // ESC key closes dialog
CloseOnBackdrop = true, // Backdrop click closes dialog
ShowCloseButton = true // X button shown in header
});Multiple dialogs stack correctly with proper z-index ordering. Only the topmost modal traps focus and responds to ESC/backdrop clicks.
Opens first dialog with nested second
// First dialog can open a second dialog
DialogService.Show<StackedDialogContent1>(new DialogOptions
{
Title = "First Dialog",
CloseOnEsc = true,
CloseOnBackdrop = true
});
// Inside StackedDialogContent1, open second dialog:
DialogService.Show<StackedDialogContent2>(new DialogOptions
{
Title = "Second Dialog (Topmost)"
});Dialogs can return results asynchronously. The ShowAsync method returns a Task of DialogResult.
var result = await DialogService.ShowAsync<ResultDialogContent>(new DialogOptions
{
Title = "Dialog with Result",
CloseOnEsc = false,
CloseOnBackdrop = false,
ShowCloseButton = false
});
if (result.Success)
{
var data = result.Data; // User entered value
}Non-modal dialogs don't block interaction with background content and don't trap focus.
Background remains interactive
DialogService.Show<NonModalDialogContent>(new DialogOptions
{
Title = "Non-Modal Dialog",
Modal = false, // Non-modal - no backdrop
ShowCloseButton = true
});Dialogs can have custom maximum widths using the MaxWidth option.
Small (400px)
Large (800px)
Extra Large (90vw)
DialogService.Show<CustomWidthDialogContent>(new DialogOptions
{
Title = "Custom Width Dialog",
MaxWidth = "800px", // Any valid CSS width value
ShowCloseButton = true
});How to set up and use the Dialog Provider in your application.
// Program.cs
builder.Services.AddFod();<FodProviders>
<Router AppAssembly="@typeof(App).Assembly">
...
</Router>
</FodProviders>@inject IDialogService DialogService
// Open a dialog
var result = await DialogService.ShowAsync<MyDialogComponent>(new DialogOptions
{
Title = "My Dialog",
CloseOnEsc = true,
CloseOnBackdrop = true
});// MyDialogComponent.razor
[Parameter]
public DialogRef? DialogRef { get; set; }
<div>
<p>Dialog content here</p>
<button @onclick="@(() => DialogRef?.Close("success"))">OK</button>
<button @onclick="@(() => DialogRef?.Cancel())">Cancel</button>
</div>Dialogs provide WCAG 2.1 AA compliant accessibility features.
IDialogService methods and DialogOptions properties.