You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The smallest and fastest command-line coloring package on the internet
Check out Chalk if you want something more mature and comprehensive.
Highlights
Tiny
Fast
Handles nested colors
Tree-shakeable
No dependencies
Actively maintained
Install
ESM:
npm install yoctocolors
Or CommonJS:
npm install yoctocolors-cjs
Usage
importcolorsfrom'yoctocolors';console.log(colors.red('Yo!'));console.log(colors.blue(`Welcome to the ${colors.green('yoctocolors')} package!`));
You can also import colors as named imports:
import{red,blue,green}from'yoctocolors';console.log(red('Yo!'));console.log(blue(`Welcome to the ${green('yoctocolors')} package!`));
This package supports basic color detection. Colors can be forcefully enabled by setting the FORCE_COLOR environment variable to 1 and can be forcefully disabled by setting NO_COLOR or NODE_DISABLE_COLORS to any value. More info.
Styles
Modifiers
reset - Reset the current style.
bold - Make the text bold.
dim - Make the text have lower opacity.
italic - Make the text italic. (Not widely supported)
underline - Put a horizontal line above the text. (Not widely supported)
overline - Put a horizontal line below the text. (Not widely supported)
inverse- Invert background and foreground colors.
hidden - Print the text but make it invisible.
strikethrough - Put a horizontal line through the center of the text. (Not widely supported)