Description:
A fully accessible and flexible React modal built according WAI-ARIA Authoring Practices.
This module provides a “smart” minimally styled component to wrap you “dumb” fully styled component. It provides the following features, while giving you complete control of the content:
- Focus is trapped within the modal: Tab and Shift+Tab will cycle through the modal’s focusable nodes without returning to the main document beneath.
- Escape will close the modal.
- Scrolling is frozen on the main document beneath the modal. (Although, sadly, you can still mess with the scrolling using a touch screen.)
- When the modal closes, focus returns to the element that was focused just before the modal activated.
- The dialog element has an ARIA
roleofdialog(oralertdialog). - The dialog element has an ARIA attribute designating its title, either
aria-labeloraria-labelledby. - By default, clicking on the modal’s underlay (outside the dialog element) will close the modal (this can be disabled).
- The modal is appended to the end of
document.bodyinstead of its taking up its source-order position within the React component tree.
