react-select icon indicating copy to clipboard operation
react-select copied to clipboard

Can i change arrow (dropdown indicator) to my svg,png icon

Open bonusbb opened this issue 7 years ago • 10 comments

in example : https://codesandbox.io/s/jz33xx66q9?module=/example.js

i want to use image (.svg , .png) instance emoji

how to use that

bonusbb avatar Mar 31 '19 17:03 bonusbb

@bonusbb Please don't post questions to Github. Keep questions over at StackOverflow as per request by the maintainers in the issue template.

Rall3n avatar Mar 31 '19 23:03 Rall3n

In the example you sent you just have to replace the EmojiIcon with the link of the image you want.

const DropdownIndicator = (
  props: ElementConfig<typeof components.DropdownIndicator>
) => {
  return (
    <components.DropdownIndicator {...props}>
      <img src="https://via.placeholder.com/30x30"/>
    </components.DropdownIndicator>
  );
};

And then on your component:

  <Select
    closeMenuOnSelect={false}
    components={{ DropdownIndicator }}
    defaultValue={[colourOptions[4], colourOptions[5]]}
    isMulti
    options={colourOptions}
  />

michaelmota avatar Apr 02 '19 12:04 michaelmota

how do you change for ? components is not exported in react-select/async

kandasj avatar Oct 15 '19 08:10 kandasj

If you're using the example above from @michaelmota make sure to add this line in your file:

import Select, { components } from "react-select";

In the example you sent you just have to replace the EmojiIcon with the link of the image you want.

const DropdownIndicator = (
  props: ElementConfig<typeof components.DropdownIndicator>
) => {
  return (
    <components.DropdownIndicator {...props}>
      <img src="https://via.placeholder.com/30x30"/>
    </components.DropdownIndicator>
  );
};

And then on your component:

  <Select
    closeMenuOnSelect={false}
    components={{ DropdownIndicator }}
    defaultValue={[colourOptions[4], colourOptions[5]]}
    isMulti
    options={colourOptions}
  />

cpnvr avatar Jul 15 '21 22:07 cpnvr

I want to remove the Arrow and the vertical line just before that. How can I achieve it ?

kushhemant avatar Mar 11 '22 16:03 kushhemant

I want to remove the Arrow and the vertical line just before that. How can I achieve it ?

@kushhemant you need to use customStyles. Inside it, set dropdownIndicator and indicatorSeparator to display: "none" like so: indicatorSeparator: () => ({ display: "none" }),

vlad31337 avatar May 30 '22 12:05 vlad31337

I want to remove the Arrow and the vertical line just before that. How can I achieve it ?

<Select
components={{
  DropdownIndicator: () => null,
  IndicatorSeparator: () => null,
}} 
/>

rognales avatar Jun 09 '22 04:06 rognales

In the example you sent you just have to replace the EmojiIcon with the link of the image you want.

const DropdownIndicator = (
  props: ElementConfig<typeof components.DropdownIndicator>
) => {
  return (
    <components.DropdownIndicator {...props}>
      <img src="https://via.placeholder.com/30x30"/>
    </components.DropdownIndicator>
  );
};

And then on your component:

  <Select
    closeMenuOnSelect={false}
    components={{ DropdownIndicator }}
    defaultValue={[colourOptions[4], colourOptions[5]]}
    isMulti
    options={colourOptions}
  />

how to this typescript error? Cannot find name 'ElementConfig'.

sahilahluwalia avatar Apr 27 '23 12:04 sahilahluwalia

In the example you sent you just have to replace the EmojiIcon with the link of the image you want.

const DropdownIndicator = (
  props: ElementConfig<typeof components.DropdownIndicator>
) => {
  return (
    <components.DropdownIndicator {...props}>
      <img src="https://via.placeholder.com/30x30"/>
    </components.DropdownIndicator>
  );
};

And then on your component:

  <Select
    closeMenuOnSelect={false}
    components={{ DropdownIndicator }}
    defaultValue={[colourOptions[4], colourOptions[5]]}
    isMulti
    options={colourOptions}
  />

how to this typescript error? Cannot find name 'ElementConfig'.

Change it with DropdownIndicatorProps instead, import Select, { DropdownIndicatorProps } from "react-select";

aoliva31 avatar Jun 21 '23 16:06 aoliva31

The error Cannot find name 'ElementConfig' is still there.

Here's how I fixed it:

import Select, { type DropdownIndicatorProps, components } from "react-select";

const DropdownIndicator: React.FC<DropdownIndicatorProps> = (props) => {
    return (
      <components.DropdownIndicator {...props}>
        <img src="https://via.placeholder.com/30x30"/>
      </components.DropdownIndicator>
    );
  };
<Select
    components={{ DropdownIndicator }}
    options={options}
/>

surajlulla avatar Jul 29 '24 12:07 surajlulla