Hyunsui
Docs
Modal
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
Anatomy
Import all parts and piece them together.
API Reference
Root
Composes every part, manages the open state (controlled or uncontrolled), and wires accessibility ids.
PropTypeDefault
open
booleanundefined
defaultOpen
booleanfalse
onOpenChange
function-
isOpen
boolean-
onClose
function-
closeOnEscape
booleantrue
closeOnOverlay
booleantrue
container
HTMLElement | nulldocument.body | null
disableLockScroll
booleanfalse
unmountDelay
number220
id
string | undefinedundefined
Trigger
Button that toggles the modal and receives aria/data attributes automatically.
PropTypeDefault
type
"button" | "submit" | "reset"button
disabled
boolean-
onClick
React.MouseEventHandler<HTMLButtonElement>-
Data AttributeValue
data-state
"open" | "closed"
data-disabled
""
Portal
When used, portals your overlay and content parts into the body.
PropTypeDefault
container
HTMLElement | nullInherited from Root
forceMount
booleanfalse
Overlay
A layer that covers the inert portion of the view when the modal is open.
PropTypeDefault
forceMount
booleanfalse
Data AttributeValue
data-state
"open" | "closed"
Content
Contains content to be rendered in the open modal.
PropTypeDefault
forceMount
booleanfalse
Data AttributeValue
data-state
"open" | "closed"
Title
An accessible title to be announced when the modal is opened.
PropTypeDefault
children
ReactNode-
Description
An accessible description to be announced when the modal is opened.
PropTypeDefault
children
ReactNode-
Close
The button that closes the modal.
PropTypeDefault
children
ReactNode-