react-native-paper TextInput icon color not working - react-native

I'm using react-native-paper TextInput to show email icon on the left side of text input and that icon should be green (#22C55E) but it's still showing the default color.
<TextInput
placeholder={t('Email')}
style={styles.textInput}
mode="outlined"
outlineColor={Colors.transparent}
activeOutlineColor={Colors.hostessGreen}
theme={{ roundness: 16 }}
left={
<TextInput.Icon
icon={'email-outline'}
color="#22C55E"
style={styles.leftIcon as StyleProp<ViewStyle>}
size={responsiveFontSize(3)}
/>
}
/>

You have to add iconColor='#22C55E' add in place of color="#22C55E" props in TextInput.Icon.you will be able to change color easily.
<TextInput
placeholder={t('Email')}
style={styles.textInput}
mode="outlined"
outlineColor={Colors.transparent}
activeOutlineColor={Colors.hostessGreen}
theme={{ roundness: 16 }}
left={
<TextInput.Icon
icon={'email-outline'}
iconColor="#22C55E"
style={styles.leftIcon as StyleProp<ViewStyle>}
size={responsiveFontSize(3)}
/>
}
/>

Related

TextInput react-native-paper remove label on focus

I am using the TextInput of React Native Paper (https://callstack.github.io/react-native-paper/text-input.html)
Is there a way to not show the label on the border line when we are focusing on a TextInput?
<TextInput
mode="outlined"
label="Email"
value={email}
onChangeText={email => setEmail(email)}
theme={{ colors: { primary: APP_COLORS.primary }}}
selectionColor={APP_COLORS.primary}
outlineColor={APP_COLORS.grey_low}
left={<TextInput.Icon name={() => <AntDesign name="mail" size={22} color="black" />} />}
/>
The label "Email" in black in your picture appears to come from another component not included in your code snippet.
If you wish to keep the "Email" label in black, remove the "Email" label in red, but retain the outlined style of the TextInput, you can simply remove the label key of the component:
<TextInput
mode="outlined"
value={email}
onChangeText={email => setEmail(email)}
theme={{
colors: { primary: APP_COLORS.primary }
}}
selectionColor={APP_COLORS.primary}
outlineColor={APP_COLORS.grey_low}
left={
<TextInput.Icon name={() =>
<AntDesign
name="mail"
size={22}
color="black"
/>
}/>
}
/>

how hidden TextInput IOS Keyboard top area (ok button)

Screenshot
i want to hidden this area
What shall I do?
thanks
<TextInput
returnKeyType={'default'}
autoFocus
style={{ paddingBottom: 97,height: 238,padding: 0}}
// blurOnSubmit={true}
multiline={true}
// onSubmitEditing={onConfirm}
// maxLength={30}
// autoCorrect={false}
clearButtonMode={'always'}
textContentType={'none'}
placeholder={'Please enter note'}
placeholderTextColor={'#454545'}
value={note}
enablesReturnKeyAutomatically
caretHidden
keyboardType="default"
blurOnSubmit={false}
contextMenuHidden={false}
inputAccessoryViewID={inputAccessoryViewID}
// disableFullscreenUI={false}
onChangeText={noteChanged}
></TextInput>
Remove these props from TextInput
enablesReturnKeyAutomatically
returnKeyType={'default'}

How to make the Keyboard show when touching the parent view

I'm creating an app with React Native & Expo.
One of the search inputs includes an icon, so I did it like so:
<View style={styles.inputContainer}>
<FontAwesome name="search" size={20} color="black" />
<TextInput
style={styles.input}
value={search}
placeholder="Pesquise"
placeholderTextColor={text_gray}
onChangeText={(text) => setSearch(text)}
/>
</View>
But the Keyboard shows only when I click the TextInput, and I need to open it wherever I click the View that wraps it and the icon.
How can I achieve that?
Create a ref to the TextInput and then call REF.current.focus() to focus on the textInput and REF.current.blur() to blur it. Use Pressable instead of View, its just like a View but with different onPress events.
const textInput = useRef(null);
return (
<Pressable style={styles.inputContainer} onPress={() => textInput?.current?.focus()}>
<FontAwesome name="search" size={20} color="black" />
<TextInput
ref={textInput}
style={styles.input}
value={search}
placeholder="Pesquise"
placeholderTextColor={text_gray}
onChangeText={(text) => setSearch(text)}
/>
</Pressable>
)

How to disable keyboard in react native

I created a screen keyboard component that I want to disable the platform's keyboard, how I can disable it?
<TextInput
secureTextEntry
ref="Pin"
selectionColor="#656565"
keyboardType="numeric"
activeColor="#656565"
inactiveColor="#fff"
autoFocus={false}
ignoreCase
codeLength={4}
inputPosition="center"
size={50}
onFulfill={isValid => this}
codeInputStyle={{ borderWidth: 1.5 }}
/>
Just write showSoftInputOnFocus={false} in <TextInput> like this:
<TextInput showSoftInputOnFocus={false} />
I had issues also. No other solutions was working for me. This will display text input field and it will be clickable but not editable.
<TouchableOpacity onPress={this.openPinKeyboard}>
<View pointerEvents="none">
<Input editable={false} value="1234" />
</View>
</TouchableOpacity>
I think you need to add something like:
<TextInput showSoftInputOnFocus={false} keyboardType="numeric" />
setting keyboardType to null worked for me
EDIT:
this only worked in the simulator, running it on an actual device the native keyboard still appeared.
wrapping the <TextInput /> in a <TouchableWithoutFeedback> element in the example below worked.
<TouchableWithoutFeedback onPress={Keyboard.dismiss} >
<TextInput />
</TouchableWithoutFeedback>
You may try to set keyboardType to none, if it doesn't work another alternative is to set the editable prop to false.
Potential answers can be found here : https://github.com/facebook/react-native/issues/14045
<TextInput showSoftInputOnFocus={false}/>
This work for me, sometime I need onFocus action to navigate new screen, and don't need keyboard open animation. Prop Editable will disable textfield, can not pressable
try this solution i hope this will work for android and ios both...
// Step 1: Get Keyboard, TouchableWithoutFeedback from ‘react-native’;
import { View, TextInput, StyleSheet, Keyboard, TouchableWithoutFeedback } from 'react-native';
// Step 2: Create an arrow function to write dismiss keyboard code
const DismissKeyboard = ({ children }) => (
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
{children}
</TouchableWithoutFeedback>
);
// Step 3: Wrap all TextInput inside <DismissKeyboard> </DismissKeyboard>
//Example
<DismissKeyboard>
<View style={styles.container}>
<TextInput style={styles.input} placeholder="email" />
<TextInput style={styles.input} placeholder="password" />
</View>
</DismissKeyboard>
The easiest solution is to use the onFocus prop on TextInput.
Import Keyboard from ‘react-native’
import {Keyboard, TextInput} from
'react-native'
Then pass Keyboard.dismiss() to TextInput onFocus prop, to stop the keyboard from popping up when focused.
<TextInput onFocus = {()=> Keyboard.dismiss()} .../>
Now test the input field by pressing it to see if the keyboard will pop up
just put this under text input tag this worked for me in react-native
<TextInput
//this line
editable={false}
/>
you can do it by pointerEvents="none"
<View pointerEvents="none">
<TextInput
focusable={false}
style={{color: '#00000000'}}
onChangeText={setEmail}
/>
</View>

React-Native Text input prevents scrolling

I have react native screen with single line TextInput:
<ScrollView>
...
<TextInput />
...
</ScrollView>
When I try to scroll the through the screen and my initial tap lands on TextInput, screen scrolling doesn't work. It almost tries to scroll inside the TextInput, but there is nothing to scroll. Here is what the text input looks like:
<TextInput
style={{...styles.rowInput, color: theme.textColor}}
onChangeText={(text) => this.setState({name: text})}
selectTextOnFocus={false}
autoCapitalize="words"
numberOfLines={1}
underlineColorAndroid="transparent"
autoCorrect={false}
placeholder="Enter Your Name"
placeholderTextColor={borderColor}
maxLength={24} />
Any ideas why it is happening?
It related to ScrollView and you can fix this by setting keyboardShouldPersistTaps to 'Handled'. Try this..
<ScrollView
keyboardShouldPersistTaps={'handled'}>
...
<TextInput />
...
</ScrollView>