Package Exports
- strcolorize
- strcolorize/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (strcolorize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
๐งถ strcolorize
strcolorize is a simple library for coloring text using codes (ANSI and hexadecimal), perfect for styling your terminal strings. strcolorize uses inline formatting (applies text formatting styles directly within the text line) to colorize your texts.
๐ฆ Install
npm install strcolorize
yarn install strcolorize
๐ฟ Highlights
- No dependencies
- Ability to nest styles
- Doesn't extend
String.prototype
- Clean and focused
- Support for
Hexadecimal
codes (text colors)
๐ How To Usage?
colorize(input: string, terminal: boolean [Opcional]):
input:
The text to be styled.terminal:
Print directly to the terminal [default is false].
const colorize = require('strcolorize'); // module commonjs
import colorize from 'strcolorize'; // module esm
// Coloring with ANSI codes.
colorize('This word is [red](red)', true)
// Coloring with hexadecimal codes.
colorize('This especif word is [blue](#0000FF)', true)
// Nesting colorizations.
colorize('[Welcome to [strcolorize](magenta) library](bold)', true)
Terminal output:
๐จ Colors and Styles
Text styles:
reset:
Reset the current style.bold:
Make the text bold.italic:
Make the text italic.inverse:
Invert background and foreground colors.underline:
Put a horizontal line below the text.hidden:
Print the text but make it invisible.strikethrough:
Puts a horizontal line through the center of the text.
Text colors:
black
red
green
yellow
blue
magenta
cyan
white
gray
Text backgrounds:
bgBlack
bgRed
bgGreen
bgYellow
bgBlue
bgCyan
bgWhite
๐ Contribuition
Your contributions are highly valued! Feel free to enhance this project by opening an issue to report any problems or submitting a pull request with your proposed changes.