Modal

Updated at:

Introduction

Use a modal when a user must complete a task without navigating away from the current page. A modal opens a floating layer in the center of the page to contain the relevant operations and prevent workflow interruptions.

For more information, see Modals and drawers.

Configurations

Category

Configuration

Example

Description

Display area

Header

Specifies whether to show the modal title bar.

Footer

Specifies whether to show the modal action bar at the bottom.

Interaction

Close on mask click

If enabled, clicking the mask triggers the cancel event by default.

Close on ESC

If enabled, pressing the ESC key triggers the cancel event by default.

Animation type

The animation effect when the modal opens or closes. The default effect is scaling.

Destroy child nodes on close

By default, child nodes within the modal are destroyed when it closes. For example, if a modal contains an Image component, destroying child nodes causes the image resource to be re-requested every time the modal opens. If you retain the child nodes, the image resource is requested only the first time the modal opens.

Style

Hide modal

Controls the default visibility of the modal. If set to true, the modal is hidden. This configuration corresponds to the hidden component property. When the show method is called, the hidden state is set to false. When the toggleHidden method is called, the hidden state is inverted.

Size

Sets the display size of the modal. On mobile pages, if the page width is insufficient to display the modal content, the modal width adjusts automatically.

Show mask

Specifies whether to show the mask.

Show Close button

Determines whether the Close button is displayed in the top-left corner of the dialog box.

CSS styles

Background color

The background color of the modal. For more information, see Common properties.

Padding

The padding of the modal. For more information, see Common properties.

Border radius

The border radius of the modal. For more information, see Common properties.

Header background color

The background color of the header area. For more information, see Common properties.

Header margin

The margin of the header area. For more information, see Common properties.

Content area background color

The background color of the content area. For more information, see Common properties.

Content area margin

The margin of the content area. For more information, see Common properties.

Footer background color

The background color of the footer area. For more information, see Common properties.

Bottom margin

The margin of the footer area. For more information, see Common properties.

Close button top margin

The top margin of the Close button relative to the content area.

Close button right margin

The right margin of the Close button relative to the content area.

Properties and methods

Name

Type

Example

Description

hidden

boolean

modalFrame.hidden

Indicates whether the component is hidden.

hide

func

modalFrame.hide()

Hides the modal.

show

func

modalFrame.show()

Shows the modal.

toggleHidden

func

modalFrame.toggleHidden()

Toggles the visibility of the modal.

Event callbacks

Configuration

Description

The event triggered when a user clicks the mask, clicks the Close button, or presses the ESC key. By default, a new modal triggers the hide method.

The event triggered after the modal's show animation is complete.

The event triggered after the modal's close animation is complete.

Scenario example

  • Terms of Service scenario

    • Configuration: Remove the cancel event, which is triggered by clicking the mask, clicking the Close button, or pressing the ESC key. Enable Show mask and disable Show Close button.

    • With this configuration, the user must click either Decline or Agree to proceed. The modal cannot be closed otherwise. You must then write the business logic for these action buttons.