Learn about the Modal component for use in UI extensions.
Modal
component to render a pop-up overlay containing other components. Like the Panel
component, you’ll include the Modal
component in an overlay
prop within a Button, LoadingButton, Link, Tag, or Image component.
To see an example of using overlays, check out HubSpot’s Overlay example project.
To format the modal, you’ll use the following subcomponents:
ModalBody
(required): contains the main content of the modal.ModalFooter
: an optional component to format the footer section of the modal.Prop | Type | Description |
---|---|---|
id | String | The unique identifier for the modal. |
width | 'small' , 'sm' (default) | 'medium' , 'md' | 'large' , 'lg' | The width of the modal. |
title | String | The title of the modal, displayed at in the modal’s top bar. |
variant | 'default' (default) | 'danger' | The type of modal. See the variants section for more information. |
aria-label | String | The modal’s accessibility label. |
onOpen | () => void | A function that will be invoked when the modal has finished opening. |
onClose | () => void | A function that will be invoked when the modal has finished closing. |
Button
, LoadingButton
, Link
, Tag
or Image
with an onClick
event that triggers the closeOverlay
action. To use this action, you’ll need to include the actions argument in hubspot.extend()
as seen in the example code below.
Learn more about opening and closing overlays.
Modal
can be opened from a Panel
, but a Panel
cannot be opened from a Modal
.variant
prop to configure the style of modal.
By default, the modal will include a blue colored top bar where the title
displays.
variant
to 'danger'
.
Modal
or a Panel
.