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.

Code Editor

With useModal

Use hooks for easier control Modal.

Code Editor

Without Actions

Hide all action buttons.

Code Editor

Disable Action

Disable one of the buttons.

Code Editor

Customizable

Custom width or className.

Code Editor

Loading

Code Editor

Overlong

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

Code Editor

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
}

Geist is an open source project from the community.

And is powered by Netlify.