npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@chrctr/shoehorn

v0.5.1

Published

A custom element that measures the size of text and adjusts its font size to fit the container.

Readme

@chrctr/shoehorn

npm version license

A zero-dependency, high-performance Web Component that automatically adjusts the font size of text to perfectly fit its container. Ideal for headlines, banners, and digital signage (DOOH).

This project is inspired by Fitty, adapted as a modern Web Component with TypeScript support.

Features

  • Three Fitting Modes: Fit text to width, height, or a 2D box.
  • Framework Agnostic: Works in any framework (React, Vue, Svelte) or with no framework at all.
  • Lightweight: Tiny footprint with zero dependencies.
  • Modern API: Built with modern browser features like ResizeObserver for optimal performance.

Installation

npm install @chrctr/shoehorn

Usage

There are two ways to use the component, depending on your project setup.

1. With a Bundler (Vite, Webpack, etc.)

Import the component into your main JavaScript or TypeScript file. This will register the <shoehorn-text> custom element, making it available throughout your application.

// main.js
import '@chrctr/shoehorn';

2. Via <script> Tag

For environments without a build step (like CodePen, basic HTML pages, or some CMS platforms), you can use a CDN like JSDelivr.

<!-- Add this to your HTML file -->
<script type="module" src="[https://cdn.jsdelivr.net/npm/@chrctr/shoehorn/dist/shoehorn.esm.js](https://cdn.jsdelivr.net/npm/@chrctr/shoehorn/dist/shoehorn.esm.js)"></script>

Example

Once the component is registered, you can use it directly in your HTML.

<div style="width: 800px; height: 150px; border: 2px solid #333;">
  <shoehorn-text>
    This text will scale to fit!
  </shoehorn-text>
</div>

API

Control the behavior of the component using these HTML attributes.

| Attribute | Type | Default | Description | |---------------|-----------|-----------|---------------------------------------------------------------------------------------------------------| | mode | string | "width" | Sets the fitting algorithm. Can be "width", "height", or "box". | | min-size | number | 16 | The minimum font size in pixels that the text can shrink to. | | max-size | number | 512 | The maximum font size in pixels that the text can grow to. |

Modes

mode="width" (Default)

Scales the text to fill the full width of the container on a single line. The height will adjust automatically.

<div style="width: 100%; height: 120px;">
  <shoehorn-text mode="width">Fills the width</shoehorn-text>
</div>

mode="height"

Scales the text to fill the full height of the container on a single line. The text may overflow its container's width if it is too long.

<div style="width: 400px; height: 150px;">
  <shoehorn-text mode="height">Fills the height</shoehorn-text>
</div>

`mode="box"

The resize method allows manual triggering of the resize logic. This can be useful in scenarios where the parent element's size changes programmatically. It calls the existing fit method with the sync option set to true, ensuring that the resizing occurs immediately. Scales the text to be as large as possible without overflowing the container's width OR height, wrapping lines as needed. This is the most powerful mode for fitting text into a fixed-size box.

<div style="width: 350px; height: 250px;">
  <shoehorn-text mode="box" min-size="12">
    This text fits perfectly inside the entire box.
  </shoehorn-text>
</div>

Contributing

Contributions are welcome! If you have a feature request, bug report, or pull request, please open an issue on the GitHub repository.

License

This project is licensed under the MIT License.