Prompts and results
ts
const color = await modal.prompt<string>(PickColor, { initial: 'red' })
if (color === null) returnInside the modal, resolve with a value. The modal closes, and its guards still run:
ts
const resolve = useModalResolve<string>()
resolve('blue')tsx
const resolve = useModalResolve<string>()
resolve('blue')js
function PickColor(props, handle) {
button.onclick = () => handle.resolve('blue')
}- Emitting instead. In Vue the component can also emit
PROMPT_EVENT('modal:prompt') with the value. - A guard vetoes.
resolve()returnsfalseand the prompt stays pending. A later successfulresolve()delivers the new value. - Closing without a value. Escape, the backdrop or
close()resolve the prompt withnull. - Results for any modal. Every handle has
handle.result, which is a promise of the resolved value ornull.