Auto size text to fit inside a box
This repo will be discontinued as adjustsFontSizeToFit
was added to react-native Text elements facebook/react-native#4026 .. Finally! 😉
children
: required Text input that should be resizedwidth
: Maximum width of the box. (Default: auto)height
: Maximum height of the box. (Default: auto)- Other React props
npm i -S react-native-textfit
import TextFit from "react-native-textfit"
<TextFit
height={200}
width={150}
style={{color: 'red'}}
onPress={event => 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.'}
</TextFit>
- git clone https://github.com/stoffern/react-native-textfit.git
- cd react-native-textfit/example
- npm start