Modal

The Modal component renders content in a portal, with customizable actions like confirm, cancel, and close.

Usage & Examples

Default

default.tsx
<Button theme="primary" onClick={() => setIsOpen(true)}>
    Open Modal
  </Button>
  
  {isOpen && (
    <Modal onClose={() => setIsOpen(false)}>
      <div style={{ padding: "1rem" }}>
        <h2 style={{ marginTop: 0 }}>Hello from the modal!</h2>
        <p>
          This is a fully accessible, focus-trapped modal component rendered via portal.
        </p>
        <Button onClick={() => alert("Action inside modal!")}>Action</Button>
      </div>
    </Modal>
  )}

Props API

22 props
Columns
Modal props API
Default
Description
aria-describedbystringNoaria—The id of an element that describes the modal dialog. Useful for linking help text, instructions, or supporting content.
aria-labelstringNoaria—Accessible label for the modal dialog. Use this when the modal does not have a visible title or when you want to provide a custom accessible name for screen readers.
aria-labelledbystringNoaria—The id of an element that labels the modal dialog. Prefer this when a visible heading or custom header should act as the dialog label.
bodyClassNamestringNoprops—Additional class names for the modal body section.
childrenReactElement<unknown, string | JSXElementConstructor<any>>Noprops—The content to be rendered inside the modal. Expected to be a single React element.
classNamestringNostyling—Additional class names for custom styling the modal content.
closeButtonAriaLabelstringNoprops"Close modal"Accessible label for the close button. Defaults to "Close modal" in the base implementation.
closeButtonClassNamestringNoprops—Additional class names for the modal close button.
data-testidstringNotesting—Backward-compatible alias for test ID attributes.
footerReactNodeNoprops—Optional footer content.
footerClassNamestringNoprops—Additional class names for the modal footer section.
headerReactNodeNoprops—Optional custom header content.