Component to display message-boxes.

HxMessageBox is a standalone component you can use in very specific cases.

Usually you use the message box by using the IHxMessageBoxService injected service.


ShowAsync result: None
Confirm result:

You should place the HxMessageBoxHost component to MainLayout.razor (or App.razor) to make it work!

@inherits LayoutComponentBase

<HxMessageBoxHost />


Register required services using services.AddHxMessageBoxHost() from Startup.cs (Blazor Server) or Program.cs (Blazor WebAssembly).

public void ConfigureServices(IServiceCollection services)
	// ...
	// ...



Name Type Description
Title string Title text (Header).
TitleTemplate RenderFragment Title template (Header).
Text string Content (body) text.
ContentTemplate RenderFragment Content (body) template.
ShowCloseButton bool Indicates whether to show close button.
Buttons MessageBoxButtons Buttons to show. Default is MessageBoxButtons.Ok.
PrimaryButton MessageBoxButtons? Primary button (if you want to override the default).
CustomButtonText string Text for MessageBoxButtons.Custom.
CssClass string Additional CSS class.

Event Callbacks

Name Type Description
OnClosed EventCallback<MessageBoxButtons> Raised when the message box gets closed. Returns the button clicked.


Method Returns Description
ShowAsync() Task Displays the message box.


Displays message boxes initiated through IHxMessageBoxService. To be placed in root application component / main layout.


An unhandled error has occurred. Reload 🗙