Import
Basic Usage
Props
Value Props
The value to show for the text input. TextInput is a controlled component, which means the native value will be forced to match this value prop if provided.
Provides an initial value that will change when the user starts typing. Useful for use-cases where you do not want to deal with listening to events and updating the value prop to keep the controlled state in sync.
Input Behavior
If false, text is not editable.
If true, the text input can be multiple lines. The default value is false.
Limits the maximum number of characters that can be entered.
Sets the number of lines for a TextInput. Use it with multiline set to true to be able to fill the lines.
Keyboard Configuration
Determines which keyboard to open.Cross-platform values: ‘default’, ‘number-pad’, ‘decimal-pad’, ‘numeric’, ‘email-address’, ‘phone-pad’, ‘url’iOS-only: ‘ascii-capable’, ‘numbers-and-punctuation’, ‘name-phone-pad’, ‘twitter’, ‘web-search’Android-only: ‘visible-password’
Determines how the return key should look.Cross-platform: ‘done’, ‘go’, ‘next’, ‘search’, ‘send’iOS: ‘default’, ‘google’, ‘join’, ‘route’, ‘yahoo’, ‘emergency-call’Android: ‘none’, ‘previous’
Can tell TextInput to automatically capitalize certain characters.
characters- All characterswords- First letter of each wordsentences- First letter of each sentence (default)none- Don’t auto capitalize anything
If false, disables auto-correct. The default value is true.
Specifies autocomplete hints for the system, so it can provide autofill. On Android, the system will always attempt to offer autofill by using heuristics to identify the type of content. On iOS, you must explicitly set the autocomplete type.
Works like the inputmode attribute in HTML, it determines which keyboard to open, e.g. numeric and has precedence over keyboardType.Options: ‘none’, ‘text’, ‘decimal’, ‘numeric’, ‘tel’, ‘search’, ‘email’, ‘url’
Determines what text should be shown to the return key on virtual keyboards.Options: ‘enter’, ‘done’, ‘go’, ‘next’, ‘previous’, ‘search’, ‘send’
Visual Props
The string that will be rendered before text input has been entered.
The text color of the placeholder string.
Styles to apply to the text input.
If true, the text input obscures the text entered so that sensitive text like passwords stay secure.
Selection Props
The start and end of the text input’s selection. Set start and end to the same value to position the cursor.
The highlight and cursor color of the text input.
When provided it will set the color of the cursor (or “caret”) in the component. Unlike the behavior of selectionColor the cursor color will be set independently from the color of the text selection box.
If true, all text will automatically be selected on focus.
Event Handlers
Callback that is called when the text input’s text changes. Changed text is passed as a single string argument to the callback handler.
Callback that is called when the text input’s text changes.
Callback that is called when the text input is focused.
Callback that is called when the text input is blurred.
Callback that is called when the text input’s submit button is pressed.
Callback that is called when text input ends.
Callback that is called when a key is pressed. This will be called with
{nativeEvent: {key: keyValue}} where keyValue is ‘Enter’ or ‘Backspace’ for respective keys and the typed-in character otherwise including ’ ’ for space.Callback that is called when the text input selection is changed.
Callback that is called when the text input’s content size changes. This will be called with
{nativeEvent: {contentSize: {width, height}}}.Identification Props
Used to reference the text input from native code.
Used to locate this view in end-to-end tests.
Platform-Specific Props
- iOS
- Android
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 true, the keyboard disables the return key when there is no text and automatically enables it when there is text.
Determines the color of the keyboard.
If false, disables spell-check style (i.e. red underlines). The default value is inherited from autoCorrect.
Give the keyboard and the system information about the expected semantic meaning for the content that users enter.Options include: ‘none’, ‘URL’, ‘addressCity’, ‘addressCityAndState’, ‘addressState’, ‘countryName’, ‘creditCardNumber’, ‘emailAddress’, ‘familyName’, ‘fullStreetAddress’, ‘givenName’, ‘jobTitle’, ‘location’, ‘middleName’, ‘name’, ‘namePrefix’, ‘nameSuffix’, ‘nickname’, ‘organizationName’, ‘postalCode’, ‘streetAddressLine1’, ‘streetAddressLine2’, ‘sublocality’, ‘telephoneNumber’, ‘username’, ‘password’, ‘newPassword’, ‘oneTimeCode’
When using textContentType as newPassword, we can let the OS know the requirements of the password so that it can autogenerate one that will satisfy them.
Methods
Makes the text input get focus.
Makes the text input lose focus.
Removes all text from the TextInput.
Returns true if the input is currently focused; false otherwise.