Blazorise Modal Provider API
Review the provider component and service methods used to create and manage modal instances.
For setup instructions and examples, see the Modal Provider documentation.
API
Parameters
| Parameter | Default | Type |
|---|---|---|
Animated | true | bool |
Determines whether the component has any animations. Global Option. | ||
AnimationDuration | 150 | int |
Specifies the animation duration. Global Option. | ||
Centered | false | bool |
Centers the modal vertically. Only considered if UseModalStructure is set. | ||
FocusTrap | true | bool? |
Specifies if the modal should keep the input focus at all times. Global Option. When unspecified, uses BlazoriseOptions.ModalFocusTrap, falling back to true. | ||
ProviderName | — | string |
Defines the provider name used by IModalService. When null or empty, this provider is used as the default provider. | ||
RenderMode | ModalRenderMode.Default | ModalRenderMode |
Specifies how the modal content will be rendered. Global Option. Possible values: DefaultLazyLoadLazyReload | ||
Scrollable | false | bool |
Scrolls the modal content independent of the page itself. Only considered if UseModalStructure is set. | ||
ScrollToTop | true | bool |
If true modal will scroll to top when opened. Global Option. | ||
ShowBackdrop | true | bool |
Specifies the backdrop needs to be rendered for this Modal. Global Option. | ||
Size | ModalSize.Default | ModalSize |
Changes the size of the modal. Possible values: DefaultSmallLargeExtraLargeFullscreenOnly considered if UseModalStructure is set. | ||
Stateful | false | bool |
Keeps the ModalInstance in memory after it has been closed. Defaults to false. | ||
UseModalStructure | true | bool |
Uses the modal standard structure, by setting this to true you are only in charge of providing the custom content. Defaults to true. Global Option. | ||
Events
| Event | Type |
|---|---|
Closed | EventCallback |
Occurs after the modal has closed. Global Option. | |
Closing | Func<ModalClosingEventArgs, Task> |
Occurs before the modal is closed. Global Option. | |
Opened | EventCallback |
Occurs after the modal has opened. Global Option. | |
Opening | Func<ModalOpeningEventArgs, Task> |
Occurs before the modal is opened. Global Option. | |
ModalProvider properties
Properties
| Property | Type |
|---|---|
TopMost | ModalInstance |
Gets the most recently activated visible modal instance, or null when no modal is visible.
| |
IModalService
Properties
| Property | Type |
|---|---|
ModalProvider | ModalProvider |
Gets the default provider that manages modal instances.
| |
Methods
| Method | Return | Parameters |
|---|---|---|
SetModalProvider | void | ModalProvider modalProvider |
Sets the default modal provider.
| ||
RegisterModalProvider | void | string providerName, ModalProvider modalProvider |
Registers a named provider, or the default provider when the name is empty.
| ||
UnregisterModalProvider | void | string providerName, ModalProvider modalProvider |
Unregisters a named or default provider.
| ||
Show<TComponent> | Task<ModalInstance> | title, parameters, options (depending on overload) |
Shows a component in a modal. Overloads support a title, component parameters, and instance options.
| ||
Show | Task<ModalInstance> | component type or RenderFragment, with optional title and options |
Shows dynamically selected component content or a render fragment.
| ||
Show | Task | ModalInstance modalInstance |
Reopens an existing modal instance.
| ||
Hide | Task | provider name or ModalInstance (optional) |
Hides the latest modal, a modal from a named provider, or a specific instance.
| ||
GetInstances | IEnumerable<ModalInstance> | — |
Returns the modal instances managed by the default provider.
| ||
Remove | Task | ModalInstance modalInstance |
Removes a modal instance from its provider.
| ||
Reset | Task | — |
Clears the modal provider state and its tracked instances.
| ||