Modal
Description
The Modal component provides a temporary overlay window that can be used to display contextual information or gather user input. It is ideal for presenting dialogs, alerts, or small interactive forms within your application. The Modal belongs to the Surfaces group and offers both blocking and non-blocking modes, light dismiss behavior, customizable headers and footers, and various styling options.
Usage
Instantiate a Modal using the Tesserae.UI helper methods. You can optionally pass in a header component. The Modal supports chaining configuration methods such as adding a footer, enabling light dismiss, adjusting dimensions, and more.
API reference
public sealed class Modal : Layer<Modal>, ISpecialCaseStyling, IHasBackgroundColorA modal overlay surface that dims the page and centers arbitrary content, with optional header, footer and close button.
Constructors
Properties
public bool AnimateOnShow { get ; set ; }Gets or sets the animate on show.
public HTMLElement StylingContainerGets or sets the styling container.
public bool PropagateToStackItemParentGets or sets the propagate to stack item parent.
public string Background { get ; set ; }Gets or sets the CSS background of the component.
public override IComponent Content { get ; set ; }Sets the content rendered inside the surface.
public bool CanLightDismiss { get ; set ; }Gets or sets a value indicating whether the surface can be dismissed by clicking outside it (light dismiss).
public bool IsDark { get ; set ; }Gets or sets a value indicating whether the component uses the dark colour theme.
public bool IsDraggable { get ; set ; }Gets or sets a value indicating whether the component can be dragged by the user.
public bool IsNonBlocking { get ; set ; }Gets or sets a value indicating whether the surface is non-blocking (allows interaction with the page beneath it).
Methods
public Modal SetHeaderCommands(params IComponent[] commands)Sets the header commands of the component.
public Modal SetLeftHeaderCommands(params IComponent[] commands)Sets the left header commands of the component.
public Modal ContentHeight(UnitSize height)Sets the height of the inner content area of the surface.
public Modal NoContentPadding()Removes / disables the content padding on the component.
public Modal LightDismiss()Enables light-dismiss behaviour (clicking outside the surface closes it).
public Modal NoLightDismiss()Removes / disables the light dismiss on the component.
public Modal NonBlocking()Makes the surface non-blocking, allowing interaction with the page beneath it.
public Modal Blocking()Makes the surface blocking (the default — interaction with the page beneath is prevented).
public void ShowAt(UnitSize fromTop = null, UnitSize fromLeft = null, UnitSize fromRight = null, UnitSize fromBottom = null)Shows the at.
public Modal OnHide(OnHideHandler onHide)Registers a callback invoked when the hide event fires.
public Modal OnShow(OnShowHandler onShow)Registers a callback invoked when the show event fires.
public void RaiseOnHide()Internal helper that raises the hide event for this surface.
Samples
Basic Modal Example
This sample demonstrates creating a simple modal with a header, a footer, and centered content. It showcases how to enable light dismiss and display the modal with default settings.
Positioned and Async Modal
This sample shows how to display a modal at custom screen positions and use the asynchronous show method to perform actions after the modal is hidden.
See also
- Dialog – For quick user decision making.
- Panel – For side-surface interactions.
- Float – For floating panels and tooltips.