Cle*_*ens 0 reactjs react-select
我想在 .txt 文件中设置禁用选项的文本(斜体等)样式react-select。尽管这对我来说似乎很基本,但我找不到任何相关内容。
禁用选项是否有自己的“样式键”?
您可以使用react-select的样式 API
这是一个例子:
const customStyles = {
// For the select itself (not the options)
control: (styles, { isDisabled }) => {
return {
...styles,
color: isDisabled ? 'red' : 'white'
fontStyle: isDisabled ? "italic" : "normal";
}
},
// For the options
option: (styles, { isDisabled }) => {
const color = chroma(data.color);
return {
...styles,
backgroundColor: isDisabled ? 'red' : 'blue',
color: 'green',
};
},
};
Run Code Online (Sandbox Code Playgroud)
然后像这样使用它:
<Select
{...props}
styles={customStyles}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2690 次 |
| 最近记录: |