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

@selfteachme/boxerjs

v1.0.0

Published

A utility for drawing beautiful boxes around terminal content

Readme

@selfteachme/boxerjs

A beautiful and flexible utility for drawing boxes around terminal content. Perfect for CLI applications using yargs and chalk.

Features

  • Draw boxes around any text content
  • Flexible width options: content-based, fixed, or terminal width
  • Text alignment options: left, center, or right
  • Customizable padding and margins
  • Custom border styles and colors using chalk
  • Full TypeScript support
  • Compatible with yargs and chalk

Installation

npm install @selfteachme/boxerjs chalk
# If you're using yargs
npm install yargs

Usage

Basic Example

import { Box } from '@selfteachme/boxerjs';
import chalk from 'chalk';

const box = new Box({
  content: 'Hello, World!',
  color: chalk.green,
  borderColor: chalk.blue
});

console.log(box.toString());

Output:

╭───────────────╮
│ Hello, World! │
╰───────────────╯

Terminal-width Box with Alignment

const box = new Box({
  content: 'Centered text in a terminal-width box',
  width: 'terminal',
  align: 'center',  // 'left', 'center', or 'right'
  padding: [1, 2],
  color: chalk.yellow
});

console.log(box.toString());

Output:

╭──────────────────────────────────────────────────────────────╮
│                                                              │
│            Centered text in a terminal-width box             │
│                                                              │
╰──────────────────────────────────────────────────────────────╯

With Yargs

import yargs from 'yargs';
import { Box } from '@selfteachme/boxerjs';
import chalk from 'chalk';

yargs
  .command({
    command: 'greet <name>',
    describe: 'Greet someone with a fancy box',
    builder: {
      color: {
        describe: 'Text color',
        type: 'string',
        default: 'green'
      },
      align: {
        describe: 'Text alignment',
        choices: ['left', 'center', 'right'],
        default: 'left'
      }
    },
    handler: (argv) => {
      const box = new Box({
        content: `Hello, ${argv.name}!`,
        width: 'terminal',
        align: argv.align,
        color: chalk[argv.color],
        padding: [1, 2],
        margin: [1, 0]
      });
      
      console.log(box.toString());
    }
  })
  .argv;

Advanced Options

const box = new Box({
  content: 'Multi-line\ncontent example',
  width: 'terminal',     // or 'content' or fixed number
  align: 'center',       // or 'left' or 'right'
  padding: [1, 2],       // [vertical, horizontal] or single number
  margin: [1, 2],        // [vertical, horizontal] or single number
  color: chalk.green,
  borderColor: chalk.blue,
  style: {
    topLeft: '╔',
    topRight: '╗',
    bottomLeft: '╚',
    bottomRight: '╝',
    horizontal: '═',
    vertical: '║'
  }
});

API Reference

BoxOptions

| Option | Type | Description | |--------|------|-------------| | content | string | The text content to wrap in a box | | width | 'content' | 'terminal' | number | Box width strategy (default: 'content') | | align | 'left' | 'center' | 'right' | Text alignment within the box (default: 'left') | | padding | number | [number, number] | Inner padding [vertical, horizontal] (default: 0) | | margin | number | [number, number] | Outer margin [vertical, horizontal] (default: 0) | | style | BoxStyle | Custom border characters | | color | chalk.Chalk | Text color using chalk | | borderColor | chalk.Chalk | Border color using chalk |

BoxStyle

| Property | Default | Description | |----------|---------|-------------| | topLeft | '╭' | Top-left corner character | | topRight | '╮' | Top-right corner character | | bottomLeft | '╰' | Bottom-left corner character | | bottomRight | '╯' | Bottom-right corner character | | horizontal | '─' | Horizontal border character | | vertical | '│' | Vertical border character |

License

MIT