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

@averagejoeslab/style

v1.0.1

Published

Terminal styling library with padding, margins, borders, and alignment

Readme

@puppuccino/style

CSS-like terminal styling with a fluent builder API.

Installation

npm install @puppuccino/style

Or install from GitHub:

npm install github:averagejoeslab/style

Features

  • Fluent Builder API - Chain methods for readable style definitions
  • Box Model - Padding, margin, and borders
  • Text Styling - Colors, bold, italic, underline, and more
  • Layout - Width, height, alignment, and text wrapping
  • Borders - Multiple border styles with custom characters
  • Inheritance - Copy and extend existing styles

Usage

Basic Styling

import { style } from '@puppuccino/style';

// Create a styled string
const greeting = style()
  .bold()
  .foreground('#FF5500')
  .render('Hello, World!');

console.log(greeting);

// Chain multiple styles
const warning = style()
  .bold()
  .foreground('yellow')
  .background('red')
  .padding(1)
  .render('WARNING');

console.log(warning);

Text Styles

import { style } from '@puppuccino/style';

const s = style()
  .bold()              // Bold text
  .italic()            // Italic text
  .underline()         // Underlined text
  .strikethrough()     // Strikethrough text
  .dim()               // Dimmed text
  .blink()             // Blinking text
  .inverse()           // Inverted colors
  .render('Styled text');

Colors

import { style } from '@puppuccino/style';

// Named colors
const red = style().foreground('red').render('Red text');

// Hex colors
const orange = style().foreground('#FF5500').render('Orange text');

// RGB colors
const custom = style().foreground([100, 150, 200]).render('Custom color');

// 256-color palette
const palette = style().foreground(196).render('Color 196');

// Background colors
const highlight = style()
  .foreground('white')
  .background('blue')
  .render('Highlighted');

Box Model

import { style } from '@puppuccino/style';

// Padding (inside the box)
const padded = style()
  .padding(1)           // All sides
  .paddingLeft(2)       // Override left
  .render('Padded content');

// Margin (outside the box)
const spaced = style()
  .margin(1)            // All sides
  .marginTop(2)         // Override top
  .render('Spaced content');

// Fixed dimensions
const box = style()
  .width(20)
  .height(5)
  .render('Fixed size box');

Borders

import { style, BorderStyle } from '@puppuccino/style';

// Simple border
const bordered = style()
  .border(BorderStyle.Rounded)
  .render('Bordered content');

// Border with color
const colorBorder = style()
  .border(BorderStyle.Double)
  .borderForeground('cyan')
  .render('Cyan border');

// Individual border sides
const partial = style()
  .borderTop()
  .borderBottom()
  .render('Top and bottom only');

// Available border styles:
// - BorderStyle.Normal    ┌─┐
// - BorderStyle.Rounded   ╭─╮
// - BorderStyle.Double    ╔═╗
// - BorderStyle.Thick     ┏━┓
// - BorderStyle.Hidden    (no visible border)

Alignment

import { style, Position } from '@puppuccino/style';

// Horizontal alignment
const centered = style()
  .width(40)
  .align(Position.Center)
  .render('Centered text');

const right = style()
  .width(40)
  .align(Position.Right)
  .render('Right aligned');

// Vertical alignment (with fixed height)
const middle = style()
  .width(20)
  .height(5)
  .alignVertical(Position.Center)
  .render('Vertically centered');

Text Wrapping

import { style } from '@puppuccino/style';

const wrapped = style()
  .width(40)
  .render('This is a long text that will be wrapped to fit within 40 columns.');

// Word wrap (default)
const wordWrap = style()
  .width(30)
  .wordWrap()
  .render('Long text with word wrapping enabled');

// Character wrap (break anywhere)
const charWrap = style()
  .width(30)
  .charWrap()
  .render('Long text that breaks at character boundaries');

Style Inheritance

import { style } from '@puppuccino/style';

// Create a base style
const baseStyle = style()
  .foreground('white')
  .background('blue')
  .padding(1);

// Extend it
const headerStyle = baseStyle
  .copy()
  .bold()
  .align(Position.Center);

// Use both
console.log(baseStyle.render('Base'));
console.log(headerStyle.render('Header'));

Inline Styling

import { style } from '@puppuccino/style';

// Apply inline styles within text
const mixed = style()
  .render('Normal ' + style().bold().render('bold') + ' normal');

// Using template literals
const message = `
  ${style().bold().render('Title')}
  ${style().dim().render('Subtitle')}
`;

Complete Example

import { style, BorderStyle, Position } from '@puppuccino/style';

const card = style()
  .width(40)
  .padding(1)
  .border(BorderStyle.Rounded)
  .borderForeground('cyan')
  .render(`
${style().bold().foreground('white').render('Card Title')}
${style().dim().render('─'.repeat(36))}
This is the card content with some
descriptive text that explains things.
${style().foreground('cyan').render('Learn more →')}
`);

console.log(card);

API Reference

Style Builder Methods

Text Styles

  • bold() / unbold()
  • italic() / unitalic()
  • underline() / ununderline()
  • strikethrough()
  • dim() / undim()
  • blink() / unblink()
  • inverse() / uninverse()

Colors

  • foreground(color) - Text color
  • background(color) - Background color

Box Model

  • padding(n) / paddingLeft(n) / paddingRight(n) / paddingTop(n) / paddingBottom(n)
  • margin(n) / marginLeft(n) / marginRight(n) / marginTop(n) / marginBottom(n)
  • width(n) / maxWidth(n)
  • height(n) / maxHeight(n)

Borders

  • border(style) - Set border style
  • borderTop() / borderBottom() / borderLeft() / borderRight()
  • borderForeground(color) - Border color
  • borderBackground(color) - Border background

Alignment

  • align(position) - Horizontal alignment
  • alignVertical(position) - Vertical alignment

Text

  • wordWrap() - Enable word wrapping
  • charWrap() - Enable character wrapping

Utilities

  • copy() - Create a copy of the style
  • render(text) - Apply style to text

Constants

  • BorderStyle - Border style presets
  • Position - Alignment positions (Left, Center, Right, Top, Bottom)

License

MIT