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

How can I change arrow?

Open victorpavlenko opened this issue 10 years ago • 33 comments

I need another arrow. Example of font-awesome.

How can a change ?

victorpavlenko avatar Dec 20 '15 13:12 victorpavlenko

you can use css on .Select-arrow-zone and .Select-arrow

CosticaPuntaru avatar Dec 28 '15 16:12 CosticaPuntaru

Cool thanks

victorpavlenko avatar Dec 28 '15 19:12 victorpavlenko

Would it be possible to allow to pass a custom prop for the arrow so you can for example use svg icons ?

LoicUV avatar May 18 '16 09:05 LoicUV

... or to hide altogether; it's in the same location as bootstrap feedback icon.

RichardForrester avatar Aug 21 '16 03:08 RichardForrester

It's been a while already, but for anyone still having issues with this you can pass a custom function to the property arrowRenderer

You can find an example here: https://github.com/JedWatson/react-select/blob/master/docs/examples/CustomDropdownIndicator.js

Update 2020-12-25: Fixed broken link

MiguelCord avatar Mar 15 '18 18:03 MiguelCord

How could I change the arrow when it's open?

matheusalxds avatar Jul 03 '18 19:07 matheusalxds

@MiguelCord looks like the feature has been taken out? The link doesn't work.

praveenaj avatar Aug 21 '18 13:08 praveenaj

Any progress on this issue ?

Rahulkr204 avatar Sep 04 '18 06:09 Rahulkr204

@Rahulkr204 Came here for the same reason of changing arrow. Maybe this issue could help you: https://github.com/JedWatson/react-select/issues/2926

Dracontis avatar Sep 05 '18 11:09 Dracontis

@matheusalxds @praveenaj @Rahulkr204 @Dracontis

See the docs to learn how to replace components. The one you're looking for is DropdownIndicator.

subnomo avatar Sep 10 '18 16:09 subnomo

I solved this by using arrowRenderer props

                arrowRenderer() {
                  return <div className={classes.arrowRenderer}><DownChevron/></div>
                }
               <Select
                    arrowRenderer={this.arrowRenderer}
                    optionRenderer={this.props.optionRenderer}
                    isMulti={false}
                    closeMenuOnSelect={false}
                    options={options}
                    onChange={(props)=>this.editDropdown(props,name)}
                    value={value}
                    className={classes.selectOption}
                    placeholder={placeholder}
                    disabled={isDisabled}
                    clearable={false}
                    style={dropdownStyle}
                />

Rahulkr204 avatar Sep 11 '18 06:09 Rahulkr204

@subnomo Thanks. I got it working. Here's my code if anyone still trying to do it.

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

const DropdownIndicator = props => {
  return (
    components.DropdownIndicator && (
      <components.DropdownIndicator {...props}>
        <FontAwesomeIcon icon={props.selectProps.menuIsOpen ? "caret-up" : "caret-down"}/>
      </components.DropdownIndicator>
    )
  );
};


<Select
   components={{ DropdownIndicator }}
    // pass other props
/>

praveenaj avatar Sep 11 '18 09:09 praveenaj

I wanted to remove the dropdown arrow and by seeing this issue I rendered arrowRenderer as an empty div but there is still an annoying border (or divider something) which used to separate clear and arrow. First anyone has any better solution to remove arrow down icon and second if there is not, how to remove that divider?

Thanks :)

erfoon avatar Sep 13 '18 15:09 erfoon

@erfansamieyan That's simple. Just do this in your customStyles Object.

simple

visualcookie avatar Sep 19 '18 12:09 visualcookie

Here's the link to the example on how you can substitute arrow-down with your image: https://react-select.com/components (search for Custom Dropdown Indicator Example)

AllaSorokina avatar Nov 19 '18 21:11 AllaSorokina

@praveenaj what is FontAwesomeIcon? I have the following, but passing this in doesn't replace the icon.

const CaretDownIcon = () => {
  return <i className="fas fa-caret-down" />;
};

https://codesandbox.io/s/jnk420nmrv

brendadev avatar Feb 08 '19 04:02 brendadev

@brendadev https://github.com/FortAwesome/react-fontawesome

praveenaj avatar Feb 11 '19 10:02 praveenaj

I also solved this by passing a function that renders the icon to arrowRenderer props

like so:

const renderIcon = () => (
  // return icon render
)

<Select
  arrowrenderer={renderIcon}
/>

ninariccimarie avatar Apr 17 '19 06:04 ninariccimarie

Is there a simple way to just pass id for dropdownIndicator component, so not to create custom to use existing one but to add html id?

vaske avatar Sep 24 '19 09:09 vaske

To remove the dropdown indicator in a select add this to your custom styles object. dropdownIndicator: base => ({ ...base, display: 'none' }),

scrayWC avatar Oct 01 '19 15:10 scrayWC