1.0.25 • Published 4 years ago

auto-fontsize v1.0.25

Weekly downloads
2,011
License
MIT
Repository
github
Last release
4 years ago

auto-fontsize

This React component is used for limit text in the certain line(s) by shrink the font size.

Install

npm i auto-fontsize --save

Usage

import {AutoFontSize} from 'auto-fontsize

Parameters

ProperyTypeOptionalDefaultNote
textstringFalseN/AText to display
fontSizeMappingIFontSizeLineHeightMapping []Trueundefineddefine Array of IFontSizeLineHeightMapping to execute the defined step sizing
textSizenumberTrueN/AStart font size, if null, will use the inherit value from parent element
minTextSizenumberTrue2Minimum text size to try on auto sizing
lineHeightRationumber or stringTrue'normal'line height setting for auto sizing
tetextSizeStepxtnumberTrue2Decrease step of font size when auto sizing
targetLinesnumberTrue1Target maximum lines when auto sizing
targetElementType'div' or 'p' or 'span'True'div'Target container to put the auto sizing text
ellipsisOverflowbooleanTruefalseShow ellipsis ... when text is overflow

IFontSizeLineHeightMapping

interface IFontSizeLineHeightMapping {
    fontSize: number;
    lineHeight: number | string | 'normal';
}

Use auto sizing

<AutoFontSize
            text="The quick brown fox jumps over the lazy dog"
            minTextSize={16}
            textSize={28}
            textSizeStep={2}
            targetLines={1}
        />

Use defined step auto sizing

<AutoFontSize
    text="The quick brown fox jumps over the lazy dog"
     fontSizeMapping={[
         { fontSize: 28, lineHeight: '31px' },
         { fontSize: 16, lineHeight: '19px' }
         ]}
            />
1.0.25

4 years ago

1.0.24

5 years ago

1.0.23

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago