Dialog

メンテナー:
Alutery
GitHub
children
showError
hasCloseButton
disableOutsideClick
disableEscapeKeyDown
size

Dialog is a modal window with a title, body, and footer actions, used for confirmations, forms, and prompts. It is built on top of Modal.

import {Dialog} from '@gravity-ui/uikit';

Usage

const [open, setOpen] = useState(false);
const dialogTitleId = 'app-confirmation-dialog-title';

<Dialog
  onClose={() => setOpen(false)}
  open={open}
  onEnterKeyDown={() => {
    alert('onEnterKeyDown');
  }}
  aria-labelledby={dialogTitleId}
>
  <Dialog.Header caption="Caption" id={dialogTitleId} />
  <Dialog.Body>Dialog.Body</Dialog.Body>
  <Dialog.Footer
    onClickButtonCancel={() => setOpen(false)}
    onClickButtonApply={() => alert('onApply')}
    textButtonApply="Apply"
    textButtonCancel="Cancel"
  />
</Dialog>;

Properties

NameDescriptionTypeDefault
openCurrent dialog stateboolean
onEscapeKeyDownEscape keydown event handler(event: KeyboardEvent) => void
onEnterKeyDownEnter keydown event handler(event: KeyboardEvent) => void
onOutsideClickEvent handler on a mouse click outside the dialog(event: MouseEvent) => void
onCloseEvent handler on closing the dialog(event: MouseEvent or KeyboardEvent, reason: ModalCloseReason or "closeButtonClick") => void
classNameclassName of the dialog content wrapperstring
modalClassNameclassName of modal box in which the dialog is embeddedstring
sizeDialog size. Deprecated. Use maxWidth + fullWidth to achieve the same result.'s' 'm' 'l'
maxWidthDialog content max width's' 'm' 'l'
fullWidthIf true content stretches to maxWidthboolean
disableBodyScrollLockToggles whether the body scroll is lockedbooleanfalse
disableEscapeKeyDownToggles whether the escape keydown is disabledbooleanfalse
disableOutsideClickToggles whether the outside click is disabledbooleanfalse
keepMountedToggles whether the dialog is kept in the mounted statebooleanfalse
hasCloseButtonToggles whether there is a cross icon in the top-right corner of the dialogbooleantrue
aria-labelledby<Dialog/> caption ID. Use the id property of <Dialog.Header/> to set the ID for captionstring
aria-labelDialog label for a11y. Set aria-labelledby if the caption is visible to the userstring
containerContainer element for the dialog boxHTMLElement
qadata-qa attribute value of the modal box in which the dialog is embeddedstring
contentOverflowDetermines whether the Dialog has a scroll indicator inside or gets larger with the content'visible' 'auto''visible'