简体   繁体   English

React-Select:菜单打开时如何旋转下拉指示器

[英]React-Select : How to rotate dropdown indicator when menu open

in example : https://codesandbox.io/s/jz33xx66q9?module=/example.js 在示例中: https : //codesandbox.io/s/jz33xx66q9?module=/example.js

i want to rotate emoji to up size down when menu open 我想在菜单打开时将表情符号旋转到更大的尺寸

how to do that 怎么做

react-select provides a styling api which offers such customization. react-select提供了样式化api ,它提供了这种自定义功能。 Each attribute in the object given to the styles prop is a function which is getting the current component state as a prop. 对象中赋予styles prop的每个属性都是一个函数,该函数将当前组件状态作为prop。 The state also has props from the base component ( Select ). 该状态还具有来自基础组件的道具( Select )。

<Select
    { ... }
    styles={{
        dropdownIndicator: (provided, state) => ({
            ...provided,
            transform: state.selectProps.menuIsOpen && 'rotate(180deg)'
        })
    }}
/>

CodeSandbox example CodeSandbox示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM