Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to change font-family of textInput #634

Closed
ManigandanRaamanathan opened this issue Nov 2, 2018 · 13 comments
Closed

Unable to change font-family of textInput #634

ManigandanRaamanathan opened this issue Nov 2, 2018 · 13 comments

Comments

@ManigandanRaamanathan
Copy link

ManigandanRaamanathan commented Nov 2, 2018

Current behaviour

Unable to change font-family of textInput. Tried setting the fontFamily through style. But not working

Expected behaviour

Be able to set custom font's for text inputs

What have you tried

Tried setting the fontFamily through style. But not working

Your Environment

software version
ios or android Android 6.0
react-native 0.57.0
react-native-paper 2.1.3
node Latest
npm or yarn Latest
@ManigandanRaamanathan ManigandanRaamanathan changed the title Unable to change font-family of textInput Unable to change font-family of textInput and drawer item Nov 2, 2018
@ManigandanRaamanathan ManigandanRaamanathan changed the title Unable to change font-family of textInput and drawer item Unable to change font-family of textInput Nov 2, 2018
@vieiralucas
Copy link
Contributor

@ManigandanRaamanathan TextInput will pick the regular font from the theme. Check this code
So what you can do is pass the font-family through the theme props

import * as React from 'react';
import { TextInput } from 'react-native-paper';

export default class MyComponent extends React.Component {
  state = {
    text: ''
  };

  render(){
    return (
      <TextInput
        label='Email'
        value={this.state.text}
        onChangeText={text => this.setState({ text })}
        theme={{ fonts: { regular: 'Apple Color Emoji' } }}
      />
    );
  }
}

@bijoycse
Copy link

Good work

@RuchikaPegasus
Copy link

RuchikaPegasus commented Jan 30, 2020

You can directly assign fontfamily to TextInput

import * as React from 'react';
import { TextInput } from 'react-native-paper';

export default class MyComponent extends React.Component {
state = {
text: ''
};

render(){
return (
<TextInput
label='Email'
value={this.state.text}
onChangeText={text => this.setState({ text })}
fontFamily:"fontName"
/>
);
}
}

@erhanbicer
Copy link

import * as React from 'react';
import { TextInput } from 'react-native-paper';

export default class MyComponent extends React.Component {
  state = {
    text: ''
  };

  render(){
    return (
      <TextInput
        label='Email'
        value={this.state.text}
        onChangeText={text => this.setState({ text })}
        theme={{ fonts: { regular: 'Apple Color Emoji' } }}
      />
    );
  }
}

the following block of code worked💪🏻

import * as React from 'react';
import { TextInput } from 'react-native-paper';

export default class MyComponent extends React.Component {
  state = {
    text: ''
  };

  render(){
    return (
      <TextInput
        label='Email'
        value={this.state.text}
        onChangeText={text => this.setState({ text })}
        fontFamily={"Apple Color Emoji"}
        theme={{ fonts: { regular: "" } }}
      />
    );
  }
}

@anabeatrizzz
Copy link
Contributor

This code worked for me:

<TextInput
  theme={
    {
      fonts: {
        regular: {
          fontFamily: 'Poppins-Regular'
        }
      }
    }
  }
/>

@RNtaate
Copy link

RNtaate commented Nov 30, 2022

@anabeatrizzz Thank you very much. Took me a while before I found your solution.

@Suba13
Copy link

Suba13 commented Apr 27, 2023

Using the below code, Still I couldn't change the fontFamily for my Textinput
<TextInput
theme={
{
fonts: {
regular: {
fontFamily: 'ProximaNovaMedium'
}
}
}
}
/>

@mohcenesegouat
Copy link

mohcenesegouat commented May 1, 2023

I did all the previous solutions but no one worked for me.
So after long search and attempts I finally achieved a solution
you just need to add the contentStyle property with font family like below :

<TextInput
     label='Email'
       value={this.state.text}
        onChangeText={text => this.setState({ text })}
        contentStyle={{ fontFamily: "Montserrat" }}
      />

@KennedyKeinstein
Copy link

I did all the previous solutions but no one worked for me. So after long search and attempts I finally achieved a solution you just need to add the contentStyle property with font family like below :

<TextInput
     label='Email'
       value={this.state.text}
        onChangeText={text => this.setState({ text })}
        contentStyle={{ fontFamily: "Montserrat" }}
      />

Worked for me, thanks

@Pajimo
Copy link

Pajimo commented Oct 12, 2023

I did all the previous solutions but no one worked for me. So after long search and attempts I finally achieved a solution you just need to add the contentStyle property with font family like below :

<TextInput
     label='Email'
       value={this.state.text}
        onChangeText={text => this.setState({ text })}
        contentStyle={{ fontFamily: "Montserrat" }}
      />

This worked for me, thanks

@shubuu07
Copy link

contentStyle={{ fontFamily: "Poppins-Medium" }}

its worked for me

@neeraj500
Copy link

@mohcenesegouat Thank you so much, been spending hours looking for this 👍

@kiing-dom
Copy link

@mohcenesegouat you are a G 🙏🏾.

anyone know how to change the label font?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests