---
url: /reference/api/logger/prompts.Variable.text.md
---
# Variable: text

```ts twoslash
// @include: imports
const text: (opts) => Promise<string | typeof CANCEL_SYMBOL>;
```

Defined in: node\_modules/.pnpm/@clack+prompts@1.9.0/node\_modules/@clack/prompts/dist/index.d.mts:709

The text prompt accepts a single line of text.

## Parameters

`opts`

[`TextOptions`](prompts.Interface.TextOptions.md)

## Returns

`Promise`<`string` | *typeof* [`CANCEL_SYMBOL`](prompts.Variable.CANCEL_SYMBOL.md)>

## See

https://bomb.sh/docs/clack/packages/prompts/#text-input

## Example

```ts twoslash
// @include: imports
import { text } from "@clack/prompts";

const name = await text({
  message: "What is your name?",
  placeholder: "John Doe",
  validate: (value) => {
    if (!value || value.length < 2) return "Name must be at least 2 characters";
    return undefined;
  },
});
```
