Modal
Modal blocks for confirmation, focused forms, and critical decisions.
@duskmoon-dev/components/modalUsage
When to use
- Use it immediately after user actions or system checks that need visible confirmation.
- Choose the least interruptive feedback surface that still makes the state clear.
Implementation notes
Features
Covers transient, inline, or blocking feedback patterns for user actions and system status.
Shows how the component keeps next actions visible after success, warning, or failure states.
Modal is most often configured through `open`, `defaultOpen`, `title`, `content`.
Renders open modal with title and children
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Controlled native modal
Modal uses native showModal and close. A controlled onCancel must update open; its ref and div props remain on the inner modal box. Apply maskClassName to the dialog for ::backdrop styling. Static Modal.confirm/info/success/error/warning handles are retained but do not render a service surface yet.
Source
import "@duskmoon-dev/components/styles.css";
import { useState } from "react";
import { Modal } from "@duskmoon-dev/components/modal";
export function ReleaseChecklist() {
const [open, setOpen] = useState(false);
return (
<>
<button type="button" onClick={() => setOpen(true)}>Review release</button>
<Modal
open={open}
title="Release checklist"
onCancel={() => setOpen(false)}
onOk={() => setOpen(false)}
maskClassName="release-mask"
>
Review component styles before publishing.
</Modal>
</>
);
}API
The API reference below lists every parsed exported type or interface for Modal. Start with `open`, `defaultOpen`, `title`, `content` for common usage.
packages/components/src/components/modal/Modal.types.tsScenarios: packages/components/src/components/modal/Modal.test.tsx| Prop | Type | Required | Description |
|---|---|---|---|
open | boolean | No | open configures Modal. |
defaultOpen | boolean | No | defaultOpen configures Modal. |
title | ReactNode | No | title configures Modal. |
children | ReactNode | No | children configures Modal. |
content | ReactNode | No | content configures Modal. |
footer | ReactNode | null | No | footer configures Modal. |
onOk | (event: MouseEvent<HTMLButtonElement>) => void | No | onOk configures Modal. |
onCancel | (event: MouseEvent<HTMLButtonElement | HTMLDivElement>) => void | No | onCancel configures Modal. |
okText | ReactNode | No | okText configures Modal. |
cancelText | ReactNode | No | cancelText configures Modal. |
confirmLoading | boolean | No | confirmLoading configures Modal. |
closable | boolean | No | closable configures Modal. |
maskClosable | boolean | No | maskClosable configures Modal. |
width | CSSProperties["width"] | No | width configures Modal. |
centered | boolean | No | centered configures Modal. |
destroyOnClose | boolean | No | destroyOnClose configures Modal. |
afterOpenChange | (open: boolean) => void | No | afterOpenChange configures Modal. |
className | string | No | className configures Modal. |
maskClassName | string | No | maskClassName configures Modal. |
closeIcon | ReactNode | No | closeIcon configures Modal. |
| Prop | Type | Required | Description |
|---|---|---|---|
title | ReactNode | No | title configures Modal. |
content | ReactNode | No | content configures Modal. |
onOk | () => void | No | onOk configures Modal. |
onCancel | () => void | No | onCancel configures Modal. |
okText | ReactNode | No | okText configures Modal. |
cancelText | ReactNode | No | cancelText configures Modal. |
| Prop | Type | Required | Description |
|---|---|---|---|
destroy | () => void | Yes | destroy configures Modal. |
update | (config: ModalFuncProps) => void | Yes | update configures Modal. |
| Prop | Type | Required | Description |
|---|---|---|---|
confirm | (config: ModalFuncProps) => ModalFuncHandle | Yes | confirm configures Modal. |
info | (config: ModalFuncProps) => ModalFuncHandle | Yes | info configures Modal. |
success | (config: ModalFuncProps) => ModalFuncHandle | Yes | success configures Modal. |
error | (config: ModalFuncProps) => ModalFuncHandle | Yes | error configures Modal. |
warning | (config: ModalFuncProps) => ModalFuncHandle | Yes | warning configures Modal. |
destroyAll | () => void | Yes | destroyAll configures Modal. |