Input
Requires:
@ray-js/ray≥0.5.10
Description
Input field component supporting multiple input types and keyboard configurations.
Props
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
value | string | No | - | Input value |
type | "text" | "number" | "digit" | "idcard" | No | text | Input type |
name | string | No | - | Form field name, used as the key on form submit |
password | boolean | No | - | Whether the input is a password field |
placeholder | string | No | - | Placeholder when empty |
placeholderStyle | any | string | No | - | Placeholder style |
disabled | boolean | No | - | Whether disabled |
maxLength | number | No | 140 | Maximum input length; set to -1 for no limit |
confirmType | "send" | "search" | "next" | "go" | "done" | No | done | Set the label of the bottom-right keyboard button; effective only when type='text' |
| No | - | Triggered on keyboard input | ||
| No | - | Triggered when the Done button is tapped | ||
| No | - | Triggered on focus | ||
| No | - | Triggered on blur |
Valid Values
type
| Value | Description | Since |
|---|---|---|
text | Text input keyboard | - |
number | Numeric input keyboard | - |
digit | Numeric input keyboard with a decimal point | - |
idcard | ID card input keyboard | - |
confirmType
| Value | Description | Since |
|---|---|---|
send | The bottom-right button displays “Send” | - |
search | The bottom-right button displays “Search” | - |
next | The bottom-right button displays “Next” | - |
go | The bottom-right button displays “Go” | - |
done | The bottom-right button displays “Done” | - |
Examples
Basic usage
Different types
Input restrictions and disabled
FAQ
Does the input field support click events such as tap and touch?
Yes, all components support tap and touch events.
How do I clear input data using JS code?
Use setData to set the value attribute to empty. Make sure the value passed to setData is different from the current value.
How do I handle jumping or delayed input content?
You can use a debounce function to avoid frequent updates in the onInput callback.
What should I do if the input loses focus when typing Chinese on iOS?
On iOS, calling setData inside onInput can cause focus loss when typing Chinese. Options: ① Apply debounce to setData; ② Store data under this inside onInput to avoid triggering setData repeatedly.
Does the Input component support auto focus (autofocus)?
- Auto focus (autofocus) is not supported. Focus must be triggered by a user action.