A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, such as auto- correction, auto-capitalization, placeholder text, and different keyboard types, such as a numeric keypad.
The simplest use case is to plop down a TextInput and subscribe to the
onChangeText events to read the user input. There are also other events, such
as onSubmitEditing and onFocus that can be subscribed to. A simple
example:
The value prop can be used to set the value of the input in order to make
the state of the component clear, but <TextInput> does not behave as a true
controlled component by default because all operations are asynchronous.
Setting value once is like setting the default value, but you can change it
continuously based on onChangeText events as well. If you really want to
force the component to always revert to the value you are setting, you can
set controlled={true}.
The multiline prop is not supported in all releases, and some props are
multiline only.
Can tell TextInput to automatically capitalize certain characters.
If false, disables auto-correct. Default value is true.
If true, focuses the input on componentDidMount. Default value is false.
This helps avoid drops characters due to race conditions between JS and the native text input. The default should be fine, but if you're potentially doing very slow operations on every keystroke then you may want to try increasing this.
When the clear button should appear on the right side of the text view
If true, clears the text field automatically when editing begins
If you really want this to behave as a controlled component, you can set this true, but you will probably see flickering, dropped keystrokes, and/or laggy typing, depending on how you process onChange events.
If false, text is not editable. Default value is true.
If true, the keyboard disables the return key when there is no text and automatically enables it when there is text. Default value is false.
Determines which keyboard to open, e.g.numeric.
If true, the text input can be multiple lines. Default value is false.
Callback that is called when the text input is blurred
Callback that is called when the text input's text changes.
Callback that is called when the text input's text changes. Changed text is passed as an argument to the callback handler.
Callback that is called when text input ends.
Callback that is called when the text input is focused
Invoked on mount and layout changes with {x, y, width, height}.
Callback that is called when the text input's submit button is pressed.
If true, the text input obscures the text entered so that sensitive text like passwords stay secure. Default value is false.
The string that will be rendered before text input has been entered
The text color of the placeholder string
Determines how the return key should look.
If true, selected the text automatically when editing begins
See DocumentSelectionState.js, some state that is responsible for maintaining selection information for a document
Styles
Used to locate this view in end-to-end tests.
The default value for the text input