AstrolUI AstrolUI
Yellow Orange Red Green Blue Purple Custom color
Light mode
Modal

1. Demo AstrolModal

Note
In this example, buttons are implemented, so it is recommended to refer to their documentation for more information.
@using Astrol.Entities.Basic.UI
@using Astrol.Component.Basic.Button
@using Astrol.Component.Basic.Modal
 
<AstrolModal Title="Demo" Status="_statusModal" OnChangeStatus="StatusModal">
   <!-- Content -->
   <h1>Hello World!</h1>
</AstrolModal>
<AstrolButton Text="Open" Style="AstrolStyle.Blue" OnClick="() => StatusModal(true)" />
@code {
   private bool _statusModal = false;
   private void StatusModal(bool newStatus) {
       _statusModal = newStatus;
   }
}

Supported parameters

  • Status (bool), modal visibility. @bind-Status is not supported: update your variable in OnChangeStatus.
  • OnChangeStatus (EventCallback<bool>), raised with false when the modal closes itself (Close button, X, click outside or Esc).
  • Title (string), modal title (also its accessible name).
  • ChildContent (RenderFragment), modal content.
  • Class (string), custom css class.
  • Draggable (bool), can be moved by dragging the header (default true).
  • Resizable (bool), can be resized from the edges (default true).
  • ClosedInteractive (bool), closes when clicking outside the content or pressing Esc (default true).
  • Outline (bool) and OutlineButton (bool), outline style for the modal and the close button (default false).
  • ShowHead (bool), shows the header with title and buttons (default true).
  • BodyPadding (bool), inner spacing of the body so the content does not touch the edges (default true, 16px; change it with the --aui-modal-padding variable). With false the content fills the whole body (tables, images, editors).
  • ShowOptions (bool), shows the bottom bar, where ButtonOption (RenderFragment) and the close button are rendered (default true).
  • ShowButtonClose (bool), Close button visibility (default true).
  • TextClose, TextMaximize, TextRestore (string), button texts (default follows the app language).
  • Width (AstrolWidth), initial max width (default Middle), and WidthMaximize (AstrolWidth?), width when maximized; the maximize button only appears when it is set and differs from Width:
    • AstrolWidth.Mini 300px
    • AstrolWidth.Short 450px
    • AstrolWidth.Middle 768px
    • AstrolWidth.Large 1200px
    • AstrolWidth.Full 100% of the browser
  • OnChangeWidth (EventCallback<AstrolWidth>), raised with the new width when maximizing or restoring.
  • The modal is a native <dialog>: it is always on top, the background page cannot be used while it is open, Esc closes only the top modal and focus returns to the button that opened it.
  • From code, without Status or @ref: await Modal.ShowAsync<MyComponent>("Title", parameters, options) or await Modal.ShowAsync(fragment, "Title", options) with @inject IAstrolModal Modal. The component closes itself with [CascadingParameter] AstrolModalReference and Close(result) or Cancel(). It returns a ModalResult (Cancelled, Data, GetData<T>()).
  • ModalOptions: Width (Middle), WidthMaximize, Draggable (true), Resizable (false), ClosedInteractive (true), ShowHead (true), BodyPadding (true), ShowOptions (true), Outline (modal and button), Class and TextClose.
Markdown for AI © 2026 AstrolUI v10.0.13