For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/ui/components/form.md.
lynx-ui logo
lynx-ui
  • English
  • 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

    <FormRoot>
      <FormField />
      <FormSubmitButton />
    </FormRoot>

    Component API

    FormRoot

    childreniOSAndroidHarmony
    TypeReactNode
    The content of the form.
    initialValuesiOSAndroidHarmony
    TypeRecord<string, unknown>
    The initial values of the form fields.
    onChangediOSAndroidHarmony
    Type(values: Record<string, unknown>) => void
    Callback function triggered when any field's value changes. It receives the entire form's data.
    onSubmitiOSAndroidHarmony
    Type(values: Record<string, unknown>) => void
    Callback function triggered when the form is submitted.

    FormField

    asiOSAndroidHarmony
    TypeInput | RadioGroupRoot | Checkbox | TextArea | Switch
    Specifies the type of component to render.
    childreniOSAndroidHarmony
    TypeReactNode
    The child elements of the form field, usually used for labels or complex structures.
    classNameiOSAndroidHarmony
    Typestring
    className
    confirmTypeiOSAndroidHarmony
    Typesend | search | go | done | next·Default'send'
    The type of confirm button
    idiOSAndroidHarmony
    Typestring·Default'input'
    The id of the input
    inputFilteriOSAndroidHarmony
    Typestring
    Filter the input content and process it in the form of regular expressions
    maxLengthiOSAndroidHarmony
    Typenumber·Default140
    Max input length
    nameiOSAndroidHarmony
    Typestring
    The unique identifier for the form field.
    onBluriOSAndroidHarmony
    Type(value: string) => void
    Blurred
    onChangediOSAndroidHarmony
    Type(value: unknown) => void
    Callback function triggered when this specific field's value changes.
    onConfirmiOSAndroidHarmony
    Type(value: string) => void
    Confirm button clicked
    onFocusiOSAndroidHarmony
    Type(value: string) => void
    Focused
    onSelectionChangeiOSAndroidHarmony
    Type(selectionStart: number, selectionEnd: number) => void
    Input selection changed
    placeholderiOSAndroidHarmony
    Typestring
    Placeholder
    readonlyiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Interaction enabled
    ref
    TypeForwardedRef<{blur: () => Promise<void>, focus: () => Promise<void>, getValue: () => Promise<{selectionEnd: number, selectionStart: number, value: string}>, setSelectionRange: (selectionStart: number, selectionEnd: number) => Promise<void>, setValue: (value: string) => Promise<void>}>
    showSoftInputOnFocusiOSAndroidHarmony
    Typeboolean·Defaulttrue
    Show soft input keyboard while focused
    styleiOSAndroidHarmony
    TypeCSSProperties
    style
    typeiOSAndroidHarmony
    Typenumber | text | digit | password | tel | email·Default"text"
    Input content type
    disablediOSAndroidHarmony
    Typeboolean·Defaultfalse
    If set to true, the RadioGroup can not accept interactions.
    checkboxPropsiOSAndroid
    TypeViewProps
    Checkbox supports original view props to be directly spread in this prop.
    indeterminateiOSAndroid
    Typeboolean·Defaultfalse
    The indeterminate state of the Checkbox.
    bouncesiOS
    Typeboolean·Defaulttrue
    Bounce effect for iOS
    lineSpacingiOSAndroid
    Typenumber | px | rpx
    Line spacing
    maxLinesiOSAndroidHarmony
    Typenumber·Default40
    Max input lines
    switchPropsiOSAndroid
    TypeViewProps
    Switch supports original view props to be directly spread in this prop.

    FormSubmitButton

    buttonPropsiOSAndroidHarmony
    TypeViewProps
    Button supports original view props to be directly spread in this prop.
    classNameiOSAndroidHarmony
    Typestring
    className
    disablediOSAndroidHarmony
    Typeboolean·Defaultfalse
    Determines whether the button is disabled.
    onSubmitiOSAndroidHarmony
    Type(values: Record<string, unknown>) => void
    Callback function triggered when the submit button is clicked, after the form's internal submit logic.
    styleiOSAndroidHarmony
    TypeCSSProperties
    style
    childreniOSAndroidHarmony
    Type| ReactNode | ((state: {active: boolean, disabled: boolean}) => ReactNode)
    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 children is a function, the state is passed in via children({ <state>: boolean, ... }) for runtime-driven rendering.

    UI variants applied by FormSubmitButton based on its render state.

    Class NameRender PropTypeDescription
    ui-activeactivebooleanWhether the button is currently being pressed (and not disabled). Applied while the submit button is pressed and not disabled.
    ui-disableddisabledbooleanWhether the button is disabled. Applied when the submit button is disabled.
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.