A hook used to fit text in one line inside its container.
npm install use-text-fit
import useTextFit from 'use-text-fit';
function Title() {
const {ref} = useTextFit();
return <div ref={ref}>
Lorem Ipsum
</div>;
}
- Pass the
ref
to the text container element. - Profit.