Controlled Textarea

A textarea component with debounced value changes and Enter key submission.

Preview

Value:

Installation

Usage

Examples

With Accept Handler

Press Enter to accept the value (Shift+Enter for new line).

Current:

Accepted:

API Reference

PropTypeDefaultDescription
valuestring-The controlled value
onValueChanged(value: string) => void-Callback triggered when value changes (debounced 500ms)
onAccepted(value: string) => void-Callback triggered when Enter key is pressed
classNamestring-Additional CSS classes

All other props are passed through to the underlying Textarea component.

Behavior

  • Debounced Changes: The onValueChanged callback is debounced by 500ms to avoid excessive updates
  • Enter Key: Pressing Enter (without Shift) triggers both onValueChanged and onAccepted callbacks if onAccepted is provided
  • New Lines: Pressing Shift+Enter creates a new line without triggering acceptance
  • External Updates: When the value prop changes externally, the component updates without triggering the onValueChanged callback
  • No Accept Handler: If onAccepted is not provided, Enter key behaves normally (creates new line)