
Description
react-textfit is a React component that fits headlines and paragraphs into any element by sizing their text. It uses a binary search to find the right font size quickly, and the README says it works with any style setup, including line-height and padding. The component has two modes. Single mode is for headlines, and by default it ignores the element's height so the text fits on one line. Multi mode is for paragraphs and wraps the text to fill the element. Props let you set the mode, decide whether the height is ignored in single mode, and set the minimum and maximum font size in pixels. A throttle prop controls how often the text is refitted on window resize, and an onReady callback runs once the text has been fitted. The README includes usage examples for headlines and paragraphs, and it links a demo. The project is MIT licensed and public on GitHub.…
Highlights
- Fits headlines and paragraphs into any element
- Binary search for the right font size
- Single mode for headlines, multi mode for paragraphs
- Min, max and resize throttle props
- onReady callback when text is fitted
Ratings & Reviews
No ratings yet
Be the first to rate react-textfit.
People also visit
react-textfit FAQ
What is react-textfit?
A React component that resizes headlines and paragraphs so they fit inside an element.
What is the difference between single and multi mode?
Single mode is for headlines and by default ignores the element's height. Multi mode is for paragraphs and wraps the text to fill the element.
Which props can I set?
mode, forceSingleModeWidth, the minimum and maximum font size in pixels, a throttle for window resizes, and onReady.
Is it open source?
Yes. It is MIT licensed and public on GitHub.
What are the best react-textfit alternatives?
Popular alternatives to react-textfit include react-text-truncate, react-textarea-autosize and react-lines-ellipsis. See all react-textfit alternatives


















