heyman333 / react-native-responsive-fontSize

πŸ”  Responsive fontSize based on screen-size of the device in React-Native

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

main image

react-native-responsive-fontsize

PRs Welcome Platform License Greenkeeper badge npm version

Use this library if you have a small problem with the font size πŸŽ‰


How to install

yarn add react-native-responsive-fontsize
# or
npm install react-native-responsive-fontsize --save

How it looks on different device sizes

iPhone SE iPhone X

Methods

arguments Description
RFPercentage percent: number The font size is calculated as a percentage of the height(width in landscape mode) of the device.
RFValue value: number, standardScreenHeight?: number The 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

Load map (I'm waiting for your help)

  • support landscape mode
  • make test code

About

πŸ”  Responsive fontSize based on screen-size of the device in React-Native

License:MIT License


Languages

Language:JavaScript 43.4%Language:HTML 22.6%Language:CSS 10.8%Language:Objective-C 8.4%Language:Ruby 5.6%Language:Java 5.3%Language:Starlark 3.9%