I want to rotate auto complete icon of material UI when auto complete component is expanded.
This is the demo of Auto complete: https://codesandbox.io/s/0xx573qrln
Any help is greatly appreciated.
You can make use of the components.DropdownIndicator
prop of the react-select.
The current state of the component can be accessed through selectProps
prop of the component.
I ran into the same challenge, and this is how I did:
// Select.js
const styles = theme => ({
dropdown: {
transition: theme.transitions.create(["transform"], {
duration: theme.transitions.duration.short
})
},
dropdownOpen: {
transform: "rotate(-180deg)"
},
dropdownClosed: {
transform: "rotate(0)"
}
})
function DropdownIndicator(props) {
return (
<KeyboardArrowDown
className={[
props.selectProps.classes.dropdown,
props.selectProps.menuIsOpen
? props.selectProps.classes.dropdownOpen
: props.selectProps.classes.dropdownClosed
]}
/>
);
}
const components = { DropdownIndicator };
export function Select(props) {
return <Select componenets={components} {...props} />
}
Hope you were able to solve the challenge yourself.
Demo (forked from above link): https://codesandbox.io/s/material-demo-b9frk
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With