colorred.js
Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback, and check the develop
branch for the latest bleeding-edge updates.
get color and style in your node.js console
Installation
npm install colorred
colors and styles!
text colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
- gray
- grey
bright text colors
- brightRed
- brightGreen
- brightYellow
- brightBlue
- brightMagenta
- brightCyan
- brightWhite
background colors
- bgBlack
- bgRed
- bgGreen
- bgYellow
- bgBlue
- bgMagenta
- bgCyan
- bgWhite
- bgGray
- bgGrey
bright background colors
- bgBrightRed
- bgBrightGreen
- bgBrightYellow
- bgBrightBlue
- bgBrightMagenta
- bgBrightCyan
- bgBrightWhite
styles
- reset
- bold
- dim
- italic
- underline
- inverse
- hidden
- strikethrough
- rainbow
- zebra
- america
- trap
- random
Usage
var colorred = require('colorred');
console.log(colorred.green('hello'));
console.log(colorred.red.underline('i like cake and pies'));
console.log(colorred.inverse('inverse the color'));
console.log(colorred.rainbow('OMG Rainbows!'));
console.log(colorred.trap('Run the trap'));
Enabling/Disabling Colors
The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
node myapp.js --no-color
node myapp.js --color=false
node myapp.js --color
node myapp.js --color=true
node myapp.js --color=always
FORCE_COLOR=1 node myapp.js
Or in code:
var colorred = require('colorred');
colorred.enable();
colorred.disable();
Custom themes
var colorred = require('colorred');
var error = ### Using string safe API.red;
error('this is red');
colorred.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red'
});
console.log(colorred.error("this is an error"));
console.log(colorred.warn("this is a warning"));