Exit Prompt

Shows a confirmation dialog when the user tries to navigate away.

Rendered in 0 ms
Usage

Prevent accidental navigation loss by showing a confirmation when users leave a page. Use Disabled to enable protection conditionally, and UseNativePrompt to choose between MudBlazor and browser-native prompts.

Test navigation
<MudExitPrompt Disabled="_isDisabled" UseNativePrompt="_useNativePrompt"/>

<MudStack Spacing="2">
    <MudSwitch Label="Disabled" @bind-Value="_isDisabled" Color="Color.Primary"/>
    <MudSwitch Label="Use native prompt" @bind-Value="_useNativePrompt" Color="Color.Primary"/>
    <MudButton Variant="Variant.Outlined" Color="Color.Primary" Href="/components/exitprompt">Test navigation</MudButton>
</MudStack>
@code {
    private bool _isDisabled;
    private bool _useNativePrompt;
}
An unhandled error has occurred. Reload 🗙