Use modal dialog boxes for confirmations or to present important information.
Examples
Contents
<div class="rosgovuk-modal" tabindex="-1" role="dialog" aria-describedby="body-id" aria-labelledby="heading-id" aria-modal="true">
<h1 id="heading-id" class="govuk-heading-l">Modal title</h1>
<div id="body-id">
<p class="govuk-body">Modal body!</p>
</div>
<button id="modal-close-button" class="rosgovuk-modal__close-button" aria-label="Close.">
X
</button>
</div>
<Modal
shouldCloseOnOverlayClick={true}
isOpen={isOpen}
onClose={() => setIsOpen(false)}
describedby="body-id"
labelledby="heading-id"
>
<Heading id="heading-id">Modal title</Heading>
<div id="body-id">
<Paragraph>Modal body!</Paragraph>
</div>
</Modal>
When to use this component
Modal dialog windows interrupt users and demand an action. They are appropriate when user's attention needs to be directed toward important information:
- when customer testing indicates it is useful
- for important warnings to provide confirmation
- to interrupt high-stake processes such as checkout flows.
Implementation advice
- on open, the title should be read by a screen reader - to achieve this set focus on the modal div (with
tabindex="-1"). This will then read the associatedaria-labelledbytext - the modal window should be keyboard accessible, with a way to close the window using the keyboard (either using the Escape key or by tabbing to the close button)
- on close the modal window should return focus to the initiating button or link.
Services using this pattern
- Digital Discharge
- ScotLIS public
- ScotLIS professional
- Register of Inhibitions.
