How to use custom icons in TextInput.Icon component
Is it possible to use custom icons in TextInput.Icon component and which icon library supports for this component.
<TextInput style={commonstyles.primaryInput} mode='outlined' label="Label Name" placeholder="Enter placeholder" left={<TextInput.Icon name="info" color={"#ff0000"} onPress={() => {}} />} />
Couldn't find version numbers for the following packages in the issue:
react-nativereact-native-paperreact-native-vector-icons
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.
You can pass your own component in the name prop, like saw in #2255.
<TextInput style={commonstyles.primaryInput}
mode='outlined'
label="Label Name"
placeholder="Enter placeholder"
left={
<TextInput.Icon
name={<Icon name="info" color="#ff0000" />} // where <Icon /> is any component from vector-icons or anything else
onPress={() => {}}
/>
}
/>
It seem like that it's not too clear in the documentation, but we always can open a PR to contribute.
This isn't an option currently since a release hasn't been cut yet
@hbiede For me, it already works, even the TS giving me an error message for name prop. I'm using version 4.2.0
Edit: Seems like 4.3.0 just launched minutes ago \o/.
@hbiede pass the name as a function
<TextInput
right={<TextInput.Icon name={() => <Icon name={'camera'} size={20} />} />}
style={styles.input}
label={'Label'}
/>
@ikaccc yep, it’s working now. It hadn’t been at the time as the change hadn’t been published. Thanks, though.
this didnt work for me and IMO very confusing design, this doesnt follow any standards or share any similarities to other components in the library
The fact that it requires a callback instead of a component is quite weird
Also unusual that a name attribute is expecting a function 🤔 ...
react-native-paper v.4.9.2 does not support FontAwesome5 with TextInpnut.Icon
Here is my take on this:
<TextInput
placeholder="Text goes here"
theme={{ colors: { text: Colors.primaryText } }}
activeOutlineColor={Colors.primaryCTA}
autoCorrect={false}
style={styles.input}
right={
<TextInput.Icon
name={() => (
<TouchableOpacity style={styles.searchButton} onPress={onSearch}>
<ExploreIcon focused focusedColor={Colors.inputBackground} />
</TouchableOpacity>
)}
/>
}
/>
@hbiede passe o nome como uma função
<TextInput right={<TextInput.Icon name={() => <Icon name={'camera'} size={20} />} />} style={styles.input} label={'Label'} />
this it works for me. Documentation sometimes does't contribuites much.
react-native-paper: v5.2.0 - Using Icon prop we can use custom SVG icon
<TextInput
placeholder="Reply"
right={<TextInput.Icon icon={() => <SendIcon/>} />}
/>
TextInputIconProps :
export type Props = $Omit<
React.ComponentProps<typeof IconButton>,
'icon' | 'theme' | 'color'
>
<TextInputCustom
mode='outlined'
label={<LableInput error={errors.confirmPassword} lable={I18n.t('register.confirm_password')} required={true} />}
placeholder={I18n.t('register.confirm_password_placeholder')}
value={confirmPassword}
onChangeText={setConfirmPassword}
error={errors.confirmPassword}
errorMess={errors.confirmPassword}
secureTextEntry={secureTextEntryConfirmPassword}
autoComplete='password-new'
textContentType="oneTimeCode"
right={<TextInput.Icon forceTextInputFocus={false} style={styles.inputIcon} color={selectedTheme.selectedTheme.textColorNeutral} icon={!secureTextEntryConfirmPassword ? "eye-off-outline" : "eye-outline"} onPress={onShowConfirmPassword} />}
onSubmitEditing={onRegister}
/>
Ipados 16.4.1 crash when press TextInput.Icon. not the simulator. Thanks Any help T.T
that work for me
left={<TextInput.Icon name={() => (<Text>{currency}</Text>)} /> }
Renamed from 'name' to 'icon` in v5.x
<TextInput
mode="outlined"
placeholder="See Recent Investigations"
contentStyle={styles.inputContainer}
style={styles.input}
right={
<TextInput.Icon
icon={() => <AntDesign name={"down"} size={20} />}
onPress={() => {}}
/>
}
/>