---
title: "Prompts"
description: "Terminal apps, written in TypeScript and compiled to native executables with scriptc."
canonical_url: "https://tui-sdk.dev/docs/guides/prompts"
---
# Prompts

`tui/prompt` asks questions and shows work in progress in the rows below the cursor, as a command does, and leaves the answers in the terminal's scrollback:

```ts
import { confirm, select, spinner, text } from "tui/prompt"

const name = await text({ message: "Project name", placeholder: "my-app" })
const template = await select({
  message: "Template",
  items: [
    { value: "app", label: "App" },
    { value: "api", label: "API" },
  ],
})
const install = await confirm({ message: "Install dependencies?" })
if (name === null || template === null || install === null) {
  process.exit(130)
}
if (install) {
  const installing = spinner({ message: "Installing" })
  await new Promise((resolve) => setTimeout(resolve, 1000))
  installing.stop("Installed")
}
```

The HTML page runs [`examples/prompt.ts`](https://github.com/vercel-labs/tui/blob/main/examples/prompt.ts) here, in a terminal in the page.

Each prompt resolves with its answer, or `null` when someone cancels it with Ctrl+C or Escape. `text` checks an answer with `validate`, `select` scrolls past `visible` items and finds one as you type its name, `multiselect` checks items with Space and can require one, and `confirm` never takes a `y` that's part of a paste. `spinner` and `progress` end with `stop` or `fail`, and when the output isn't a terminal, they write only that last line.

Prompts draw on `process.stdout` by default. Pass `output: process.stderr` to a prompt, spinner, or progress bar to keep stdout clean for data a pipe or another program reads. Pass `input` to read keys from a stream other than `process.stdin`: it takes a stream with the same shape.

The prompts are apps like any other. `runApp({ view, rows: 3 })` draws your own app in the 3 rows below the cursor instead of on the whole screen, with the same components, and its `stop` leaves the last frame on screen.
