Skip to content

Textarea

A multi-line text input component for Ink 5 with cursor movement and scrolling.

ink-text-input is single-line only — this fills the gap.

Install

Terminal window
npm install @matthesketh/ink-textarea

Usage

import React, { useState } from 'react';
import { render } from 'ink';
import { TextArea } from '@matthesketh/ink-textarea';
function App() {
const [value, setValue] = useState('');
return (
<TextArea
value={value}
onChange={setValue}
onSubmit={(text) => console.log('Submitted:', text)}
height={10}
placeholder="Type your message..."
/>
);
}
render(<App />);

Props

PropTypeDefaultDescription
valuestringCurrent text value (controlled)
onChange(value: string) => voidCalled when text changes
onSubmit(value: string) => voidCalled on Ctrl+Enter or Ctrl+S
heightnumber5Visible rows
placeholderstringShown when value is empty
focusbooleantrueWhether the component accepts input
showCursorbooleantrueShow cursor position as inverted character

Key Bindings

  • Arrow keys — move cursor up/down/left/right
  • Enter — insert newline
  • Ctrl+Enter or Ctrl+S — trigger onSubmit
  • Backspace — delete character before cursor
  • Tab — insert two spaces

License

MIT