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 πŸ™

Β© 2025 – Pkg Stats / Ryan Hefner

react-fitter

v0.1.8

Published

<h1 align="center">🫸 πš›πšŽπšŠπšŒπš-πšπš’πšπšπšŽπš› 🫷</h1>

Readme

In a project of mine I had to fit some text of unknown length to a container without it wrapping. This utility component does exactly that, regardless of whether if it sits inline, in a flexbox, grid or table. It just works.

Important πŸ’‘

At the moment the fitter can have some issues adjusting to containers that resize based on their content. A feeback loop occurs where the fitter never settles because the size changes with every change in font size. I have some ideas on how to fix this but haven't tried implemented any them yet. If this is an issue for your use case, please don't hesitate to open an issue.

npm install react-fitter

Usage:

import {Β Fitter } from 'react-fitter'

// ...

<div className="my-text">
  <Fitter>
    This is some text that will perfectly fit in the container
  </Fitter>
</div>

And your CSS can be whatever you want. The Fitter component will never make the text larger than what's set by your styles. It will only ever make it smaller.

.my-text {
  width: 400px;
  font-size: 24px;
  border: 1px solid hotpink;
}

Which would look like this:

Example with react-fitter

In contrast to how it would look without react-fitter:

Example without react-fitter

Fitter component props

Prop name | Type | Default value | Description --- | --- | --- | --- children | ReactNode | (required) | The content to fit. minSize | number | 0.25 | The minimum scale that the text will shrink to. E.g. 0.25 means the text will shrink to no less than 25% of its original size. maxLines | number | 1 | The maximum number of lines that the text will shrink to fit. settlePrecision | number | 0.01 | The precision at which the text will settle. The component finds the best size by halving the difference between the current size and the min/max size. If the difference is less than the settle precision, the component will stop and settle on that size. A value of 0.01 means the component will settle when the difference is less than 1%. updateOnSizeChange | boolean | true | Whether to update the text size when the size of the component changes. resizeDebounceMs | number | 50 | The time in milliseconds to wait before updating the text size when the size of the component changes. This is useful when the component is being resized frequently and you want to avoid updating the text size on every resize event.