Controlled Input
An input component with debounced value changes and Enter key submission.
Preview
Value:
Installation
Usage
Examples
With Accept Handler
Press Enter to accept the value and trigger the onAccepted callback.
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 Input component.
Behavior
- Debounced Changes: The
onValueChangedcallback is debounced by 500ms to avoid excessive updates - Enter Key: Pressing Enter immediately triggers both
onValueChangedandonAcceptedcallbacks, canceling any pending debounced update - External Updates: When the
valueprop changes externally, the component updates without triggering theonValueChangedcallback