React Native Input:
How to Enter Text and Delete It Easily

What is the input element for, and how to implement it in React Native?
Any developer who uses React Native will know about the importance of placing text input. There will always be a field where users must enter information in any web or mobile app. For example, when registering on a specific platform, especially in products built through Cross-Platform App Development Services, where consistent user experience across devices is key.
In any web application, you’re going to need to use a simple input tag. This is what you know as <input>. The React Native input will allow you to implement this feature in this framework. You will do it using an element called TextInput.
In its most basic form, it would look like this:
import React from 'react'
import { StyleSheet, Text, View, TextInput } from 'react-native'
const ExampleScreen = () => {
return (
<View>
<Text>Enter Text:</Text>
<TextInput />
</View>
)
}
const styles = StyleSheet.create({})It is important to note that React Native elements are available in a basic version. This means the TextInput appears without any styling. So, if you don’t modify it, the user will hardly find a way to interact with it. We will show you how to give it a basic styling to improve the functionality.
How to apply basic and functional styling to the text input in React Native?
If you want to see the TextInput, you will need to add a basic style to it. For example, by creating a margin. For that, you will need to add a new object. It would be done as follows:
const styles = StyleSheet.create({
input: {
margin: 15,
borderColor: 'black',
borderWidth: 1
}
})
return (
<View>
<Text> Enter Text: </Text>
<TextInput style={styles.input}/>
</View>
)You’re done! You can now manage the entry’s status.

How to manage the text input status?
Now, you will have to add the state to the component. If you look closely, the previous component has a functional structure. Therefore, you will have to use the “useState” hook, which, as its name suggests, will help the user interact with it.
You should apply:
import React {useState} from 'react
const ExampleScreen = () => {
const [text, setText] = useState('')
return (
<View>
<Text> Enter Text: </Text>
<TextInput style={styles.input}/>
</View>
)
}The value “text” would be transformed into a state value if it were a class component. In such a case, it would look as follows:
state = {
text: ''
}
this.setState({
text: "someNewText"
})Using JSX, you can display the current status in the interface of your creation. Basically, you will have to add a new text element to the component:
const ExampleScreen = () => {
const [text, setText] = useState('')
return (
<View>
<Text> Enter Text: </Text>
<TextInput style={styles.input}/>
<Text> Text: {text} </Text>
</View>
)
}The state is already initialized. However, now you will be able to incorporate a callback through the “value” attribute and the “onChangeText” event as follows:
const ExampleScreen = () => {
const [text, setText] = useState('')
return (
<View>
<Text> Enter Text:</Text>
<TextInput
style={styles.input}
value={text}
onChangeText={(newValue)=> setText(newValue)}/>
<Text> Text: {text}</Text>
</View>
)
}
How to delete a text entry easily on Android and iOS?
You already know that text input components in React Native are known as TextInput. In some systems, such as iOS, editable inputs do not automatically include a clear button. However, a clear functionality can be added through the clearButtonMode.
Whereas:
enum(‘never’, ‘while-editing’, ‘unless-editing’, ‘always’)
Note that the value defaults to “never”. However, you must set it to “always” so that you can apply it on iOS.
However, on Android, it will be somewhat different. For that, you are going to have to add a button on the right side, through the TouchableOpacity component. You can do it in the following way:
<TouchableOpacity
style={styles.closeButtonParent}
onPress={() => setText('')}>
<Image
style={styles.closeButton}
source={require('./assets/close.png')}/>
</TouchableOpacity>Touching it will delete the text that has been placed.
<TextInput
style={styles.textInput}
value={text}
onChangeText={value => setText(value)}/>You’re done! You now know what you need to do to delete text in React Native.

Incorporate other useful attributes in the TextInputs
Although you already have basic functionality, you will enhance it by adding new attributes to TextInputs. Here are some of the most popular ones:
- autoCapitalize. This is one of the most well-known attributes. In this case, it refers to the possibility of automatically capitalizing the first value in the TextInput, although it can also be applied to a specific one. The default setting is activated with the first letter, generally for first and last names, although you can customize it.
- autoCompleteType. Another handy attribute is especially useful for database fields where users want to fill in the information they use most often when creating accounts. For example, email or password. You can enable or disable it without any problems.
- autoCorrect. Finally, you can also automatically correct some spelling or syntax problems. By default, it will be activated, but you can change it if you feel it is not necessary.
The importance of the different uses in React Native
As you can see, this JavaScript framework is really useful for creating native apps on iOS and Android. Since they are two different operating systems, it is expected that modifications will be made for one of them, as was the case with deleting text inputs.
However, once you learn the basics of each OS, you will realize that it is much simpler than it seems. The Cross-Platform compatibility of this framework can make your work much more manageable when programming valuable apps for any work environment.
You have already learned the basic features of React Native Input. If you want to discover more tips and tutorials about this framework or code in general, we recommend you continue reading some of the articles available on our blog, including guides on implementing image selection in React Native to expand your app’s functionality.
Related articles

may 23, 2023 | 5 min read
Next.js 13: Powerful Framework for Server-rendered Apps

jul 1, 2021 | 5 min read
React Bootstrap Table: perfect your work as a web developer

may 5, 2025 | 3 min read