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
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | 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 |
className | string | - | Additional CSS classes |
All other props are passed through to the underlying Textarea component.
Behavior
- Debounced Changes: The
onValueChangedcallback is debounced by 500ms to avoid excessive updates - Enter Key: Pressing Enter (without Shift) triggers both
onValueChangedandonAcceptedcallbacks ifonAcceptedis provided - New Lines: Pressing Shift+Enter creates a new line without triggering acceptance
- External Updates: When the
valueprop changes externally, the component updates without triggering theonValueChangedcallback - No Accept Handler: If
onAcceptedis not provided, Enter key behaves normally (creates new line)