ctext
TypeScript icon, indicating that this package has built-in type declarations

1.10.4 • Public • Published

Colored Text in Console

Node.js Package

Small library (zero dependency) to display colored text in the console.

Basic Usage

  1. Initialize
const ctext = require('ctext');

const ymu = new ctext({
  color: 'yellow', // or ctext.colors.yellow
  bgColor: 'magenta', // or ctext.bgColors.magenta
  format: 'underscore' // or ctext.format.underscore
});
  1. Use
console.log(ymu.text('Hello World'));

Code and output samples

const ctext = require('ctext');

// text with no styling
const dText = new ctext();

// text with black color and white background
const bw = new ctext({
  color: 'black', 
  bgColor: 'white'
});

// parameters can be passed using colors, bgColors, and format attributes
const ymu = new ctext({
  color: ctext.colors.yellow,
  bgColor: ctext.bgColors.magenta,
  format: ctext.format.underscore
});

const y = new ctext({
  color: ctext.colors.yellow
});

const dr = new ctext({
  bgColor: ctext.bgColors.red
});

console.log(dText.text('Hello World'));
console.log(bw.text('Hello World'));
console.log(ymu.text('Hello World'));
console.log(y.text('Hello World'));
console.log(dr.text('Hello World'));

ctext Object input options

color: String bgColor: String format: String
black black reset
red red bright
green green dim
yellow yellow underscore
blue blue blink
magenta magenta reverse
cyan cyan hidden
white white

Output

Output

Contribution

For contribution details please refer this document.

Keywords

Install

npm i ctext

DownloadsWeekly Downloads

1

Version

1.10.4

License

ISC

Unpacked Size

8.7 kB

Total Files

14

Last publish

Collaborators

  • mshekhar