--- id: Modal section: components cssPrefix: pf-v5-c-modal-box ---import './ModalBox.css' ## Examples ### Basic ```html isFullscreen ``` ### With help button ```html isFullscreen ``` ### Small ```html isFullscreen ``` ### Medium ```html isFullscreen ``` ### Large ```html isFullscreen ``` ### Without title ```html isFullscreen ``` ### With description ```html isFullscreen ``` ### Custom title ```html isFullscreen ``` ### Modal box as generic container ```html isFullscreen ``` ### Icon ```html isFullscreen ``` ### Custom alert ```html isFullscreen ``` ### Info alert ```html isFullscreen ``` ### Success alert ```html isFullscreen ``` ### Warning alert ```html isFullscreen ``` ### Danger alert ```html isFullscreen ``` ### Danger alert with modifier on modal title The status modifier classes can be applied directly to the modal title element, instead of the parent modal. ```html isFullscreen isBeta ``` ## 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-v5-c-modal-box` container will serve as a generic container with no padding for custom modal content. If no `.pf-v5-c-modal-box__title` is used, `aria-label="[title of modal]"` must be provided for `.pf-v5-c-modal-box`. ### Accessibility | Attribute | Applies to | Outcome | | -- | -- | -- | | `role="dialog"` | `.pf-v5-c-modal-box` | Identifies the element that serves as the modal container. **Required** | | `aria-labelledby="[id value of .pf-v5-c-modal-box__title or custom modal title]"` | `.pf-v5-c-modal-box` | Gives the modal an accessible name by referring to the element that provides the dialog title. **Required when .pf-v5-c-title is present** | | `aria-label="[title of modal]"` | `.pf-v5-c-modal-box` | Gives the modal an accessible name. **Required when `.pf-v5-c-modal-box__title` is *not* present** | | `aria-describedby="[id value of applicable content]"` | `.pf-v5-c-modal-box` | Gives 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-v5-c-modal-box` | Tells assistive technologies that the windows underneath the current modal are not available for interaction. **Required**| | `aria-label="Close"` | `.pf-v5-c-modal-box__close .pf-v5-c-button` | Provides 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 open | Hides main contents of the page from screen readers. The element with `.pf-v5-c-modal-box` must not be a descendent of the element with `aria-hidden="true"`. For more info see [trapping focus](/accessibility/product-development-guide#trapping-focus). **Required** | | `form="[id of form in modal body]"` | `.pf-v5-c-modal-box__footer .pf-v5-c-button` | Associates a submit button in the modal footer with a form in the modal body. For use when the submit button is outside of the `
` that the button submits. | | `tabindex="0"` | `.pf-v5-c-modal-box__body` | If a modal box body has overflow content that triggers a scrollbar, to ensure that the content is keyboard accessible, the body must include either a focusable element within the scrollable region or the body itself must be focusable by adding `tabindex="0"`. | ### Usage | Class | Applied | Outcome | | -- | -- | -- | | `.pf-v5-c-modal-box` | `
` | Initiates a modal box. **Required** | | `.pf-v5-c-modal-box__close` | `
` | Creates a container for the modal box close button. **Required** if there is a close button. | | `.pf-v5-c-button.pf-m-plain` | `