Skip to content

React Native Text scales the font size based on a device width

License

Notifications You must be signed in to change notification settings

thibautguedou3/react-native-text

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native Text

About

React Native Text scales the font size based on a device width.

This is the comparison of two screens (iPhone 4s and iPhone 6s Plus), with applied style:

welcome: {
  fontSize: 31,
  textAlign: 'center',
  margin: 10,
},
instructions: {
  fontSize: 16,
  textAlign: 'center',
  color: '#333333',
  marginBottom: 5,
}

With react-native-text

with

Without (using <Text /> from React Native Core)

without

Get Started

  1. npm install --save react-native-text
  2. Example usage:
import React, { PropTypes } from 'react';
import { StyleSheet } from 'react-native';
import ScalableText from 'react-native-text';

const WelcomeText = ({ text }) => (
  <ScalableText style={styles.text}>{text}</ScalableText>
);

WelcomeText.propTypes = {
  text: PropTypes.string.isRequired
};

const styles = StyleSheet.create({
  text: {
    color: 'tomato',
    fontSize: 28
  }
});

export default WelcomeText;

About

React Native Text scales the font size based on a device width

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%