Responsive Fontsize

Published in Text
June 29, 2022
1 min read
Responsive Fontsize

Introduction

Library to help with responsive font size for varying sizes of display.πŸŽ‰

How to install

yarn add react-native-responsive-fontsize

or

npm install react-native-responsive-fontsize --save

Examples on different device sizes

iPhone SEiPhone X
imgimg

Methods

argumentsDescription
RFPercentagepercent: numberThe font size is calculated as a percentage of the height(width in landscape mode) of the device.
RFValuevalue: number, standardScreenHeight?: numberThe font size is calculated based on standardScreenHeight and passed value
  • when using RFValue’s standardScreenHeight
    • default standardScreenHeight is 680
    • In landscape mode, please pass the screen width

Usage

import { RFPercentage, RFValue } from "react-native-responsive-fontsize";
const styles = StyleSheet.create({
welcome: {
fontSize: RFValue(24, 580) // second argument is standardScreenHeight(optional),
textAlign: "center",
margin: 10,
},
instructions: {
textAlign: "center",
color: "#333333",
marginBottom: 5,
fontSize: RFPercentage(5),
},
});

Changelog

Releases

Credits

Original Author repository


Share


Previous Article
Showdown
Next Article
Measure Text
Omkar Lubal

Omkar Lubal

Computer Science Aficionado

Related Posts

Awesome React Native
Β© 2025, All Rights Reserved.

Social Media