An open API service indexing awesome lists of open source software.

https://github.com/lipp/fit-text

A fit text to width responsive web component
https://github.com/lipp/fit-text

Last synced: 9 months ago
JSON representation

A fit text to width responsive web component

Awesome Lists containing this project

README

          

# fit-text

A very basic and lightweight vanilla fit-text web component, which adjusts the font-size to fit the parent container width.

[![Demo](./demo.gif)](https://fit-text.now.sh/examples/tiles.html)

.

## Highlights

- vanilla web component / custom element
- less than 600 byte (minified + gzip)
- no dependencies
- no additional css / js required
- supports custom fonts

The implementation relies on custom elements and shadow dom parts of the web component specs
([check support](https://developer.mozilla.org/en-US/docs/Web/Web_Components#Browser_support)).
For using custom fonts, the browser must support the `FontFaceSet` API (`onloadingdone` event,
[check support](https://developer.mozilla.org/kab/docs/Web/API/FontFaceSet#Browser_compatibility))

Thus, not every major Browser is supported yet.

# Demo

Play with this demo on [codepen.io](https://codepen.io/lipp/pen/YJGvEe?editors=1100#0).

# Usage

```html


This fits to 50vw

```

Also checkout the [examples directory](./examples). They are deployed [here](https://fit-text.now.sh/examples/)