Fitty

fitty

Makes text fit perfectly.

Fitty, Snugly text resizing: Scales up (or down) text so it fits perfectly to its parent container.

The crux is of fitty is the fit method which marks the fitty as dirty and requests a redraw (this will also redraw any other fitty marked as dirty).

Get it: npm install fitty

Sample usage:

1
2
3
const fitty = require('fitty');

fitty('#my-element);

Default options:

1
2
3
4
5
6
const defaultOptions = {
  minSize: 16,
  maxSize: 512,
  multiLine: true,
  observeMutations: 'MutationObserver' in w ? mutationObserverDefaultSetting : false
};

Yes, it uses MutationObserver.

GIF FTW!

fitty

Suggest a module

Comments