如何更改 react-select 颜色

How to change react-select color

我不确定如何将颜色从默认的蓝色更改为其他颜色。示例代码在下面的 codesandbox link 中。我尝试更改 root 的样式,但没有成功。

https://codesandbox.io/s/ly87zo23kl

react-select 2.1.0 版添加了覆盖主题的选项。

这里有一个它如何工作的例子:

<Select
    defaultValue={flavourOptions[0]}
    label="Single select"
    options={flavourOptions}
    theme={(theme) => ({
      ...theme,
      borderRadius: 0,
      colors: {
      ...theme.colors,
        text: 'orangered',
        primary25: 'hotpink',
        primary: 'black',
      },
    })}
  />

您可以找到 here the complete documentation and live example and here 可以覆盖的不同变量。