如何更改反应选择颜色

时间:2018-10-25 17:12:33

标签: reactjs react-select

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

https://codesandbox.io/s/ly87zo23kl

1 个答案:

答案 0 :(得分:2)

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的完整文档和实时示例以及here可以覆盖的不同变量。