Answers for "use google fonts in react native"

CSS
1

google font in react native

// 1) Install two package from expo 
// 1.1) visit https://directory.vercel.app/ and select font you want
// expo install @expo-google-fonts/FONT_FAMILY_NAME 
  //For example, if you choose to use lato we would install:
   //====== expo install @expo-google-fonts/lato     =======
//1.2) =====expo install expo-app-loading   ===========
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import { AppLoading } from "expo-app-loading";
import {
  useFonts,
  Roboto_400Regular,
  Roboto_400Regular_Italic
} from "@expo-google-fonts/roboto";

export default function App() {
  let [fontsLoaded] = useFonts({
    Roboto_400Regular,
    Roboto_400Regular_Italic
  });

  if (!fontsLoaded) {
    return <AppLoading />;
  } else {
    return (
      <View style={{flex: 1, alignItems: "center", justifyContent: "center" }}>
        <Text style={{ fontFamily: "Roboto_400Regular", fontSize: 28 }}>
          Nice! Support for Google Fonts!
        </Text>
      </View>
    );
  }
}
Posted by: Guest on February-03-2022
1

import google fonts into react

@import url('https://fonts.googleapis.com/css?family=Patrick+Hand+SC|Roboto&display=swap');

body {
  font-family: 'Patrick Hand SC', cursive;
}
Posted by: Guest on February-16-2020

Browse Popular Code Answers by Language