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.

General

Use visible control whether Modal is displayed.

Preview
See code

With useModal

Use hooks for easier control Modal.

Preview
See code

Without Actions

Hide all action buttons.

Preview
See code

Disable Action

Disable one of the buttons.

Preview
See code

Customized

Custom width or className.

Preview
See code

Loading

You can use loading in Modal.Action with the property loading.

Preview
See code

Overlong

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

Preview
See code

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
}
Edit this page on GitHub

Previous

Loading

Next

Note

MADE & DESIGNED WITHBY BRUNO ANDRADE
docs background gradient blue
docs background gradient violet