1.0.1 • Published 10 months ago

@anicetus/console-style v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

console.style

A simple NPM package that lets you easily customize your console.logs!

Easy to use and fast to setup, console.style boasts a large amount of customization.

Setup

The package is really easy to install from NPM. Just run npm install @anicetus/console-style

Example script:

const consoleStyle = require("console-style");

// string, font color, background color, style, [newline?], [use the last format?]
consoleStyle('Error at line xx col xx', 'red', 'black', 'bold');

consoleStyle('GO!', 'green');
consoleStyle('slow...', 'yellow');
consoleStyle('STOP!', 'red');

List of example functions:

Here are a few examples!

consoleStyle('Normal text\n');

consoleStyle("White, bold text\n", "white", "black", "bold");

consoleStyle("Red, italic text\n", "red", "black", "italic");

consoleStyle("Green underlined\n", "green", "black", "underline");

consoleStyle("Purple background and overline\n", "white", "purple", "overline");

consoleStyle("Black on yellow with a strikethrough\n", "black", "yellow", "strikethrough");

consoleStyle("Blinking bright-red text\n", 'brightred', undefined, 'blinking');

consoleStyle("no newline after, ", undefined, undefined, undefined, false);
consoleStyle('and no newline before!\n\n');

consoleStyle('Save this formatting for later\n', 'brightwhite', 'blue', 'bold');
consoleStyle('I keep the last formatting!', undefined, undefined, undefined, undefined, true);

consoleStyle('\nMultiple styles!!\n', undefined, undefined, ['bold', 'italic', 'blinking', 'underline']);

List of all colors:

Colors

font colors:

normal
black
red
green
yellow
blue
magenta
purple
cyan
white
gray
brightblack
brightred
brightgreen
brightyellow
brightblue
brightmagenta
brightcyan
brightwhite

background colors:

normal
black
red
green
yellow
blue
magenta
purple
cyan
white
gray

What they look like in different terminals:

ANSI color appearances

Styles:

Style NamesAdditional NamesDescription
boldMakes the text bold.
faintdimMakes the text dim.
italicitalics, italicizeMakes the text italicized.
underlineunderscoreUnderlines the text.
blinkblinkingMakes the text blink.
flashflashingMakes the text flash.
invertinverted, swap, swappedInverts the text colors.
invisibleconcealHides the text.
strikethroughcrossStrikes through the text.
frameframedFrames the text. (not usually supported)
encircledcircledEncircles the text. (not usually supported)
overlineoverscoreAdds a line above the text.
normaldefaultResets to normal/default style.

An example output:

Terminal output image