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

@oxog/termstyle

v1.0.1

Published

A powerful, feature-rich CLI text formatting library with zero dependencies. Supports colors, gradients, animations, progress bars, and more.

Readme

@oxog/termstyle

npm version npm downloads bundle size license

✨ Features

  • 🎨 Full Color Support - 16, 256, and true color (16.7m colors)
  • 🔗 Chainable API - Intuitive and fluent interface
  • 🌈 Gradient Effects - Beautiful color transitions
  • 📦 Zero Dependencies - Lightweight and fast
  • 🚀 High Performance - Optimized with caching
  • 📊 Progress Bars - Customizable progress indicators
  • 🎭 Animations - Built-in spinner and animation effects
  • 🎯 TypeScript - Full type definitions included
  • 🖼️ Box Drawing - Create boxes around content
  • 🎨 Themes - Predefined and custom theme support

📦 Installation

npm install @oxog/termstyle

🚀 Quick Start

const termstyle = require('@oxog/termstyle').default;
// or with ES modules
import termstyle from '@oxog/termstyle';

// Basic colors
console.log(termstyle.red('Error message'));
console.log(termstyle.green('Success message'));
console.log(termstyle.blue('Info message'));

// Styles
console.log(termstyle.bold('Bold text'));
console.log(termstyle.italic('Italic text'));
console.log(termstyle.underline('Underlined text'));

// Chaining
console.log(termstyle.red.bold('Bold red text'));
console.log(termstyle.blue.underline.italic('Blue underlined italic'));

// Background colors
console.log(termstyle.bgRed.white('White text on red background'));
console.log(termstyle.bgGreen.black('Black text on green background'));

🎨 Colors

Basic Colors

// Foreground colors
termstyle.black('Black text')
termstyle.red('Red text')
termstyle.green('Green text')
termstyle.yellow('Yellow text')
termstyle.blue('Blue text')
termstyle.magenta('Magenta text')
termstyle.cyan('Cyan text')
termstyle.white('White text')
termstyle.gray('Gray text')

// Background colors
termstyle.bgBlack('Text on black background')
termstyle.bgRed('Text on red background')
termstyle.bgGreen('Text on green background')
termstyle.bgYellow('Text on yellow background')
termstyle.bgBlue('Text on blue background')
termstyle.bgMagenta('Text on magenta background')
termstyle.bgCyan('Text on cyan background')
termstyle.bgWhite('Text on white background')
termstyle.bgGray('Text on gray background')

Advanced Colors

// Hex colors
termstyle.hex('#ff6b35')('Orange text')
termstyle.bgHex('#4ecdc4')('Text on teal background')

// RGB colors
termstyle.rgb(255, 107, 53)('RGB orange text')
termstyle.bgRgb(78, 205, 196)('Text on RGB teal background')

// ANSI 256 colors (0-255)
termstyle.color(196)('ANSI 256 red')
termstyle.bgColor(46)('Text on ANSI 256 green background')

✨ Text Styles

termstyle.bold('Bold text')
termstyle.dim('Dim text')
termstyle.italic('Italic text')
termstyle.underline('Underlined text')
termstyle.inverse('Inverse text')
termstyle.hidden('Hidden text')
termstyle.strikethrough('Strikethrough text')

// Combine multiple styles
termstyle.bold.italic.underline('Bold, italic, and underlined')
termstyle.red.bgYellow.bold('Bold red text on yellow background')

🌈 Special Effects

Gradient Text

// Rainbow gradient
termstyle.rainbow('Rainbow colored text')

// Custom gradient
termstyle.gradient('Gradient text', ['red', 'yellow', 'green'])

// Hex gradient
termstyle.gradient('Smooth gradient', ['#ff0000', '#00ff00', '#0000ff'])

Box Drawing

// Simple box
termstyle.box('Hello World')
// ┌───────────┐
// │Hello World│
// └───────────┘

// Customized box
termstyle.box('Important Message', {
  padding: 1,
  margin: 1,
  borderStyle: 'double',
  borderColor: 'blue',
  align: 'center'
})

Progress Bars

// Create a progress bar
const progressBar = termstyle.progressBar({
  total: 100,
  width: 40,
  complete: '█',
  incomplete: '░'
});

// Update progress
progressBar.update(25);  // 25%
console.log(progressBar.render());
// ██████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 25%

// Simple progress bar
console.log(termstyle.bar(50, 100, { width: 20 }));
// ██████████░░░░░░░░░░

Spinners

// Create a spinner
const spinner = termstyle.spinner('Loading...');
spinner.start();

// Update text
spinner.text = 'Processing...';

// Stop with success
spinner.succeed('Complete!');

// Different spinner styles
const customSpinner = termstyle.spinner({
  text: 'Loading',
  spinner: 'dots2' // dots, line, circle, etc.
});

🎯 Conditional Formatting

// Conditional styling
const isError = true;
console.log(
  termstyle.conditional(isError).red('Error occurred')
);

// Conditional chains
termstyle.conditional(process.env.DEBUG).gray('Debug info')

// Status formatters
const status = termstyle.createStatusFormatter();
console.log(status.success('Operation completed'));
console.log(status.error('Operation failed'));
console.log(status.warning('Please review'));
console.log(status.info('For your information'));

📝 Template Literals

// Template literal support
const name = 'World';
console.log(termstyle.red`Hello ${name}!`);

// Complex templates
const user = 'John';
const score = 95;
console.log(
  termstyle.template`User ${termstyle.green(user)} achieved ${
    termstyle.yellow.bold(`${score}%`)
  } success rate!`
);

🎨 Themes

// Use built-in themes
const themes = termstyle.themes;
const theme = themes.get('ocean');

// Create custom theme
const customTheme = new termstyle.ThemeManager();
customTheme.create('myTheme', {
  primary: '#007acc',
  success: '#4caf50',
  error: '#f44336',
  warning: '#ff9800'
});

// Apply theme colors
const colors = customTheme.applyTheme();
console.log(colors.primary('Primary text'));
console.log(colors.success('Success message'));

🛠️ Utilities

// Strip ANSI codes
const styled = termstyle.red.bold('Styled text');
const plain = termstyle.strip(styled);
console.log(plain); // 'Styled text'

// Check color support
console.log(termstyle.supportsColor); // true/false
console.log(termstyle.level); // 0, 1, 2, or 3

// Get terminal info
const info = termstyle.getTerminalInfo();
console.log(info);
// {
//   supportsColor: true,
//   colorLevel: 3,
//   columns: 120,
//   rows: 30
// }

🔧 Advanced Usage

Create Custom Formatter

// Create a custom formatter instance
const myStyle = termstyle.create({ force: true });

// Log formatter
const logger = termstyle.createLogFormatter({
  timestamp: true,
  usePrefix: true
});

console.log(logger.info('Information message'));
console.log(logger.warn('Warning message'));
console.log(logger.error('Error message'));
console.log(logger.debug('Debug message'));

Method Chaining

// Complex chaining
termstyle
  .red
  .bgYellow
  .bold
  .underline
  .italic('Complex styled text');

// Conditional chaining
const productionError = termstyle.conditional(isProduction).red('Production error!');
console.log(productionError);

📊 Performance

TermStyle is optimized for performance:

  • Lazy evaluation of styles
  • Intelligent caching system
  • Minimal overhead
  • Zero dependencies
// Efficient for loops
const styled = termstyle.red.bold;
for (let i = 0; i < 1000; i++) {
  console.log(styled(`Item ${i}`));
}

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

📄 License

MIT © TermStyle