react-native-google-places-autocomplete icon indicating copy to clipboard operation
react-native-google-places-autocomplete copied to clipboard

How to change font-family of placeholder text

Open desai-hardik opened this issue 2 years ago • 9 comments

How to change font-family of placeholder text

I want to change font-family of place holder text (Please refere below image for required output)

Screen Shot 2022-12-27 at 12 38 04 PM

Reproduction - (required - issue will be closed without this)

1 I apply the styles inside style property but did't word (please find a screen shot)

Please provide a FULLY REPRODUCIBLE example.

<GooglePlacesAutocomplete
        ref={locationSheetRef}
        //textInputProps={{clearButtonMode: 'never'}}
        renderRightButton={() => null}
        styles={{
          textInputContainer: styles.googleInputContainer,
          textInput: styles.googleTextInput,
          placeholderStyle: {
            fontFamily: appFontStyle.fontFamily,
            fontSize: normalize(appFontStyle.fontSize),
          },
        }}
/>

also try inside textInput props

<GooglePlacesAutocomplete
      ref={locationSheetRef}
      //textInputProps={{clearButtonMode: 'never'}}
      renderRightButton={() => null}
      styles={{
        textInputContainer: styles.googleInputContainer,
        textInput: {
          placeholderStyle: {
            fontFamily: appFontStyle.fontFamily,
            fontSize: normalize(appFontStyle.fontSize),
          },
        },
      }}
    />

Additional context

  • Library Version: [e.g. 2.4.1]

  • React Native Version: [e.g. 0.68.2]

  • [*] iOS

  • [* ] Android

Help wanted here

So at which place I have to apply styles to chaneg placeholder font-family.

desai-hardik avatar Dec 27 '22 07:12 desai-hardik

@desai-hardik, You can use the 'textInputProps' to add styling to your placeholder text. For example,

<GooglePlacesAutocomplete
        // other props
        textInputProps={{
          placeholderTextColor: 'white',
          fontSize: 16,
          fontFamily: ..... ,
        }}
        // other props
/>

Fardin96 avatar Apr 01 '23 08:04 Fardin96

From my experience, I had to use an additional style prop to change the fontFamily. So the above became:

<GooglePlacesAutocomplete
        // other props
        textInputProps={{
          placeholderTextColor: 'white',
          style: {
            fontSize: 16,
            fontFamily: ..... ,
        }}}
        // other props
/>

RyanTG avatar Apr 10 '23 23:04 RyanTG

Need a solution for this which actually works.

SaadBazaz avatar May 18 '23 12:05 SaadBazaz

The above works, bruh.

RyanTG avatar May 18 '23 14:05 RyanTG

If by works you mean has no effect at all, then yeah sure, that works...

jacquesdev avatar Sep 10 '23 21:09 jacquesdev

Here's how we're using it. I solemnly swear that it is changing the placeholder font family. We are using "react-native-google-places-autocomplete": "^2.5.1",

RyanTG avatar Sep 10 '23 22:09 RyanTG

Hey @RyanTG - thanks for confirming. The thing that has no effect for me is placeholderTextColor: 'white',, so good to know the font works at least. I'm on the same version... I really wonder what it could be then...

jacquesdev avatar Sep 11 '23 18:09 jacquesdev

Ah, I see. We aren't using that prop (I only showed it above because I was correcting the person's code for how to change the font family, which is the focus of this issue). I haven't tried it, but I would think you could change the color with a color prop within style. I'm assuming you tried that, though.

RyanTG avatar Sep 11 '23 18:09 RyanTG

I take it back, it works, argg! Sorry for the hassle @RyanTG

jacquesdev avatar Sep 13 '23 13:09 jacquesdev