@j_moleiro/multicolor
v1.0.2
Published
Cross-platform text colorization utility supporting chalk, picocolors, yoctocolors, and Node.js styleText
Maintainers
Readme
multicolor
Cross-platform/cross library text colorization for Node.js.
Automatically detects and uses the best available colorization library from:
- chalk
- picocolors
- yoctocolors
- Node.js built-in
util.styleText
Useful when you create a module that outputs color content into terminal, but you must rely on the project's existing colorizing library instead of adding another dependency to the project.
Usage
const multicolor = require('@j_moleiro/multicolor');
console.log(multicolor('Hello, world!', ['red']));
console.log(multicolor('Bold green text', ['green', 'bold']));Parameters
|Parameter|Type|Description|
|---------|----|-----------|
|text|string|The text to be colorized|
|color parameters|Array|An array of colorizing parameters|
Color parameters
The support of these parameters may vary depending on the backend library
Modifiers
bold- Make the text bold.italic- Make the text italic. (Not widely supported)underline- Put a horizontal line below the text. (Not widely supported)strikethrough- Put a horizontal line through the center of the text. (Not widely supported)
Colors
blackredgreenyellowbluemagentacyanwhitegrayredBrightgreenBrightyellowBrightblueBrightmagentaBrightcyanBrightwhiteBright
Background colors
bgBlackbgRedbgGreenbgYellowbgBluebgMagentabgCyanbgWhitebgGraybgRedBrightbgGreenBrightbgYellowBrightbgBlueBrightbgMagentaBrightbgCyanBrightbgWhiteBright
Supports
- chalk Up to version 4.7
- picocolors
- yoctocolors
- Node.js built-in
util.styleText, available since node version v21.7
License
MIT License
Copyright (c) 2026
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
