[英]Trying to change the color of my default placeholder in using react-select to black, doesn't work
The text is currently grey, and hard to see, I want to make it black so it is noticeable. 该文本当前为灰色,很难看到,我想将其设置为黑色,以便使其引人注目。 Whenever I change the select value it changes, but when I try to set the default color of the control text to black it doesn't do anything.
每当我更改选择值时,它都会更改,但是当我尝试将控件文本的默认颜色设置为黑色时,它什么也没做。 My other settings work, such as backgroundColor, fontfamily works.
我的其他设置有效,例如backgroundColor,fontfamily均可。
I am setting the placeholder value to my state when rendered. 渲染时,我将占位符值设置为我的状态。
const colourStyles = {
control: styles => ({ ...styles, fontFamily: 'Times new roman, sans-serif !important', color: 'black', backgroundColor: this.state.selectedOption.value || this.state.statusLiveOff, fontSize: 23, paddingLeft: 'center', height:46})
}
<Select
onChange={this.handleChange}
options={optionsStatus}
styles={colourStyles}
placeholder= {this.state.statusColor}
/>
You can change the color of the text by changing singleValue
styles in your styles object 您可以通过更改样式对象中的
singleValue
样式来更改文本的颜色
const colourStyles = {
control: styles => ({ ...styles, fontFamily: 'Times new roman, sans-serif !important', color: 'black', backgroundColor: this.state.selectedOption.value || this.state.statusLiveOff, fontSize: 23, paddingLeft: 'center', height:46}),
singleValue: styles => ({...styles, color: 'black'})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.