Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Braintree Placeholder Text Color

Tags:

braintree

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.

like image 500
tolmark Avatar asked Jan 03 '17 20:01

tolmark


People also ask

How can I change the color of placeholder color?

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.

How do I change the placeholder text?

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.

What is the placeholder text color?

Note: In most browsers, the appearance of placeholder text is a translucent or light gray color by default.

How do you change the placeholder color on a storyboard?

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.


1 Answers

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.

like image 131
C Joseph Avatar answered Sep 16 '22 22:09

C Joseph