Imperative dialogs
confirm / alert / prompt are three standalone functions — import and await them from any event callback: no hook, no component to mount, no React tree required. For fully custom dialogs use the Dialog component.
Basic usage
confirm returns a Promise<boolean> (OK → true, Cancel / ESC → false); alert returns a Promise<void>; prompt returns a Promise<string | null> (Cancel / ESC → null).
No action yet
Config inheritance
A dialog called inside an OOUIProvider subtree inherits that Provider's language, direction and popup container settings; unwrapped, it renders with defaults. For overriding message text, see OOUIProvider · Imperative dialogs.
Runtime semantics
- The Promise resolves after the close animation finishes (plus a ~50ms margin), not at the instant of the button click — code right after
await confirm(...)that reads the DOM or navigates waits for the animation first. - The dialog renders inside the app's React tree and inherits all context of its subtree; with nested
OOUIProviders, the outermost host renders all imperative dialogs (an imperative call has no position information, so rendering with the app-root config is the most predictable). - Repeated calls stack multiple dialogs, each independently interactive; the original shares one single-window manager, where a second call while a window is open is rejected and its Promise never settles.
- In
prompt, pressing Enter in the input equals clicking OK (except during IME composition;textInput.onKeyDowncan veto withpreventDefault); the input is focused automatically once ready (textInput.inputRefis taken internally and passing it has no effect;textInput.valueis only the initial value).
API
options (ConfirmAlertOptions / AlertOptions / PromptOptions):
See also
- The dialog components themselves (controlled
open, action areas, multi-dialog isolation): Dialog - How imperative dialogs inherit provider config: OOUIProvider
- The multi-step dialog: ProcessDialog