HomeOur TeamContact

Responsive Fontsize

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

Table Of Contents

01
Introduction
02
How to install
03
Methods
04
Usage

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


Previous Article
Showdown
Next Article
Measure Text
Omkar Lubal

Omkar Lubal

Computer Science Aficionado

Related Posts

Text Size
Text Size
June 29, 2022
5 min

Quick Links

Advertise with usAbout UsContact Us

Social Media