https://github.com/lassehaslev/fit-text
Resizes text to fit width of parent
https://github.com/lassehaslev/fit-text
Last synced: 24 days ago
JSON representation
Resizes text to fit width of parent
- Host: GitHub
- URL: https://github.com/lassehaslev/fit-text
- Owner: LasseHaslev
- Created: 2017-01-20T22:54:40.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-15T12:34:27.000Z (about 9 years ago)
- Last Synced: 2025-01-05T09:29:20.633Z (over 1 year ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @lassehaslev/fit-text
> Resizes text to fit width of parent
## Install
Run ```npm install @lassehaslev/fit-text --save``` in your project folder.
## Usage
```js
import FitText from '@lassehaslev/fit-text';
var element = document.querySelector( '.fittext-multiline' );
// Use default options
new FitText( element );
// Overwrite defaults
new FitText( element, {
compressor: .1,
minFontSize: Number.NEGATIVE_INFINITY,
maxFontSize: Number.POSITIVE_INFINITY,
multiline: false,
watch: true,
widthMargin: 0,
unit: 'em',
debugColor: null, // Only for debuging
} );
```
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload
npm run dev
```