Form
A headless Form component for ReactLynx. It provides form context and a submit button that collects field values.Info
You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.
Basic Usage
Use <Form> to manage form state, handle form validation, and submission
Examples
Avoiding Keyboard Overlap
Prevent the on-screen keyboard from obscuring the input field by automatically adjusting the view when the keyboard appears
Structure
Component API
FormRoot
childreniOSAndroidHarmony
The content of the form.
initialValuesiOSAndroidHarmony
The initial values of the form fields.
onChangediOSAndroidHarmony
Callback function triggered when any field's value changes. It receives the entire form's data.
onSubmitiOSAndroidHarmony
Callback function triggered when the form is submitted.
FormField
asiOSAndroidHarmony
Specifies the type of component to render.
childreniOSAndroidHarmony
The child elements of the form field, usually used for labels or complex structures.
classNameiOSAndroidHarmony
className
confirmTypeiOSAndroidHarmony
The type of confirm button
idiOSAndroidHarmony
The id of the input
inputFilteriOSAndroidHarmony
Filter the input content and process it in the form of regular expressions
maxLengthiOSAndroidHarmony
Max input length
nameiOSAndroidHarmony
The unique identifier for the form field.
onBluriOSAndroidHarmony
Blurred
onChangediOSAndroidHarmony
Callback function triggered when this specific field's value changes.
onConfirmiOSAndroidHarmony
Confirm button clicked
onFocusiOSAndroidHarmony
Focused
onSelectionChangeiOSAndroidHarmony
Input selection changed
placeholderiOSAndroidHarmony
Placeholder
readonlyiOSAndroidHarmony
Interaction enabled
ref
showSoftInputOnFocusiOSAndroidHarmony
Show soft input keyboard while focused
styleiOSAndroidHarmony
style
typeiOSAndroidHarmony
Input content type
disablediOSAndroidHarmony
If set to true, the RadioGroup can not accept interactions.
checkboxPropsiOSAndroid
Checkbox supports original view props to be directly spread in this prop.
indeterminateiOSAndroid
The indeterminate state of the Checkbox.
bouncesiOS
Bounce effect for iOS
lineSpacingiOSAndroid
Line spacing
maxLinesiOSAndroidHarmony
Max input lines
switchPropsiOSAndroid
Switch supports original view props to be directly spread in this prop.
FormSubmitButton
buttonPropsiOSAndroidHarmony
Button supports original view props to be directly spread in this prop.
classNameiOSAndroidHarmony
className
disablediOSAndroidHarmony
Determines whether the button is disabled.
onSubmitiOSAndroidHarmony
Callback function triggered when the submit button is clicked, after the form's internal submit logic.
styleiOSAndroidHarmony
style
childreniOSAndroidHarmony
children
State-based styling & rendering
This component exposes runtime states through one or both of the following channels. The table lists only the channels available for each state:
- UI variant class — when supported, a class like
ui-<state>is toggled on the corresponding component node for selectors such as.ui-<state> { ... }. - Render-prop field — when supported and
childrenis a function, the state is passed in viachildren({ <state>: boolean, ... })for runtime-driven rendering.
UI variants applied by FormSubmitButton based on its render state.
| Class Name | Render Prop | Type | Description |
|---|---|---|---|
| ui-active | active | boolean | Whether the button is currently being pressed (and not disabled). Applied while the submit button is pressed and not disabled. |
| ui-disabled | disabled | boolean | Whether the button is disabled. Applied when the submit button is disabled. |