I am using react-autocomplete for search and I want to add search icon to autocomplete component
My current code is
import Autocomplete from "react-autocomplete";
import searchIcon from "../images/search-icon.svg";
......
......
<InputGroup className="searchbar">
<div style={{ width: "100%", display: "flex" }}>
<Autocomplete
getItemValue={(item) => item.key}
items={suggestionItems}
renderItem={(item, isHighlighted) =>
<div style={{ background: isHighlighted ? '#eee' : 'transparent' }} key={item.key}>
{item.label}
</div>
}
value={queryText}
onChange={this.onChange}
onSelect={this.onSelect}
autoHighlight={false}
inputProps={{ style: { width: "100%", height: "100%", padding: "6px 12px" }, placeholder: "Enter a query here"}}
wrapperStyle={{ width: "100%" }}
......
......
</div>
</InputGroup>
My end goal is to have something similar to stackoverflow search bar like below:
I tried to add the search icon inside the placeholder like this:
inputProps={{ style: { width: "100%", height: "100%", padding: "6px 12px" }, placeholder: " Enter a query here"}}
But the icon will disappear when typing..I want the icon stay there inside the search bar no matter what, exactly like what stackoverflow search bar does.
Does anybody know how I can make it work with react-autocomplete ?
Thank you so much!!

If you can inspect the stack Overflow search bar then you'll see the searchIcon is an SVG Image. So basically you can render the search bar with the below pattern
This will do the job