useFormControl
Use the form control's state for more advanced composition.
You can use useFormControl
within the context of a Control component to access the state of the control and use it as you see fit.
Usage
Say we're building a custom component that contains both a custom input and label.
In this example, we're using useFormControl
to get the spreadable for the label and control elements. We then pass those attributes to our custom components.
We'd then use this within the context of a Control
component like so:
API Reference
Props
Optionally provide a getter function that returns a custom ID to override the default control ID.
Return Type
useFormControl
returns the following types:
Warning
The useFormControl
function returns getters for the various reactive states. You should not destructure the object returned by useFormControl
and instead use the getters directly.