https://github.com/st0ffern/react-native-textfit
Auto size text to fit inside a box
https://github.com/st0ffern/react-native-textfit
Last synced: about 1 year ago
JSON representation
Auto size text to fit inside a box
- Host: GitHub
- URL: https://github.com/st0ffern/react-native-textfit
- Owner: st0ffern
- Created: 2016-07-18T08:04:50.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-07T15:33:57.000Z (almost 3 years ago)
- Last Synced: 2025-04-13T05:16:38.516Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 14
- Watchers: 1
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# react-native-textfit [](https://www.npmjs.org/package/react-native-textfit)
Auto size text to fit inside a box
***This repo will be discontinued as `adjustsFontSizeToFit` was added to react-native Text elements https://github.com/facebook/react-native/pull/4026 .. Finally! :wink:***
## Props
- `children`: ***required*** Text input that should be resized
- `width`: Maximum width of the box. (Default: auto)
- `height`: Maximum height of the box. (Default: auto)
- [Other React props](https://facebook.github.io/react-native/docs/text.html#props)
## Installation
```js
npm i -S react-native-textfit
```
## Usage Examples
```js
import TextFit from "react-native-textfit"
```
```html
console.log(event)}>
{'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'}
```
## Try example
```
- git clone https://github.com/stoffern/react-native-textfit.git
- cd react-native-textfit/example
- npm start
```