Form
A form component built on top of react-hook-form with validation and field arrays support.
Anatomy
Usage
With Validation
Field Array
With Description
With Different Controls
Form.FieldComposed Props
| Prop | Type | Default |
|---|---|---|
render* | function | — |
name* | string | — |
rules | see more | — |
shouldUnregister | boolean | — |
defaultValue | any | — |
control | Control<TFieldValues, any, TFieldValues> | — |
disabled | boolean | — |
description | ReactNode | — |
label | ReactNode | — |
className | string | — |
FormRadix.Root Props
Root Form component from RadixUI. Provides form functionality and validation.
| Prop | Type | Default |
|---|---|---|
onClearServerErrors | function | — |
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
Form.Root Props
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | ReactNode[] | — |
watch* | UseFormWatch<TFieldValues> | — |
getValues* | UseFormGetValues<TFieldValues> | — |
getFieldState* | UseFormGetFieldState<TFieldValues> | — |
setError* | UseFormSetError<TFieldValues> | — |
clearErrors* | UseFormClearErrors<TFieldValues> | — |
setValue* | UseFormSetValue<TFieldValues> | — |
trigger* | UseFormTrigger<TFieldValues> | — |
formState* | FormState<TFieldValues> | — |
resetField* | UseFormResetField<TFieldValues> | — |
reset* | UseFormReset<TFieldValues> | — |
handleSubmit* | see more | — |
unregister* | UseFormUnregister<TFieldValues> | — |
control* | see more | — |
register* | UseFormRegister<TFieldValues> | — |
setFocus* | UseFormSetFocus<TFieldValues> | — |
subscribe* | UseFormSubscribe<TFieldValues> | — |
Form.FieldArrayRoot Props
| Prop | Type | Default |
|---|---|---|
name* | string | — |
keyName | string | "'id' as TKeyName" |
control | Control<TFieldValues, any, TFieldValues> | — |
rules | see more | — |
shouldUnregister | boolean | — |
defaultValues* | unknown | — |
children* | function | — |
className | string | — |
fieldClassName | string | — |
addButtonProps | any | "{}" |
addButtonChildren | ReactNode | "Add" |
min | number | "0" |
max | number | "Number.MAX_SAFE_INTEGER" |
hideCopy | boolean | — |
hideMove | boolean | — |
label | ReactNode | — |
Form Props
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | ReactNode[] | — |
watch* | UseFormWatch<TFieldValues> | — |
getValues* | UseFormGetValues<TFieldValues> | — |
getFieldState* | UseFormGetFieldState<TFieldValues> | — |
setError* | UseFormSetError<TFieldValues> | — |
clearErrors* | UseFormClearErrors<TFieldValues> | — |
setValue* | UseFormSetValue<TFieldValues> | — |
trigger* | UseFormTrigger<TFieldValues> | — |
formState* | FormState<TFieldValues> | — |
resetField* | UseFormResetField<TFieldValues> | — |
reset* | UseFormReset<TFieldValues> | — |
handleSubmit* | see more | — |
unregister* | UseFormUnregister<TFieldValues> | — |
control* | see more | — |
register* | UseFormRegister<TFieldValues> | — |
setFocus* | UseFormSetFocus<TFieldValues> | — |
subscribe* | UseFormSubscribe<TFieldValues> | — |
Form.Control Props
| Prop | Type | Default |
|---|---|---|
children | ReactNode | — |
className | string | — |
Form.Description Props
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
Form.Field Props
| Prop | Type | Default |
|---|---|---|
render* | function | — |
name* | string | — |
rules | see more | — |
shouldUnregister | boolean | — |
defaultValue | any | — |
control | Control<TFieldValues, any, TFieldValues> | — |
disabled | boolean | — |
Form.FieldArray Props
| Prop | Type | Default |
|---|---|---|
name* | string | — |
keyName | string | — |
control | Control<TFieldValues, any, TFieldValues> | — |
rules | see more | — |
shouldUnregister | boolean | — |
defaultValues* | unknown | — |
children* | function | — |
className | string | — |
fieldClassName | string | — |
addButtonProps | any | — |
addButtonChildren | ReactNode | — |
min | number | — |
max | number | — |
hideCopy | boolean | — |
hideMove | boolean | — |
label | ReactNode | — |
Form.FieldArrayControls Props
| Prop | Type | Default |
|---|---|---|
count* | number | — |
min* | number | — |
hideCopy | boolean | "false" |
hideMove | boolean | "false" |
Form.FieldArrayField Props
| Prop | Type | Default |
|---|---|---|
render* | function | — |
name* | string | — |
rules | see more | — |
shouldUnregister | boolean | — |
defaultValue | any | — |
control | Control<FieldValues, any, FieldValues> | — |
disabled | boolean | — |
className | string | — |
label | ReactNode | — |
Form.Item Props
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
Form.Label Props
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
Form.Message Props
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
FormRadix.Control Props
Form control primitive. Wraps form inputs and handles their state.
| Prop | Type | Default |
|---|---|---|
type | enum | — |
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
FormRadix.Description Props
Form description component. Provides additional context or instructions for form fields.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
FormRadix.Field Props
| Prop | Type | Default |
|---|---|---|
label | ReactNode | — |
description | ReactNode | — |
messages | see more | — |
name* | string | — |
serverInvalid | boolean | — |
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
FormRadix.Label Props
Form label component. Renders an accessible label for form controls.
| Prop | Type | Default |
|---|---|---|
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
FormRadix.Message Props
Form message component for validation and error messages. Displays feedback about the form field state.
| Prop | Type | Default |
|---|---|---|
match | see more | — |
forceMatch | boolean | — |
name* | string | — |
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
FormRadix.Submit Props
Submit button primitive for forms.
| Prop | Type | Default |
|---|---|---|
type | enum | — |
className | string | — |
children | ReactNode | — |
asChild | boolean | — |
FormRadix.ValidityState Props
| Prop | Type | Default |
|---|---|---|
children* | function | — |
name* | string | — |
__scopeForm | Scope | — |