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

@borgar/textbox

v2.0.0

Published

A utility to render formatted multi-line rich text.

Readme

Textbox

Textbox is a simple library to layout multiline text for display on SVG or Canvas. It can fairly decently line-break and render rich text given some boundaries. It understands simple text, and a small subset of HTML and LaTeX syntaxes. The original purpose of this software is to aid labeling charts.

Take a look at Textbox example and demos if you are curious what this library can do.

Features:

  • Line-break text to fit dimensions.
  • Can overflow text into ... if it doesn't fit designated area.
  • Understands common text features: bold, italic, links, etc...
  • Knows that there is different whitespace like thin, or non-breaking.
  • Tries to be smart about line-breaking before or after certain characters (it can occur after - but not before).
  • Supports hyphenation if text is prepared with soft-hyphens.

Installing

If you don't want to download and build Textbox yourself, the library is also provided as an NPM package:

$ npm install @borgar/textbox

API Reference

For any use, you will need to start by defining a new Textbox instance. You may pass a configuration object as a parameter:

const box = new Textbox({
  font: '12px/14px sans-serif',
  width: Infinity,
  height: Infinity,
  align: 'left',
  valign: 'top',
  x: 0,
  overflow: 'ellipsis',
  parser: 'text',
  createElement: Textbox.createElement
});

Shown here are the defaults, but any or all of the above parameters can be provided. The Textbox instance will provide methods by the same name, along with line-breaking and rendering methods:

const box = new Textbox()
  .font('16px/19px sans-serif')
  .align('center')
  .parser('html')
  .createElement(React.createElement);

Full API documentation can be found in docs/API.md.

Limitations:

  1. In SVG links do not automatically get color or pointer cursor. You will need to add your own styles to these.

    svg text a {
      fill: blue;
      text-decoration: underline;
      cursor: pointer;
    }
  2. Multi-word links in SVG text are not necessarily a single entity/element like they are in HTML. If the text in a link is line-broken, then hovering one segment will not cause segment in the next line over to trigger hover styles.

  3. Text justification does not work consistently in all browsers as they have buggy support for the word-spacing property. Google Chrome seems to work fine, Safari works for plain text but incorrectly for formatted text. Firefox is fairly random. Test your output in different browsers before you publish.

  4. Subscript and superscript are bugged in Firefox because they have never implemented the baseline-shift property. The bug report is 20 years old currently, so aaaaaany day now.