Modal Buttons

Buttons and actions for modals

Modals have an optional stack of buttons on the bottom of the page. They are sticky, and the content (sections) will scroll under the top button if too tall.

Buttons are not required.

Button Actions

By default all buttons dismiss the modal, and only dismiss the modal.

To add another action, you can specify an actionName which can fire any other CriticalMoments action, including a deep link to trigger native code in your app.

To prevent a button from dismissing the modal when tapped set the preventDefault option on the config.

If no buttons are included, or all have preventDefault set, be careful not to set showCloseButton=false on the modal or the user won't be able to dismiss the modal!

Button Parameters

  • title [string, required]: The title of the button

  • style [string, optional]: One of styles described below. If omitted, defaults to normal.

  • actionName [string, optional]: If specified, the action by this name will be triggered when this button is tapped. Can be used to make the

  • preventDefault [bool, optional, default false]: prevents the button's default action. In the case of modals, this prevents the modal from being dismissed. ActionName is not impacted by this parameter.

Button Styles

The following styles are available. The color is derived from the primaryColor of the theme for this content (in this case, systemPurple).

Valid values are: "large", "normal", "secondary", "tertiary", "info", "info-small".

Sample Config

Here is a sample config for a style=secondary button which launches a web link action, and does not dismiss the modal when tapped.

{
    "title": "More info",
    "preventDefault": true,
    "style": "secondary",
    "actionName": "web_link_action"
}

Automatic Button Events

Button taps are tracked as events by default. See Modal Built-In Events for details.

Last updated