text-fit-component

1.0.4 • Public • Published

text-fit-component

See the demo

Puts text inside of another element at just the right font size so that it perfectly fits the width of its container.

Uses get-text-fit-size.

Automatically adjust on window resize.

Doesn't work in IE or Edge yet.

Example

<body>
	<h1 id="header"></h1>
	<p>Aw yeah</p>
</body>
const TextFit = require('text-fit-component')

new TextFit({
	target: document.getElementById('header'),
	data: {
		text: 'This is a cool header'
	}
})

This module is also usable as a Svelte component.

<h1 id="header">
	<TextFit text="This is a cool header" />
</h1>
<p>Aw yeah</p>

<script>
	import TextFit from 'text-fit-component'

	export default {
		components: {
			TextFit
		}
	}
</script>

License

WTFPL

Package Sidebar

Install

npm i text-fit-component

Weekly Downloads

1

Version

1.0.4

License

WTFPL

Last publish

Collaborators

  • tehshrike