InkUI
Components

TextInput

Controlled text input with cursor, arrow-key navigation, and password masking.

A controlled text input for terminal apps. Supports block cursor, arrow-key cursor movement, backspace, placeholder text, and password masking.

Live Preview
TextInput · controlled
? Project name
~/my-cli — node v22● running

Installation

npx inkui add text-input

Usage

import { useState } from 'react';
import { TextInput } from './components/ui/text-input';
 
export default function App() {
  const [name, setName] = useState('');
 
  return (
    <TextInput
      label="Name"
      value={name}
      onChange={setName}
      onSubmit={(v) => console.log('submitted:', v)}
      placeholder="Enter your name"
    />
  );
}

Examples

Basic

const [value, setValue] = useState('');
<TextInput value={value} onChange={setValue} />

With label and placeholder

<TextInput
  label="Email"
  value={email}
  onChange={setEmail}
  placeholder="you@example.com"
/>

Password mode

<TextInput
  label="Password"
  value={password}
  onChange={setPassword}
  password
/>

Multi-field form

const [step, setStep] = useState<'name' | 'email' | 'done'>('name');
 
<TextInput
  label="Name "
  value={name}
  onChange={setName}
  onSubmit={() => setStep('email')}
  focus={step === 'name'}
/>
<TextInput
  label="Email"
  value={email}
  onChange={setEmail}
  onSubmit={() => setStep('done')}
  focus={step === 'email'}
/>

Props

PropTypeDefaultDescription
valuestringControlled value (required)
onChange(v: string) => voidCalled on every keystroke (required)
onSubmit(v: string) => voidundefinedCalled when Enter is pressed
placeholderstring''Shown when value is empty
passwordbooleanfalseMask characters as *
focusbooleantrueWhether this input captures keyboard input
labelstringundefinedOptional label to the left
themeInkUIThemedarkThemeColor theme

On this page