Modal

Display popup content that requires attention or provides additional information. If you just need to prompt for a text message, try component Toast.

The Modal contain an additional Hooks, see subsection useModal for details.

Basic

Use visible control whether Modal is displayed.

With useModal

Use hooks for easier control Modal.

Without Actions

Hide all action buttons.

Disable Action

Disable one of the buttons.

Customizable

Custom width or className.

Loading

Overlong

Whether it is desktop or mobile, the content beyond the scope has been well handled.

APIs

Modal.Props

AttributeDescriptionTypeAccepted valuesDefault
visibleopen or closeboolean-false
onCloseopen event() => void--
onContentClickevent from modal content(e: MouseEvent) => void--
wrapClassNameclassName of the modal dialogstring--
keyboardpress Esc to close modalboolean-true
disableBackdropClickclick background and don't closeboolean-false
...native propsHTMLAttributes'autoFocus', 'name', 'className', ...-

Modal.Title.Props

AttributeDescriptionTypeAccepted valuesDefault
...native propsHTMLAttributes'id', 'className', ...-

Modal.Subtitle.Props

AttributeDescriptionTypeAccepted valuesDefault
...native propsHTMLAttributes'id', 'className', ...-

Modal.Content.Props

AttributeDescriptionTypeAccepted valuesDefault
...native propsHTMLAttributes'id', 'className', ...-

Modal.Action.Props

AttributeDescriptionTypeAccepted valuesDefault
passivedisplay passive modeboolean-false
disableddisable current actionboolean-false
onClickclick handler(e: ModalActionEvent) => void--
loadingshow loadingboolean-false
...native propsButtonHTMLAttributes'id', 'className', ...-

useModal

type useModal = (initialVisible: boolean) => {
  visible: boolean
  setVisible: Dispatch<SetStateAction<boolean>>
  currentRef: MutableRefObject<boolean>
  bindings: {
    visible: boolean
    onClose: () => void
  }
}

ModalActionEvent

type ModalActionEvent = MouseEvent<HTMLButtonElement> & {
  close: () => void
}