Is there any way to change the placeholder text color in a Braintree javascript generated hosted field? I don't see it as one of the options you can pass into the constructor. Our design is on a dark background, and the placeholder values aren't visible.
In most browsers, the placeholder text is grey. To change this, style the placeholder with the non-standard ::placeholder selector. Note that Firefox adds a lower opacity to the placeholder, so we use opacity: 1 to fix this.
The “placeholder” property is used to get or set the placeholder of an input text. This can be used to change the placeholder text to a new one. The element is first selected using a jQuery selector. The new placeholder text can then be assigned to the element's placeholder property.
Note: In most browsers, the appearance of placeholder text is a translucent or light gray color by default.
Go to Storyboard and set the placeholder for the textfield from attribute inspector. Now we will be adding extension for UITextField in ViewController. @IBInspectable var placeHolderColor: UIColor? { get { return self. placeHolderColor } set { self.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
There is a way to change the placeholder color, which isn't documented since it's not a 100% fix.
However, in your JS you could do the following:
braintree.hostedFields.create({
client: clientInstance,
styles: {
'input': {
'font-size': '14pt'
},
'input.invalid': {
'color': 'red'
},
'input.valid': {
'color': 'green'
},
'::-webkit-input-placeholder': {
'color': 'pink'
},
':-moz-placeholder': {
'color': 'pink'
},
'::-moz-placeholder': {
'color': 'pink'
},
':-ms-input-placeholder': {
'color': 'pink'
},
},
This isn't a 100% fix because not all browsers support even adding a placeholder, so when styling the placeholder element, the browser prefixes are needed so that each browser can attempt to render the style you want. If a customer goes to access this outside of a browser specified, however, it won't be a fix.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With