$ 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

PropTypeDefaultDescription
messagestringrequiredPrompt question
defaultValuestring""Default value if empty
placeholderstring""Placeholder text shown when empty
validate(v: string) => true | stringundefinedValidation function returning error message
maskstringundefinedMask character for passwords (e.g., "*")