Skip to main content

Modal

A dialog with two ways to use it: controlled (drive open yourself and handle onOk / onCancel) or imperative (Modal.confirm, Modal.info, … fire a self-managing modal from anywhere). The mask is not click-closable by default.

import { Modal } from '@jbpark/ui-kit';

const [open, setOpen] = useState(false);

<Modal
open={open}
title="Title"
content="Body text"
onOk={() => setOpen(false)}
onCancel={() => setOpen(false)}
/>;

Imperative

The static methods render a centered, status-styled modal and manage their own open state. Modal.confirm shows both OK/Cancel; the others show a single acknowledge button.

Modal.confirm({
title: 'Delete this item?',
content: 'This action cannot be undone.',
onOk: handleDelete,
});

Modal.success({ title: 'Saved.' });

Modal.destroy(id) closes a specific one (each call returns an id); Modal.destroyAll() clears them all.

Props

PropTypeDefault
openbooleanfalse
titleReactNode-
contentReactNode (body; children also works)-
footerReactNode (null hides the footer)-
onOk() => void-
onCancel() => void-
okTextstringlocale
cancelTextstringlocale
closableboolean | { closeIcon?; disabled? }false
closeIconReactNode-
maskClosablebooleanfalse
containerHTMLElement (custom portal target)-
classNames{ mask?; header?; body?; footer? }-
classNamestring-

Imperative methods

MethodNotes
Modal.info / success / error / warningsingle acknowledge button
Modal.confirmOK + Cancel
Modal.destroy(id) / Modal.destroyAll()programmatic close

Each imperative status renders a matching icon next to the title. Modal.info / success / error / warning set the status axis; Modal.confirm is a separate interaction mode (two-button footer), not a status.