0.1.7 • Published 5 years ago

react-resize-text v0.1.7

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

Component that resizes font-size of children to fit the parent container.

Supports Typescript

Examples

    <TextResize defaultFontSize={26}>
        <p>Lorem Ipsum...</p>
    </TextResize>

    <TextResize defaultFontSize={26}>
        Lorem Ipsum...
    </TextResize>

    <TextResize defaultFontSize={26}>
        Lorem Ipsum...
        <div>Lorem Ipsum...</div>
        <p>Lorem Ipsum...</p>
    </TextResize>

    <TextResize defaultFontSize={26} minFontSize={14} maxFontSize={36}>
        <p>Lorem Ipsum...</p>
    </TextResize>

React Props

  • defaultFontSize: Starting font size
  • maxFontSize: maximum font size
  • minFontSize: minimum font size
  • className: add some css to the text parent

Algorithm

Uses binary search to find the right font-size - Blazing fast!
Uses useRef (React Hooks) to access the components and check the dimension.

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago