my-colors

1.0.0 • Public • Published

License: MIT Build Status

my-colors

Colorize terminal text for Node

createColor(foreground, background, modifier)

Returns a colorizer function.

Both foreground & background arguments expect a color. A color could be one of the following:

  • A supported color name (see list below)
  • 0-255 Number - see 256 color palette
  • HEX - a hex color string that starts with a hash sign (e.g. '#1d3ddf')
  • RGB - an array of three values (e.g. [200, 40, 40])

Example:

// my-app.js
const createColor = require('my-colors');
 
const warning = createColor('yellow', 'red', 'bold');
const msg = warning('Attention: Do not do that.');
 
console.log(msg)

Terminal Example

Supported Safe Color Names

  • Black
  • Red
  • Green
  • Yellow
  • Blue
  • Magenta
  • Cyan
  • White

Modifiers

Note: Support may vary between different OS/terminals

  • bold
  • dim
  • italic
  • underline
  • invert
  • strike

Example:

// using hex color foreground, RGB background, and bold & underline modifiers
createColor('#000000', [77, 160, 255], ['bold', 'underline']);

Package Sidebar

Install

npm i my-colors

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

60.3 kB

Total Files

17

Last publish

Collaborators

  • taitulism