Set text input placeholder color in reactjs

Mohammad Razeghi picture Mohammad Razeghi · Aug 12, 2016 · Viewed 23.4k times · Source

When using ordinary CSS if you want to style your place holder you use these css selectors :

::-webkit-input-placeholder {
    color: red;
}

But I can't figure out how to apply these type of styles in react inline styles.

Answer

Timo picture Timo · Aug 12, 2016

You can't use ::-webkit-inline-placeholder inline.

It is a pseudo-element that (much like e.g. :hover) can only be used in your stylesheet:

The non-standard proprietary ::-webkit-input-placeholder pseudo-element represents the placeholder text of a form element.

Source

Instead, assign a class to the React component via the className property and apply the style to this class.