Skip to content

@jsvision/ui / inputBox

Function: inputBox() ​

inputBox(host, o): Promise<string | null>

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

Prompt for a single line of text modally. An optional validator gates OK through the dialog's valid() sweep, which keeps the box open and refocuses the field when the value is invalid.

Parameters ​

host ​

ModalDialogHost

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

o ​

InputBoxOptions

Title, field label (with optional ~X~ hotkey), the two-way value signal, and validator.

Returns ​

Promise<string | null>

The entered string on OK, or null if the user cancels.

Example ​

ts
import { createApplication, inputBox, signal } from '@jsvision/ui';
import { resolveCapabilities } from '@jsvision/core';

const caps = resolveCapabilities().profile;
const app = createApplication({ caps });

function rename(newName: string): void {
  // Apply the new name to the selected item.
}

const name = signal('');
const entered = await inputBox(app, { title: 'Rename', label: '~N~ew name', value: name });
if (entered !== null) rename(entered);