reactjs - 更改颜色箭头图标 react 选择

标签 reactjs react-select

嗨,如何更改 react 选择中箭头图标的颜色 将鼠标悬停在 google chrome 中,我发现 CSS 变量,但无法更改颜色。 CSS css-tlfecz-indicatorContainer 的这个值。 在我的 customStyles 中,我写了这一行,但不起作用:

  indicatorContainer:base =>({
        ...base,
       color:'#000000'
     }),

enter image description here

更新

这是我使用react-select的组件

import React from 'react';
import Select from 'react-select';
export default function DropDown(props) {
  const customStyles = {
    control: (base, state) => ({
      ...base,
      background: "#59c5b8",
      borderRadius: 0,

    }),
    menu: base => ({
      ...base,
      // override border radius to match the box
      borderRadius: 20,
      // kill the gap
      marginTop: 0,

    }),
    menuList: base => ({
      ...base,
      // kill the white space on first and last option
      padding: 0
    }),
    indicatorSeparator: base => ({
      ...base,
      display: 'none'
    }),
    myDropDown__indicator: base => ({
      ...base,
      '&.myDropDown__dropdown-indicator': {
        '&.indicatorContainer': {
          color: '#000000'
        }
      }

    }),
    '&.indicatorContainer': {
      color: '#000000'
    }
  };


  const [selectedOption, setSelectedOption] = React.useState(0);

  const handleChange = selectedOption => {

    setSelectedOption(selectedOption)

    props.parentCallBack(selectedOption)
  };
  return (
    <Select


      isSearchable={false}
      styles={customStyles}
      isOptionDisabled={true}
      defaultValue={props.options[0]}
      isRtl={true}
      onChange={handleChange}
      options={props.options}
      classNamePrefix='myDropDown'
    />
  );
}

最佳答案

只需使用 customStyles 并为 dropdownIndicator 元素声明新颜色:

const customStyles = {
  dropdownIndicator: base => ({
    ...base,
    color: "red" // Custom colour
  })
};

Here您可以找到所有元素的列表和 here一个活生生的例子。

关于reactjs - 更改颜色箭头图标 react 选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59591251/

相关文章:

node.js - 清除选定的值和列表

reactjs - 在输入框外渲染所选项目以进行多选 react 选择库

javascript - 使用 --fix 运行时 ESLint 错误 'Invalid count value'

javascript - ReactJs,必须使用render吗

javascript - 如何在服务器端呈现时禁用或阻止 ReactJS 查找文档?

javascript - React store.getState 不是函数

reactjs - React-Select 过滤器不适用于 React hook

reactjs - 登录时重定向到上一个路径 - React Router v4

javascript - React Select 不会更新单击选项的值

reactjs - React-Select - 带有自定义处理程序的可点击值