@domir/react-native-measure-text
TypeScript icon, indicating that this package has built-in type declarations

0.1.8 • Public • Published

react-native-measure-text

Measure the size of a string of text in React Native synchronously.

This can be useful for calculating the size of a string of text before rendering it, for example for animation targets.

API documentation

Add the package to your npm dependencies

npm install @domir/react-native-measure-text

Configure for iOS

Run npx pod-install after installing the npm package.

Configure for Android

No additional configuration is needed.

Usage

import * as MeasureText from '@domir/react-native-measure-text';

MeasureText.measureWidth('Hello World', {
  fontSize: 20,
  fontFamily: 'Helvetica',
  fontWeight: 'normal',
  // TBD
  // fontStyle: 'normal',
  // fontVariant: ['small-caps'],
  // letterSpacing: 0,
  // lineHeight: 20,
  // textAlign: 'left',
  // textDecorationLine: 'none',
  // textTransform: 'none',
  // includeFontPadding: true,
  // maxWidth: 100,
  // maxHeight: 100,
  // numberOfLines: 1,
  // ellipsizeMode: 'tail',
})

Package Sidebar

Install

npm i @domir/react-native-measure-text

Weekly Downloads

70

Version

0.1.8

License

MIT

Unpacked Size

39.5 kB

Total Files

44

Last publish

Collaborators

  • domir