Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  7] [ 6]  / answers: 1 / hits: 5361  / 4 Years ago, wed, may 20, 2020, 12:00:00

How do I change the text input color inside the TextInput element in react native elements I tried passing the color=red to the component but for some reason it doesn't work.



Here is the code I used:



import React, { useState } from react;
import { StyleSheet, View } from react-native;
import { Text, Button, Input } from react-native-elements;
import Icon from react-native-vector-icons/MaterialIcons;
import colors from ../config/colors;

function LoginScreen() {
const [email, setEmail] = useState();
const [password, setPassword] = useState();
return (
<View style={styles.Input}>
<Input
style={styles.TextInput}
placeholder=Your email
value={email}
onChangeText={setEmail}
autoCapitalize=none
autoCorrect={false}
leftIcon={<Icon name=email size={20} color=#B3C1B3 />}
/>
<Input

secureTextEntry
placeholder=Your password
value={password}
onChangeText={setPassword}
autoCapitalize=none
autoCorrect={false}
leftIcon={<Icon name=lock size={20} color=#B3C1B3 />}
/>
</View>
);
}
const styles = StyleSheet.create({
Input: {
top: 2%,
width: 70%,
left: 15%,
justifyContent: center,
alignItems: center,
},
});
export default LoginScreen;

More From » reactjs

 Answers
4

You need to add inputStyle to change the style of the input.



<Input
style={styles.TextInput}
inputStyle={{color: 'red'}} // Add this to your code
placeholder=Your email
value={email}
onChangeText={setEmail}
autoCapitalize=none
autoCorrect={false}
leftIcon={<Icon name=email size={20} color=#B3C1B3 />}
/>

[#3744] Tuesday, May 19, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
destiniemartinac

Total Points: 92
Total Questions: 106
Total Answers: 111

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
destiniemartinac questions
;