Integrate a custom input
A custom text component needs to participate in Conform validation and submission.
Conform · Const
useInputControl connects controlled or custom React inputs to Conform by exposing their current value and helpers that simulate native input events.
Use useInputControl when a custom or controlled input must integrate with Conform. Read the current value from the returned control and call its event helpers so Conform receives browser-like updates without requiring direct native input handling.
const control = useInputControl(metaOrOptions);| Name | Type | Description |
|---|---|---|
metaOrOptions | Field metadata | options object | Field metadata or an options object containing key, name, formId, and initialValue. |
An input control object exposing the current value and helpers for simulating browser events.
useInputControl is a React hook for dispatching browser-like events from a controlled or custom input.control.value as the current input value when rendering a controlled component.control.change(value) to update the value and emit the events Conform expects.control.blur() to report that the logical input lost focus.control.focus() to simulate focus-related events programmatically.useInputControl resets its value when the field key changes.blur() or focus() simulates events but does not move the browser's actual keyboard focus.const control = useInputControl(meta);
return (
<input
name={meta.name}
value={control.value ?? ''}
onChange={(event) => control.change(event.target.value)}
onBlur={() => control.blur()}
/>
);Connects a controlled input to Conform by reading its value and forwarding change and blur events.
A custom text component needs to participate in Conform validation and submission.
A React component owns its value state but must notify Conform of updates.
An application needs to trigger input, blur, or focus behavior programmatically.
useInputControl for a controlled input?useInputControl provides a control object for integrating custom inputs with Conform. Its value can drive the controlled component, while change(value) emits both change and input events.
Follow-up: How would you notify Conform that interaction ended? Call control.blur(), which simulates blur and focusout without moving real keyboard focus.
useInputControl?Pass field metadata or an options object containing key, name, formId, and initialValue to useInputControl. The hook then returns an input-control object with the current value and event helpers.
Follow-up: What field identity matters when resetting? The field key is used to coordinate remounting and can cause the controlled value to reset when it changes.
The hook simulates browser events, but its focus helpers do not actually move keyboard focus. For a custom input, listen for focus and call the desired element's native focus() method when real focus delegation is required.
Follow-up: Why can automatic invalid-field focusing fail? Conform may not know which custom element should receive focus, so the component must forward focus explicitly.
useControlgetInputPropsgetFormPropsfield metadata