Modal
A modal component that lets you open content in a dialog.
#
ImportModal
: The component that provides the context to the other components.Modal.Content
: Adds padding around the content.Modal.CloseButton
: A button that closes the modal.
#
UsageResult
SyntaxError: Unexpected token (1:8) 1 : return () ^
Live Editor
#
PropsisOpen
#
Toggle the modal with the isOpen
prop.
onClose
#
onClose
is called whenever the overlay or close button are clicked on.
closeOnOverlayClick
#
You can stop the modal from closing when you click outside the content using the closeOnOverlayClick
prop.
You should probably include some other way of closing the modal, for example the Modal.CloseButton
.
Result
SyntaxError: Unexpected token (1:8) 1 : return () ^
Live Editor
size
#
Use the size
prop to set the width of the modal. Possible values are xs
, sm
, md
, lg
, xl
, or a custom value like w-full md:w-72
. The default is md
.
Result
SyntaxError: Unexpected token (1:8) 1 : return () ^
Live Editor
Modal.CloseButton
#
Result
SyntaxError: Unexpected token (1:8) 1 : return () ^
Live Editor
#
AccessabilityModal
follows the practices for dialog modal found at WAI-ARIA Authoring Practices.
Esc
closes the modal.- Focus is locked inside the modal.
- The trigger gains focus after the modal is closed.
- The modal has a role of
dialog
. - The modal has
aria-modal="true"