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/input.md.
lynx-ui logo
lynx-ui
  • English
  • Input

    A headless Input component for ReactLynx. It provides primitives for text entry and keyboard awareness.
    Info

    You can check the source code to understand how it works, and you're welcome to submit PRs to enhance its capabilities.

    Input component that supports controlled, uncontrolled, and keyboard avoidance capabilities. Use <Input> for single-line input and <TextArea> for multi-line input.

    Basic Usage

    Use <Input> to render a single-line input field, and <TextArea> to render a multi-line text area.

    Examples

    Avoiding Keyboard Overlap

    Prevent the on-screen keyboard from obscuring the input field by automatically adjusting the view when the keyboard appears

    Structure

    Input and TextArea can be used independently:

    <Input />
    <TextArea />

    Use the keyboard-aware parts when an input should remain visible above the keyboard:

    <KeyboardAwareRoot>
      <KeyboardAwareResponder>
        <KeyboardAwareTrigger>
          <Input />
        </KeyboardAwareTrigger>
        <KeyboardAwareTrigger>
          <TextArea />
        </KeyboardAwareTrigger>
      </KeyboardAwareResponder>
    </KeyboardAwareRoot>

    Component API

    Input

    classNameiOSAndroidHarmony
    Typestring
    className
    confirmTypeiOSAndroidHarmony
    Typesend | search | go | done | next·Default'send'
    The type of confirm button
    defaultValueiOSAndroidHarmony
    Typestring
    The value of the input
    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
    onBluriOSAndroidHarmony
    Type(value: string) => void
    Blurred
    onConfirmiOSAndroidHarmony
    Type(value: string) => void
    Confirm button clicked
    onFocusiOSAndroidHarmony
    Type(value: string) => void
    Focused
    onInputiOSAndroidHarmony
    Type(value: string, selectionStart: number, selectionEnd: number, isComposing?: boolean) => void
    Input content changed
    onSelectionChangeiOSAndroidHarmony
    Type(selectionStart: number, selectionEnd: number) => void
    Input selection changed
    placeholderiOSAndroidHarmony
    Typestring
    Placeholder
    readonlyiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Interaction enabled
    ref
    TypeForwardedRef<InputRef>
    showSoftInputOnFocusiOSAndroidHarmony
    Typeboolean·Defaulttrue
    Show soft input keyboard while focused
    styleiOSAndroidHarmony
    TypeCSSProperties
    style
    typeiOSAndroidHarmony
    Typenumber | text | digit | password | tel | email·Default"text"
    Input content type
    valueiOSAndroidHarmony
    Typestring
    The controlled value of the input

    TextArea

    bouncesiOS
    Typeboolean·Defaulttrue
    Bounce effect for iOS
    classNameiOSAndroidHarmony
    Typestring
    className
    confirmTypeiOSAndroidHarmony
    Typesend | search | go | done | next·Default'send'
    The type of confirm button
    defaultValueiOSAndroidHarmony
    Typestring
    The value of the input
    idiOSAndroidHarmony
    Typestring·Default'input'
    The id of the input
    inputFilteriOSAndroidHarmony
    Typestring
    Filter the input content and process it in the form of regular expressions
    lineSpacingiOSAndroid
    Typenumber | px | rpx
    Line spacing
    maxLengthiOSAndroidHarmony
    Typenumber·Default140
    Max input length
    maxLinesiOSAndroidHarmony
    Typenumber·Default40
    Max input lines
    onBluriOSAndroidHarmony
    Type(value: string) => void
    Blurred
    onConfirmiOSAndroidHarmony
    Type(value: string) => void
    Confirm button clicked
    onFocusiOSAndroidHarmony
    Type(value: string) => void
    Focused
    onInputiOSAndroidHarmony
    Type(value: string, selectionStart: number, selectionEnd: number, isComposing?: boolean) => void
    Input content changed
    onSelectionChangeiOSAndroidHarmony
    Type(selectionStart: number, selectionEnd: number) => void
    Input selection changed
    placeholderiOSAndroidHarmony
    Typestring
    Placeholder
    readonlyiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Interaction enabled
    ref
    TypeForwardedRef<TextAreaRef>
    showSoftInputOnFocusiOSAndroidHarmony
    Typeboolean·Defaulttrue
    Show soft input keyboard while focused
    styleiOSAndroidHarmony
    TypeCSSProperties
    style
    typeiOSAndroidHarmony
    Typenumber | text | digit | password | tel | email·Default"text"
    Input content type
    valueiOSAndroidHarmony
    Typestring
    The controlled value of the input

    KeyboardAwareRoot

    androidStatusBarPlusBottomBarHeightAndroid
    Typenumber·Default0
    The height of the Android status bar and bottom navigation bar needs to be set. If your App has an immersive status bar, only the height of the bottom navigation bar needs to be passed in. In px.
    childreniOSAndroidHarmony
    TypeReactNode
    Children
    forceAttachiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Whether to force attach the root component

    KeyboardAwareTrigger

    childreniOSAndroidHarmony
    TypeReactNode
    Children
    classNameiOSAndroidHarmony
    Typestring
    className
    offsetiOSAndroidHarmony
    Typenumber·Default0
    Additional Offset, in px
    styleiOSAndroidHarmony
    TypeCSSProperties
    style

    KeyboardAwareResponder

    Properties
    androidTouchSlopAndroid
    Typedefault | paging
    Android touch recognition mode. When inside a component that supports 'paging' mode, 'paging' must be enabled.
    asiOSAndroidHarmony
    TypeView | ScrollView·Default'View'
    The type of the root component
    bounceableiOSAndroid
    Typeboolean
    Enable bouncing effect
    bounceableOptionsiOSAndroid
    Typeboolean | {alwaysBouncing?: boolean, enableBounceEventInFling?: boolean, enableBounces: boolean, endBounceTriggerDistance?: number, estimatedHeight?: number, estimatedWidth?: number, lowerBounceItem?: any, onScrollToBounces?: (e: ScrollToBouncesInfo) => void, singleSidedBounce?: upper | lower | both | iOSBounces | none, startBounceTriggerDistance?: number, upperBounceItem?: any, validAnimationVersion?: boolean}·Default{ enableBounces: true, singleSidedBounce: "iOSBounces" },
    Props for bouncing effect
    childreniOSAndroid
    TypeReactNode
    Children in scroll-view.
    classNameiOSAndroidHarmony
    Typestring
    className
    debugLogiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Display debug logs for bounce interactions.
    enableNewArchiOSAndroidHarmony
    Typeboolean·Defaulttrue on Lynx SDK >= 4.3; false otherwise
    Enable the native <scroll-view> new architecture. When enabled, bounceableOptions uses native bounces on Android, iOS, and Harmony. Defaults to true on Lynx SDK 4.3 and newer, and false on earlier versions.
    enableRTLiOSAndroidHarmony
    Typeboolean·Defaultfalse
    Whether horizontal bounce direction should be mirrored in RTL mode.
    enableScrolliOSAndroidHarmony
    Typeboolean·Defaulttrue
    Enable scroll interaction.
    enableScrollMonitoriOSAndroidHarmony
    Typeboolean·Defaultfalse
    Enable scroll monitor.
    estimatedItemStyleiOSAndroid
    TypeCSSProperties
    Estimated height and width of the items need to be set.
    experimentalNestedScrollBackwardHarmony
    TypeselfOnly | selfFirst | parentFirst | parallel
    Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.
    experimentalNestedScrollForwardHarmony
    TypeselfOnly | selfFirst | parentFirst | parallel
    Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.
    exposureBottomiOSAndroid
    Typestring·Default'10px'
    exposure-screen-margin-bottom
    exposureIDiOSAndroidHarmony
    Typestring
    exposure-id for global exposure
    exposureLeftiOSAndroid
    Typestring·Default'10px'
    exposure-screen-margin-left
    exposureRightiOSAndroid
    Typestring·Default'10px'
    exposure-screen-margin-right
    exposureSceneiOSAndroidHarmony
    Typestring
    exposure-scene for global exposure
    exposureTopiOSAndroid
    Typestring·Default'10px'
    exposure-screen-margin-top
    firstScreenItemCountiOSAndroid
    Typenumber·Default1
    Estimated first screen item count for lazy rendering. Remaining children will complete rendering based on exposure. When this estimate is small, it may cause a blank screen phenomenon where some nodes exist on the first screen.
    iOSBouncesiOSAndroid
    Typeboolean·Defaulttrue
    Open the bouncing effect on iOS. If you want to use it on Android, please refer to the bounceableOption. If the bounceableOption is set, the iOSBounces property will be invalid.
    lazyiOSAndroid
    Typeboolean·Defaulttrue
    When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.
    lazyOptionsiOSAndroid
    TypeLazyOptions·Defaulttrue
    When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.
    main-thread:gestureiOSAndroid
    TypeBaseGesture<BaseGestureConfig, GestureChangeEvent>
    If you want to use gesture, pass it here.
    onUIAppeariOSAndroidHarmony
    Type(e: CommonEvent) => void
    Exposure event for UI
    onUIDisappeariOSAndroidHarmony
    Type(e: CommonEvent) => void
    Disappear event for UI
    ref
    TypeForwardedRef<KeyboardAwareResponderRef>
    sceneiOSAndroid
    Typestring
    Be used to mark the exposure timing of lazy loading. Please ensure that it is unique throughout the page.
    scrollMonitorTagiOSAndroidHarmony
    Typestring·Defaultfalse
    The tag for scroll monitor.
    scrollOrientationiOSAndroidHarmony
    Typehorizontal | vertical·Default'vertical'
    Set to 'vertical' for vertical scrolling and set to 'horizontal' for horizontal scrolling.
    scrollPropagationBehavioriOSAndroid
    TypeScrollPropagationBehaviorOption·Default'native'
    Controls whether scroll events propagate to parent containers. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
    scrollviewIdiOSAndroid
    Typestring·Default"scrollview"
    The id of the scrollview.
    stickyiOSAndroid
    TypeReactElement<any, string | JSXElementConstructor<any>>
    Sticky item, designed for Tabs.
    styleiOSAndroid
    TypeCSSProperties
    Styles for KeyboardAwareResponder KeyboardAwareResponder 的样式
    temporaryBlockScrollClassiOS
    Typestring·Default'BDXLynxViewPager'
    The specific class name of the container that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', must be informed by the container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
    temporaryBlockScrollTagiOS
    Typenumber·Default0
    Used to specify the native container tag that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', corresponding to the Tag attribute of UIView. Needs to be specified by the native container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
    temporaryNestedScrollAndroid
    Typeboolean
    Android-only temporary flag to control nested scroll; maps to native 'enable-nested-scroll'. Android default value is true.
    testingiOSAndroid
    Typeboolean
    Testing Mode.
    Events
    catchLongPressiOSAndroidHarmony
    Type(e: EventHandler<BaseTouchEvent<Target>> | undefined) => void
    Same as onLongPress, but stops the event from propagating to parent elements.
    catchTouchCanceliOSAndroidHarmony
    Type(e: TouchEvent) => void
    Same as onTouchCancel, but stops the event from propagating to parent elements.
    catchTouchEndiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Same as onTouchEnd, but stops the event from propagating to parent elements.
    catchTouchMoveiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Same as onTouchMove, but stops the event from propagating to parent elements.
    catchTouchStartiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Same as onTouchStart, but stops the event from propagating to parent elements.
    onContentSizeChangeiOSAndroid
    Type(res: {detail: {scrollHeight: number, scrollWidth: number}}) => void
    Being triggered when scrolling content changes.
    onLayoutChangeiOSAndroidHarmony
    Type(e: EventHandler<LayoutChangeDetailEvent<Target>> | undefined) => void
    Send when UI has changed viewport size.
    onLongPressiOSAndroidHarmony
    Type(e: EventHandler<BaseTouchEvent<Target>> | undefined) => void
    Send when a touch-point is held on the UI for a period of time.
    onScrolliOSAndroid
    Type(e: ScrollEvent) => void
    Being triggered when scrolling occurs.
    onScrollEndiOSAndroid
    Type(e: ScrollEndEvent) => void·Defaultundefined
    Being triggered when scrolling stops.
    onScrollToLoweriOSAndroid
    Type(e: ScrollToLowerEvent) => void·Defaultundefined
    Being triggered when scrolling to lower.
    onScrollToUpperiOSAndroid
    Type(e: ScrollToUpperEvent) => void·Defaultundefined
    Being triggered when scrolling to upper.
    onTapiOSAndroidHarmony
    Type(e: EventHandler<BaseTouchEvent<Target>> | undefined) => void
    Send when a touch-point is tapped on the UI.
    onTouchCanceliOSAndroidHarmony
    Type(e: TouchEvent) => void
    Send when a touch event is interrupted or cancelled before it is completed.
    onTouchEndiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Send when a touch-point is removed from the UI.
    onTouchMoveiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Send when a touch-point is moving on the UI.
    onTouchStartiOSAndroidHarmony
    Type(e: TouchEvent) => void
    Send when a touch-point is placed on the UI.
    onWheel
    Type(e: CommonEvent) => void
    Send when a wheel event is triggered on the scroll-view.

    InputRef

    bluriOSAndroidHarmony
    Type() => Promise<void>
    Release focus
    focusiOSAndroidHarmony
    Type() => Promise<void>
    Require focus
    getValueiOSAndroidHarmony
    Type() => Promise<{selectionEnd: number, selectionStart: number, value: string}>
    Get input content
    setSelectionRangeiOSAndroidHarmony
    Type(selectionStart: number, selectionEnd: number) => Promise<void>
    Set selection range
    setValueiOSAndroidHarmony
    Type(value: string) => Promise<void>
    Set input content

    TextAreaRef

    bluriOSAndroidHarmony
    Type() => Promise<void>
    Release focus
    focusiOSAndroidHarmony
    Type() => Promise<void>
    Require focus
    getValueiOSAndroidHarmony
    Type() => Promise<{selectionEnd: number, selectionStart: number, value: string}>
    Get input content
    setSelectionRangeiOSAndroidHarmony
    Type(selectionStart: number, selectionEnd: number) => Promise<void>
    Set selection range
    setValueiOSAndroidHarmony
    Type(value: string) => Promise<void>
    Set input content

    KeyboardAwareResponderRef

    as
    Type() => View | ScrollView
    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.