This library is still in development and is available only for internal usage at VTEX.
Skip to main content

Modal

Version: 0.135.0

Modal

A Modal (Dialog) is used to represent information that demands attention and/or action from the users, preventing them from interacting with the rest of the page. It follows the WAI-ARIA Dialog (Modal) Pattern.

Composability

The modal is composed by many parts: Modal, ModalHeader, ModalTitle, ModalDismimiss, ModalContent, ModalFooter, and ModalButton.

The main component, responsible for holding the state.

Loading...

Props

Same as div JSX element, and:

NameTypeDescriptionRequiredDefault
stateModalStateReturn of useModalStatenull

ModalHeader

The header gives the modal context, its usually composed by the ModalTitle and ModalDismiss.

Loading...

Props

Same as header JSX element.

ModalTitle

Modal heading component.

Loading...

Props

Same as h1 JSX element.

ModalDismiss

Dismisses the modal.

Loading...

Props

Same as button JSX element.

ModalContent

The ModalContent is the main part of the modal.

Loading...

Props

Same as div JSX element.

ModalFooter

The footer usually contains actions.

Loading...

Props

Same as footer JSX element.

ModalButton

Props

Same as Admin UI Button, and:

NameTypeDescriptionRequiredDefault
dismissModalbooleanIf dismisses the modal on click🚫false

Abstracting

The main reason the modal is composable is to enable abstractions. You can create specific modals using the small pieces admin-ui provides. In the example, you can see a confirmation modal that uses this approach:

Loading...

Styling

Every modal component can receive a className to customize styling.

Loading...