Skip to content

@jsvision/ui / messageBox

Function: messageBox()

messageBox(host, o): Promise<"ok" | "cancel">

Defined in: ui/src/dialog/message-box.ts:99

Show a modal message box and wait for the user to dismiss it.

With the default single OK button the box can still resolve 'cancel'Dialog is closable and Esc-dismissible, and both resolve the modal to Commands.cancel. Callers that only inform the user typically ignore the return value.

Parameters

host

ModalDialogHost

The modal host (an Application, or { loop, desktop }).

o

MessageBoxOptions

Title, message text, and the button set.

Returns

Promise<"ok" | "cancel">

'ok' when OK is chosen, 'cancel' on Cancel, Esc, or the frame close-box.

Example

ts
await messageBox(app, { title: 'About', text: 'jsvision — classic terminal UI, reimagined' });
const answer = await messageBox(app, { title: 'Delete?', text: 'This cannot be undone.', buttons: 'okCancel' });
if (answer === 'ok') remove();