Modal

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

Usage

Default

<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

Data table
TypeDescription
aria-describedbystringThe id of an element that describes the modal dialog. Useful for linking help text, instructions, or supporting content.
aria-labelstringAccessible 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-labelledbystringThe id of an element that labels the modal dialog. Prefer this when a visible heading or custom header should act as the dialog label.
childrenReactElement<unknown, string | JSXElementConstructor<any>>The content to be rendered inside the modal. Expected to be a single React element.
classNamestringAdditional class names for custom styling the modal content.
closeButtonAriaLabelstringAccessible label for the close button. Defaults to "Close modal" in the base implementation.
data-testidstringOptional test ID for testing frameworks.
footerReactNodeOptional footer content.
headerReactNodeOptional custom header content.
onClose() => voidCallback function fired when the modal is closed.
openbooleanControls whether the modal is open. - If omitted, the modal is considered open when rendered. - If provided, the modal opens/closes based on this value.
roundingRoundingTypeRounding of the modal corners. One of: "none" | "small" | "medium" | "large" | "full"
shadowShadowTypeShadow of the modal. One of: "none" | "light" | "medium" | "strong" | "intense"
titleReactNodeOptional modal title used for accessible labelling and default header content.