$ Input
interactiveasync
Interactive text input prompt with placeholder text, default values, validation messages, and password masking.
# Preview
input demo
Placeholder state:
? What is your name? Enter your name...
Typing:
? What is your name? Alice
Confirmed:
✔ What is your name? Alice
Validation error:
? Email: foo
✖ Must be a valid email
Masked input:
? Password: ****
# Usage
example.ts
import { input } from "@vr_patel/tui";
// Basic input
const name = await input({ message: "What is your name?" });
// With validation
const email = await input({
message: "Email:",
validate: (v) => v.includes("@") || "Must be a valid email",
});
// Password input (masked)
const password = await input({
message: "Password:",
mask: "*",
validate: (v) => v.length >= 8 || "Must be at least 8 characters",
});
// With placeholder and default
const port = await input({
message: "Port:",
placeholder: "3000",
defaultValue: "3000",
});# API
| Prop | Type | Default | Description |
|---|---|---|---|
| message | string | required | Prompt question |
| defaultValue | string | "" | Default value if empty |
| placeholder | string | "" | Placeholder text shown when empty |
| validate | (v: string) => true | string | undefined | Validation function returning error message |
| mask | string | undefined | Mask character for passwords (e.g., "*") |