question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display a right icon inside a TextInput?

See original GitHub issue

I’m struggling to display a right icon inside a text-input. From this article announcing version 4.0, it looks like it is possible. But there is no clear instruction in docs on how to achieve it. On the documentation page, for TextInput, there are left and right props which I suppose should display e.g an icon. This is my view (Expo + React-Native):

<TextInput label="__label__" right={() => <FontAwesome5 name="edit" size={24} color="red" />}  />

I also tried this way:

<TextInput label="__label__" right={<FontAwesome5 name="edit" size={24} color="red" />}  />

In both cases nothing is displayed. What is the use of properties left and right and how to display an icon inside a TextInput? Thank you for support.

react-native (expo version): https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz react-native-paper: ^4.0.1 @expo/vector-icons: ^10.0.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rizshivallicommented, Aug 24, 2020

I was also having the same issue

i fixed it using <TextInput.Icon name="Icon-Name" /> You can pass the name of an icon from MaterialCommunityIcons. This will use the react-native-vector-icons library to display the icon.

import * as React from 'react';
import { View } from 'react-native'
import { TextInput } from 'react-native-paper';

const InputComponent = () => {
 const element = <TextInput.Icon name="lock-outline" />
  return (
    <TextInput
      label="Email"
      mode='outlined'
      style={{ backgroundColor: 'transparent' }}
      right= {element}
      left={element}
    />
  );
};

export default InputComponent;
0reactions
pixelasscommented, Feb 1, 2021

this should really be covered somewhere in the docs which IMHO are not useful in many cases.

@rizshivalli do you want to document things like this? are you open to PRs that add better docs for components?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I put an icon inside a TextInput in React Native?
Basically you can't put an icon inside of a textInput but you can fake it by wrapping it inside a view and setting...
Read more >
CSS to put icon inside an input element in a form
The fontawesome icon can be placed by using the fa prefix before the icon's name.
Read more >
TextInput.Icon · React Native Paper
A component to render a leading / trailing icon in the TextInput. ... useState(''); return ( <TextInput label="Password" secureTextEntry right={<TextInput.
Read more >
How to add icons inside input elements in HTML - Educative.io
In HTML, icons are added with the <i> tag. For it to be added inside the input elements, it must be added between...
Read more >
Image Icon in React Native TextInput
While working with React Native TextInput we need to assist the user in what to insert in TextInput. We can use React Native...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found