14

Trying to set the color of the default select value to black but it doesn't work, i even put !important so it overrides any bootstrap colors that being overwritten by it. Any help is appreciated thank you.

const colourStyles = {
      control: styles => ({ ...styles, overflow: 'hidden', color: 'black !important',backgroundColor: this.state.selectedOption.value || '#32CD32', fontSize: 23,  paddingLeft: 'center', height:46}),
      singleValue: styles => ({ ...styles, color: 'black' }),
    }
<Select
 onChange={this.handleChange}
 options={optionsStatus}
 styles={colourStyles}
 placeholder= 'Status'
/> 

enter image description here enter image description here

bobb1213131
  • 277
  • 1
  • 5
  • 16
  • 1
    Possible duplicate of [Change an HTML5 input's placeholder color with CSS](https://stackoverflow.com/questions/2610497/change-an-html5-inputs-placeholder-color-with-css) – Fabien Greard Dec 06 '18 at 18:27

5 Answers5

23

You can update the placeholder styles using the same colourStyles object.

const colourStyles = {
    placeholder: (defaultStyles) => {
        return {
            ...defaultStyles,
            color: '#ffffff',
        }
    }
}

You can review the related documentation (https://react-select.com/styles#style-object) to check the keys available for styling.

Oscar Saraza
  • 1,171
  • 1
  • 14
  • 23
8

If someone is looking for changing text and style

<Select 
options={options} 
placeholder={<div className="select-placeholder-text">Select category</div>} 
/>

In the Stylesheet

.select-placeholder-text {
color: pink;
}
ZiaUllahZia
  • 1,072
  • 2
  • 16
  • 30
6

Another option is to override the default theme. According to react-select docs, the neutral50 response for placeholder's color. For example:

<Select
    onChange={this.handleChange}
    options={optionsStatus}
    styles={colourStyles}
    placeholder= 'Status'
    theme={theme => ({
        ...theme,
        colors: {
            ...theme.colors,
            neutral50: '#1A1A1A',  // Placeholder color
        },
    })}
/>

View on codesandbox

tdphut
  • 94
  • 3
  • 5
3

I just ran into this too. I kept trying to change ::placeholder in the css, but it seems to be rendered as actual text, not a pseudo-class. Here's what I found that worked. First, pass the prop classNamePrefix="react-select" to the component, and then select it in the css with:

.react-select__placeholder {
  color: black;
}

(And of course, you can make the classNamePrefix whatever you want).

jefferiestube
  • 141
  • 3
  • 8
1

For version 5.7.3, I changed it this way:

theme={(theme) => ({
            ...theme,
            colors: {
              neutral50: "#fff",
            },
          })}
SpicyCatGames
  • 863
  • 7
  • 25