ansi-colors-es6
Easily add ANSI colors to your node terminal or browser console. A faster drop-in replacement for chalk, colors, kleur and turbocolor (without the dependencies and rendering bugs). And a lighter ES6 implementation of
ansi-colors
that works everywhere ES6+ works without the need for transpiling, unless you want to.
Install
Install with npm:
$ npm install --save ansi-colors-es6
Why use this?
ansi-colors-es6 is the fastest Node.js library for terminal and browser console styling. A more performant drop-in replacement for chalk, colors and ansi-colors with no dependencies.
- Works in the browser as well as the terminal!
- Blazing fast - Fastest terminal styling library in node.js, and the browser!
- No dependencies
- Safe - Does not modify the
String.prototype
like others. - Supports nested colors, and does not have the nested styling bug that is present in colorette, chalk, and kleur.
- Supports chained colors.
- Toggle color support on or off.
Chrome
Edge
Usage
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; console;console;console;console;
Chained colors
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; console;console;console;
Nested colors
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; console;
Toggle color support
Easily enable/disable colors.
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; // disable colors manuallyansienabled = false; // or use a library to automatically detect supportansienabled = hasBasic; console;
Strip ANSI codes
Use the .unstyle
method to strip ANSI codes from a string.
console;//=> 'foo bar baz'
Available styles
Note that bright and bright-background colors are not always supported.
Colors | Background Colors | Bright Colors | Bright Background Colors |
---|---|---|---|
black | bgBlack | blackBright | bgBlackBright |
red | bgRed | redBright | bgRedBright |
green | bgGreen | greenBright | bgGreenBright |
yellow | bgYellow | yellowBright | bgYellowBright |
blue | bgBlue | blueBright | bgBlueBright |
magenta | bgMagenta | magentaBright | bgMagentaBright |
cyan | bgCyan | cyanBright | bgCyanBright |
white | bgWhite | whiteBright | bgWhiteBright |
gray | |||
grey |
(gray
is the U.S. spelling, grey
is more commonly used in the Canada and U.K.)
Style modifiers
-
dim
-
bold
-
hidden
-
italic
-
underline
-
inverse
-
strikethrough -
reset
Aliases
Create custom aliases for styles.
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; ansi;ansi; console;
Themes
A theme is an object of custom aliases.
//use relative paths to allow code sharing with browsers//this way the same exact files will work in all locations; ansi; // Now, we can use our custom styles alongside the built-in styles!console;console;console;console;
Contributors
Commits | Contributor |
---|---|
48 | jonschlinkert |
42 | doowb |
9 | RIAEvangelist |
6 | lukeed |
2 | Silic0nS0ldier |
1 | dwieeb |
1 | jorgebucaran |
1 | madhavarshney |
1 | chapterjason |