Skip to Content
Patternfly Logo

Modal

Modals load and display important information without navigating away from the current page. The user cannot perform other actions until the modal is dismissed. Related design guidelines: Modal

ExamplesPropsCSS Variables

Examples

Basic

With description

Small

Large

Width

No header

Props

Modal properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesContent rendered inside the Modal.
classNamestringNo''Additional classes added to the Modal
isOpenbooleanNofalseFlag to show the modal
headerReact.ReactNodeNoComplex header (more than just text), supersedes title for header content
titlestringYesSimple text content of the Modal Header, also used for aria-label on the body
hideTitlebooleanNofalseFlag to hide the title
showClosebooleanNotrueFlag to show the close button in the header area of the modal
modalContentAriaDescribedByIdstringNo''Id to use for Modal Box descriptor
footerReact.ReactNodeNoCustom footer
actionsanyNo[]Action buttons to add to the standard Modal Footer, ignored if `footer` is given
onClose() => voidNo() => undefined as anyA callback for when the close button is clicked
widthnumber | stringNoDefault width of the Modal.
appendToHTMLElement | (() => HTMLElement)No(typeof document !== 'undefined' && document.body) || nullThe parent container to append the modal to. Defaults to document.body
disableFocusTrapbooleanNoFlag to disable focus trap
descriptionReact.ReactNodeNoDescription of the modal
variant'small' | 'large' | 'default'No'default'Variant of the modal
ModalBox properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesContent rendered inside the ModalBox.
classNamestringNo''Additional classes added to the ModalBox
variant'small' | 'large' | 'default'No'default'Variant of the modal
titlestringYesString to use for Modal Box aria-label
idstringYesId to use for Modal Box description
ModalBoxBody properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullContent rendered inside the ModalBoxBody
classNamestringNo''Additional classes added to the ModalBoxBody
ModalBoxCloseButton properties
NameTypeRequiredDefaultDescription
classNamestringNo''Additional classes added to the close button
onClose() => voidNo() => undefined as anyA callback for when the close button is clicked
ModalBoxFooter properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullContent rendered inside the Footer
classNamestringNo''Additional classes added to the Footer
ModalBoxHeader properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeNonullContent rendered inside the Header
classNamestringNo''Additional classes added to the button
hideTitlebooleanNofalseFlag to hide the title
headingLevel'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'No'h1'The heading level to use
ModalContent properties
NameTypeRequiredDefaultDescription
childrenReact.ReactNodeYesContent rendered inside the Modal.
classNamestringNo''Additional classes added to the button
variant'small' | 'large' | 'default'No'default'Variant of the modal
isOpenbooleanNofalseFlag to show the modal
headerReact.ReactNodeNonullComplex header (more than just text), supersedes title for header content
descriptionReact.ReactNodeNonullDescription of the modal
titlestringYesSimple text content of the Modal Header, also used for aria-label on the body
hideTitlebooleanNofalseFlag to show the title (ignored for custom headers)
showClosebooleanNotrueFlag to show the close button in the header area of the modal
widthnumber | stringNo-1Default width of the content.
footerReact.ReactNodeNonullCustom footer
actionsanyNo[]Action buttons to add to the standard Modal Footer, ignored if `footer` is given
onClose() => voidNo() => undefined as anyA callback for when the close button is clicked
modalBoxAriaDescribedByIdstringNo''Id to use for Modal Box descriptor
idstringNo''Id of the ModalBoxBody
disableFocusTrapbooleanNofalseFlag to disable focus trap

CSS Variables

.pf-c-modal-box--pf-c-modal-box--BackgroundColor
#fff
.pf-c-modal-box--pf-c-modal-box--BoxShadow
0 1rem 2rem 0 rgba(3, 3, 3, 0.16), 0 0 0.5rem 0 rgba(3, 3, 3, 0.1)
.pf-c-modal-box--pf-c-modal-box--ZIndex
500
.pf-c-modal-box--pf-c-modal-box--Width
100%
.pf-c-modal-box--pf-c-modal-box--MaxWidth
calc(100% - 2rem)
.pf-c-modal-box--pf-c-modal-box--m-sm--sm--MaxWidth
35rem
.pf-c-modal-box--pf-c-modal-box--m-lg--lg--MaxWidth
70rem
.pf-c-modal-box--pf-c-modal-box--MaxHeight
calc(100% - 3rem)
.pf-c-modal-box--pf-c-modal-box__title--LineHeight
1.3
.pf-c-modal-box--pf-c-modal-box__title--FontSize
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--PaddingTop
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--PaddingRight
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--PaddingLeft
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--last-child--PaddingBottom
1.5rem
.pf-c-modal-box--pf-c-modal-box__description--PaddingTop
0.25rem
.pf-c-modal-box--pf-c-modal-box__description--PaddingRight
1.5rem
.pf-c-modal-box--pf-c-modal-box__description--PaddingLeft
1.5rem
.pf-c-modal-box--pf-c-modal-box__description--last-child--PaddingBottom
1.5rem
.pf-c-modal-box--pf-c-modal-box__body--MinHeight
calc(1rem * 1.5)
.pf-c-modal-box--pf-c-modal-box__body--PaddingTop
1.5rem
.pf-c-modal-box--pf-c-modal-box__body--PaddingRight
1.5rem
.pf-c-modal-box--pf-c-modal-box__body--PaddingLeft
1.5rem
.pf-c-modal-box--pf-c-modal-box__body--last-child--PaddingBottom
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--body--PaddingTop
1rem
.pf-c-modal-box--pf-c-modal-box__description--body--PaddingTop
1rem
.pf-c-modal-box--pf-c-modal-box--c-button--Top
calc(1.5rem - 0.375rem + 0.0625rem)
.pf-c-modal-box--pf-c-modal-box--c-button--Right
1rem
.pf-c-modal-box--pf-c-modal-box--c-button--sibling--MarginRight
2rem
.pf-c-modal-box--pf-c-modal-box__footer--PaddingTop
1.5rem
.pf-c-modal-box--pf-c-modal-box__footer--PaddingRight
1.5rem
.pf-c-modal-box--pf-c-modal-box__footer--PaddingBottom
1.5rem
.pf-c-modal-box--pf-c-modal-box__footer--PaddingLeft
1.5rem
.pf-c-modal-box--pf-c-modal-box__footer--c-button--MarginRight
1rem
.pf-c-modal-box--pf-c-modal-box__footer--c-button--sm--MarginRight
calc(1rem / 2)
.pf-c-modal-box__title + .pf-c-modal-box__body--pf-c-modal-box__body--PaddingTop
1rem
.pf-c-modal-box__description + .pf-c-modal-box__body--pf-c-modal-box__body--PaddingTop
1rem