Tuimorphic

TextArea

Terminal-style multi-line text input with custom caret.

Import

import { TextArea } from 'tuimorphic';

Basic Usage

<TextArea placeholder="Enter your message..." />

Props

PropTypeDefaultDescription
labelstringLabel text for the textarea
rowsnumber4Number of visible rows
caretCharsstring' 'Custom caret character
isBlinkbooleantrueWhether the caret should blink
valuestringControlled value
defaultValuestringDefault value for uncontrolled mode
placeholderstringPlaceholder text
disabledbooleanfalseWhether the textarea is disabled
readOnlybooleanfalseWhether the textarea is read-only
maxLengthnumberMaximum character length
onChange(event: ChangeEvent) => voidChange event handler
onFocus(event: FocusEvent) => voidFocus event handler
onBlur(event: FocusEvent) => voidBlur event handler
classNamestringAdditional CSS class names
refReact.Ref<HTMLTextAreaElement>Forwarded ref to the textarea element

All standard HTML textarea attributes are also supported.

With Label

<TextArea label="Description" placeholder="Enter a description..." />

Row Heights

Control the visible height with the rows prop:

<TextArea label="2 rows" rows={2} placeholder="Small textarea..." />
<TextArea label="4 rows (default)" rows={4} placeholder="Default textarea..." />
<TextArea label="8 rows" rows={8} placeholder="Large textarea..." />

With Placeholder

<TextArea placeholder="Write your message here..." rows={4} />

Custom Caret

<TextArea label="Default caret" placeholder="Type here..." />
<TextArea label="Block caret" caretChars="█" placeholder="Type here..." />
<TextArea label="No blink" isBlink={false} placeholder="Type here..." />

States

<TextArea label="Default" placeholder="Enabled textarea" />
<TextArea label="Disabled" placeholder="Disabled textarea" disabled />
<TextArea label="Read-only" value="Read-only content..." readOnly />

Controlled with Character Count

const [value, setValue] = useState('');
const charCount = value.length;
const maxChars = 280;
 
<TextArea
  label="Tweet"
  value={value}
  onChange={(e) => setValue(e.target.value)}
  placeholder="What's happening?"
  rows={4}
  maxLength={maxChars}
/>
<div>{charCount}/{maxChars} characters</div>

Accessibility

  • Semantic <textarea> element with proper labeling
  • Supports all standard textarea attributes
  • Keyboard accessible with visible focus states
  • Works with screen readers

Styling

VariableDescription
--theme-borderTextarea border color
--theme-backgroundTextarea background color
--theme-textTextarea text color
--theme-focused-borderBorder color when focused
  • Input - Single-line text input
  • Select - Dropdown selection

On this page