react select icon

Solutions on MaxInterview for react select icon by the best coders in the world

showing results for - "react select icon"
Vincenzo
07 May 2018
1I found a workaround how to solve it. My technique is similar to @canda:
2
3import React, { Component } from "react";
4import { render } from "react-dom";
5import "./style.css";
6import Select, { components } from "react-select";
7
8const options = [
9  { value: "England", label: "England", icon: "england.svg" },
10  { value: "Germany", label: "Germany", icon: "germany.svg" }
11];
12
13const { Option } = components;
14const IconOption = props => (
15  <Option {...props}>
16    <img
17      src={require('./' + props.data.icon)}
18      style={{ width: 36 }}
19      alt={props.data.label}
20    />
21    {props.data.label}
22  </Option>
23);
24
25class App extends Component {
26  constructor() {
27    super();
28    this.state = {
29      name: "React"
30    };
31  }
32
33  render() {
34    return (
35      <Select
36        defaultValue={options[0]}
37        options={options}
38        components={{ Option: IconOption }}
39      />
40    );
41  }
42}
43
44render(<App />, document.getElementById("root"));
queries leading to this page
react select add icon to selectedselect icon reactreact select search iconadd icon to select reactjshow to change react select arrow iconhow to style a select dropdown with react iconsicon button display a select in reactcustom icon select css reacthow to add icon in select option reactcomponente select com icones reactreactjs add icon in select optionselect option box with a icon i reactreact select options iconsadd icon select reactreact select dropdown iconselect option icon also selected in reactreact add icon on select valuereact select flags iconreact select change iconreact select icon inside inputreact default value select iconhow to change react select iconreact select change iconsadd a react icon to a selectreact select add icon with optionsrender icons with react selectreact select component iconreact select add search iconrender an icon with react selecticon select in reactreact select option with iconicon in select reactrender icon in select options reacticon in react selectreact select option iconicon inside option select reactchanging react selects selector iconreact select dropdown iconset icons react selecthow to use react icons in selectselect with icon react libreact icon display a select lsitreact select close iconhow to add icon in react select dropdownreact select add icon to selected optionreact select with iconreact select iconreact select icons left and rightreact select icon in text boxreact select add icon option on the right sidereact select iconsicon dans option select in reactreact select option right icon for selectedreact bootstrp select icon changemake dropdown icon by react selecthow to place a custom icon on select tag reactjsshow icon in select option react chakramake an option an icon select menu reactreact select add icon on the right sidereact select label with iconselect dropdown with icon reactreact select add icon inputadd icon to react selectreact select start iconhow to replace select icon with react iconshow to add icon on input select option in react jsreact select add icons in before valuesreact select change dropdown iconicon selection in reactreact select option data iconreact select form add the select iconreact select input with iconcomponent select with iconsreact add icon on select itemsreact select input iconreact select data iconreact select iconsreact icons fa selectreact select with iconshow to change select icon in reactreact select field on iconreact select add icon beside dropdown iconreact js icon selectadd icon in react selectreact select icon optionsreact select prefix iconreact select change arrow icon 22react select 22 with iconsreact select icon