7

In react native app whats the best way to deal with font size.

I've a kind of weird issue, if font size is increased from mobile device display settings it changes the fontSize of app as well. I have used fontSize:14(whatever value), so it picks the size 14 according to mobile device font size & the font size of entire app get increased and UI looks horrible.

I've also tried to adjust the fontSize using width and height but it also not looks good on all devices.

const WIDTH = Dimensions.get('window').width; const HEIGHT = Dimensions.get('window').height; 
4
  • 1
    Sorry but why you have voted it down? It seems to be a genuine issue. Commented Feb 9, 2018 at 15:31
  • 5
    What you're asking to do is effectively ignore accessibility options on a device and fix the font size so you don't have to worry about your UI enlarging. Larger font sizes are controllable from the device for vision impaired individuals and your UI should respect those settings. Commented Feb 9, 2018 at 15:39
  • 2
    Possible duplicate of React Native Responsive Font Size Commented Feb 9, 2018 at 15:40
  • Thank you Travis. I've added below what worked for me. Commented Feb 12, 2018 at 13:40

1 Answer 1

3

Adding allowFontScaling={false} to Text ignores the device font scaling.

 <Text allowFontScaling={false} style={styles.TitleText}> {this.state.testLabel.toUpperCase()} </Text> 
Sign up to request clarification or add additional context in comments.

1 Comment

I used React-Native-Snackbar for display error messages. The font of snackbar is not fixed though I used 'allowFontScaling={false}'. Is there a way to fix the font size of snackbar as well?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.