Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to set a font globally in React Native?

I need to create a custom font that applies to every Text component in the whole application.

Is there is a way to set a font globally in React Native?

like image 989
Thisara Avatar asked Jun 25 '18 12:06

Thisara


1 Answers

One way is to create a wrapper for RN Text say MyTextCustomFont:

const MyTextCustomFont = (props) => {
   return (
        <Text style={{fontFamily:'myFont'}} {...props} >{props.children}</Text>
   )
}

import this MyTextCustomFont and use anywhere.

Another way is to define a style object and use it wherever you want.

like image 187
Revansiddh Avatar answered Jan 19 '23 15:01

Revansiddh