[TextField] Add icon prop to Text Field
As referenced in #2416, we currently don't have a way to add a left icon to the Text Field component. I'd like to work on a PR for this.
TextField would be called like<TextField icon={icon} /> and would render the icon on the left side in the textField before the input.
As pointed out by #3032, it could look like
and #3038 we should be able to add an icon on the left and on the right.
also would be great to see prefix and suffix

I'd like something like this. Are you working on this?
How long will it be before this will be released?
I think this should be extended to the autocomplete input too, would be very useful.
Could there be a way to add an icon with TextField validations/errors also?


I think that should apply to all "form" fields, including SelectField.
I accomplish that using TextField inside ListItem or MenuItem. Put a TextField inside ListItem then use leftIcon or rightIcon props to achieve it.
I accomplish that using TextField inside ListItem or MenuItem.
I think that it's the right approach. I would rather use composition over additional logic in the TextField.
However, I'm wondering if ListItem or MenuItem were designed with this use case in mind.
I think that we could have a more specified component to do it. Like a <TextFieldIcon />
I think the best would be to have it in what looks like a ListItem like shown here: https://material.google.com/components/text-fields.html#text-fields-single-line-text-field
And perhaps have it as a similar option to rightCheckbox, but then rightField, and possible support giving it an array of max. 2 elements, like TextField and/or SelectField, like shown in that phone/calendar example.
This could save a lot of space especially on mobile, and hassle, not needing to tweak the css just right to have them all align.
The issue with using a Textfield nested with ListItem is that... unless I am missing something, it becomes impossible to tab to the next Textfield in your form.
For this reason alone it is preferable to have a standalone
Is there any progress or temporary solution to solve the original issue?
@iamzhouyi try to use something like this for autocomplete experience
<Menu disableAutoFocus>
<MenuItem leftIcon={<SearchIcon color='#fff'/>} disabled>
<AutoComplete hintText='Search' />
</MenuItem>
</Menu>
Anyone with any progress on this? If anyone has started I'd love to help, if not I'd give it a whirl myself?
Doesn't look like it @oshalygin, note it's been added to the checklist on #6566 though so might want to track progress there!
Would be a great addition.
@oshalygin If you're going to look into this, I'd suggest working off the next branch - we aren't prioritizing new features on master. Also, because it is made of composable components, you should find it easier.
I think it also would be great to have circular progress in text fields for real time checking of the text field value.
Wow, I see this was opened 1.5 years ago! Any update to this? I've tried adding CSS hacks (&before content) which kind of work, but I need more fine grained control, as I need to style it further, have it disappear or go away depending on state, and more specifically, be inside the textfield. Tried fiddling also w/ the HintText/placeholder, but all of these are totally conflicting and chaotic with each other. 😞
The easiest way to achieve the icon adjacent to the text field is to wrap the field and icon in a div that can contain the absolute positioned icon.
<div style={{position: 'relative', display: 'inline-block'}}>
<SearchIcon style={{position: 'absolute', right: 0, top: 15, width: 20, height: 20}}/>
<TextField
hintText="Search by Name"
onChange={_.debounce((event, value) => this.handleSearch(value), 500)}
/>
</div>
If you want it on the left, simply add a textIndent to the field and change the positioning to the left.
<div style={{position: 'relative', display: 'inline-block'}}>
<SearchIcon style={{position: 'absolute', left: 0, top: 15, width: 20, height: 20}}/>
<TextField
style={{textIndent: 30}}
hintText="Search by Name"
onChange={_.debounce((event, value) => this.handleSearch(value), 500)}
/>
</div>
If you want to have dynamic icons, then change the field onChange method to update the state which can change the icon. If you wanted to make this cleaner, you can put this in a component and call it IconTextField like <IconTextField icon={
@bradrisse works great, thank god I read the whole thread, found the answer I was looking in the last comment