Material-UI - How to customize dropdown icon in Autocomplete?
Asked Answered
M

2

7

How can I just change the icon for the open/close dropdown list? I want to functionality to stay the same. As I tried to add them as endAdornment, the functionality is gone for both remove and open/close(arrow) icons.

I just want to add a new arrow icon instead of Material-UI's custom one.

enter image description here

return (
    <div>
        <Autocomplete
            {...defaultProps}
            className="contract-search"
            onChange={(event, value) => {
                handleOnChange(event, value);
            }}
            id="disable-close-on-select"
            sx={{ width: 300 }}
            renderInput={params => {
                console.log(params);
                return (
                    <TextField
                        {...params}
                        InputProps={{
                            ...params.InputProps,
                            startAdornment: (
                                <span className="contract-search-icon">
                                    <img src={`${ASSETS_BASE_URL}/icons/icon-search.svg`} alt="" />
                                </span>
                            ),
                        }}
                        label="Vertrag suchen"
                        variant="standard"
                    />
                );
            }}
        />
    </div>
);
Madelon answered 4/10, 2021 at 13:41 Comment(0)
C
13

Use popupIcon prop, it accepts a ReactNode. See the full API of Autocomplete here:

<Autocomplete popupIcon={<YourCustomIcon />}

Live Demo

Codesandbox Demo

Carrico answered 4/10, 2021 at 13:45 Comment(1)
Do you know how I can add a rotate effect to that image? It will really help meJoerg
G
-1

"& .MuiAutocomplete-endAdornment": { display: "contents", width: "3rem", },

Gayomart answered 13/9, 2024 at 8:27 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.