Patternfly Logo

Examples

Basic

With help button

Small

Medium

Large

Without title

With description

Custom title

Icon

Default alert

Info alert

Success alert

Warning alert

Danger alert

Documentation

Overview

A modal box is a generic rectangular container that can be used to build modals. A modal box can have the following sections: header, title, description, body, and footer. With normal use of the modal, a title or body is required. Alternatively, no child elements can be used, and the .pf-c-modal-box container will serve as a generic container with no padding for custom modal content. If no .pf-c-modal-box__title is used, aria-label="[title of modal]" must be provided for .pf-c-modal-box.

Accessibility

AttributeApplies toOutcome
role="dialog".pf-c-modal-boxIdentifies the element that serves as the modal container. Required
aria-labelledby="[id value of .pf-c-modal-box__title or custom modal title]".pf-c-modal-boxGives the modal an accessible name by referring to the element that provides the dialog title. Required when .pf-c-title is present
aria-label="[title of modal]".pf-c-modal-boxGives the modal an accessible name. Required when .pf-c-modal-box__title is not present
aria-describedby="[id value of applicable content]".pf-c-modal-boxGives the modal an accessible description by referring to the modal content that describes the primary message or purpose of the dialog. Not used if there is no static text that describes the modal.
aria-modal="true".pf-c-modal-boxTells assistive technologies that the windows underneath the current modal are not available for interaction. Required
aria-label="Close".pf-c-modal-box__close .pf-c-buttonProvides an accessible name for the close button as it uses an icon instead of text. Required
aria-hidden="true"Parent element containing the page contents when modal is openHides main contents of the page from screen readers. The element with .pf-c-modal-box must not be a descendent of the element with aria-hidden="true". For more info see trapping focus. Required

Usage

ClassAppliedOutcome
.pf-c-modal-box<div>Initiates a modal box. Required
.pf-c-button.pf-m-plain<button>Initiates a modal box close button.
.pf-c-modal-box__header<header>Initiates a modal box header. Required if using a .pf-c-modal-box__title.
.pf-c-modal-box__header-main<div>Initiates a modal box header main container. Required when pf-c-modal-box__header-help is used.
.pf-c-modal-box__header-help<div>Initiates the help button container in the modal box header actions.
.pf-c-modal-box__title<h1>,<h2>,<h3>,<h4>,<h5>,<h6>, <div>Initiates a modal box title. Required if using a modal description.
.pf-c-modal-box__title-icon<span>Initiates a container for the modal box title icon.
.pf-c-modal-box__title-text<span>Initiates a container for the modal box title text.
.pf-c-modal-box__description<div>Initiates a modal box description.
.pf-c-modal-box__body<div>Initiates a modal box body.
.pf-c-modal-box__footer<footer>Initiates a modal box footer.
.pf-m-sm.pf-c-modal-boxModifies for a small modal box width.
.pf-m-md.pf-c-modal-boxModifies for a medium modal box width.
.pf-m-lg.pf-c-modal-boxModifies for a large modal box width.
.pf-m-align-top.pf-c-modal-boxModifies for top alignment.
.pf-m-icon.pf-c-modal-box__titleModifies the title layout to accommodate an icon.
.pf-m-default.pf-c-modal-boxModifies for the default alert state.
.pf-m-info.pf-c-modal-boxModifies for the info alert state.
.pf-m-success.pf-c-modal-boxModifies for the success alert state.
.pf-m-warning.pf-c-modal-boxModifies for the warning alert state.
.pf-m-danger.pf-c-modal-boxModifies for the danger alert state.
.pf-m-help.pf-c-modal-box__headerModifies the modal box header to support the help action

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-md--Width
52.5rem
.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__header--PaddingTop
1.5rem
.pf-c-modal-box--pf-c-modal-box__header--PaddingRight
1.5rem
.pf-c-modal-box--pf-c-modal-box__header--PaddingLeft
1.5rem
.pf-c-modal-box--pf-c-modal-box__header--last-child--PaddingBottom
1.5rem
.pf-c-modal-box--pf-c-modal-box__title--LineHeight
1.3
.pf-c-modal-box--pf-c-modal-box__title--FontFamily
"RedHatDisplay", "Overpass", overpass, helvetica, arial, sans-serif
.pf-c-modal-box--pf-c-modal-box__title--FontSize
1.5rem
.pf-c-modal-box--pf-c-modal-box__description--PaddingTop
0.25rem
.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__header--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.pf-m-sm--pf-c-modal-box--Width
35rem
.pf-c-modal-box.pf-m-md--pf-c-modal-box--Width
52.5rem
.pf-c-modal-box.pf-m-lg--pf-c-modal-box--Width
70rem
.pf-c-modal-box__header + .pf-c-modal-box__body--pf-c-modal-box__body--PaddingTop
1rem

View source on Github