useInputValue
Unified form input and textarea value binder supporting tuple destructuring, object spreading, and reset/clear actions.
2 KB
•Updated on September 3, 2026
Installation
Bash
pnpm dlx shadcn@latest add @spaceui/hooks-form-use-input-valueUsage
Code
import { useInputValue } from '@/hooks/use-input-value'
export default function SpaceUI() {
// Pattern 1: Tuple destructuring with binder
const [value, bind, { reset, clear }] = useInputValue('Space UI')
return <input {...bind} />
}API Reference
Parameters / Props
| Parameter | Type | Default | Description |
|---|---|---|---|
initialValue | string | - | Initial text value for the input. |
Return Value
| Property | Type | Description |
|---|---|---|
[0] (or value) | string | Current string value. |
[1] (or bind) | { value, onChange } | Ready-to-spread props object for <input /> or <textarea />. |
[2] | { setValue, reset, clear } | Action helpers object. |
onChange | Function | React change event handler. |
reset() | Function | Resets field to initialValue. |
clear() | Function | Clears field to empty string. |