How to use custom font to change button text in React Native

In this React Native source code example, the source code below illustrate how to use custom font to change button text in React Native.

You can copy and adopt this source code example to your React Native project without reinventing the wheels.

import React, {Component} from 'react';
import {StyleSheet, Text, View} from 'react-native';

export default class App extends Component{
  render() {
    return (
      <View style={styles.container}>
          <View style={styles.button}>
            <Text style={styles.buttonText}>My Button</Text>
          </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  buttonText:{
    fontFamily: 'monospace',
    fontStyle: 'italic',
    textAlign: 'center',
    color:'white',
    fontSize:25
    },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
  },
  button:{
    paddingHorizontal:20,
    paddingVertical:15,
    backgroundColor:'#29ba2f',
    borderRadius:6,
  }
});

/* Inbuilt Font families include:
      normal
      notoserif
      sans-serif
      sans-serif-light
      sans-serif-thin
      sans-serif-condensed
      sans-serif-medium
      serif
      Roboto
      monospace
*/

If you have any questions or suggestions kindly use the comment box or you can contact us directly through our contact page below.

 

Add a Comment