Text formatting modifiers that apply visual effects like bold, italic, underline, and other formatting styles using ANSI escape codes.
Core text formatting functions for common styling needs.
/**
* Reset all text formatting to terminal defaults
* @param text - The text to reset
* @returns Text with reset ANSI codes
*/
function reset(text: string): string;
/**
* Apply bold/increased intensity formatting to text
* @param text - The text to make bold
* @returns Bold-styled text with ANSI escape codes
*/
function bold(text: string): string;
/**
* Apply dim/decreased intensity formatting to text
* @param text - The text to dim
* @returns Dim-styled text with ANSI escape codes
*/
function dim(text: string): string;
/**
* Apply italic formatting to text (not supported on all terminals)
* @param text - The text to italicize
* @returns Italic-styled text with ANSI escape codes
*/
function italic(text: string): string;
/**
* Apply underline formatting to text
* @param text - The text to underline
* @returns Underlined text with ANSI escape codes
*/
function underline(text: string): string;Specialized formatting functions for unique visual effects.
/**
* Apply inverse/reverse video formatting (swap foreground and background colors)
* @param text - The text to invert
* @returns Inverse-styled text with ANSI escape codes
*/
function inverse(text: string): string;
/**
* Apply hidden/invisible formatting to text
* @param text - The text to hide
* @returns Hidden text with ANSI escape codes
*/
function hidden(text: string): string;
/**
* Apply strikethrough formatting to text (not supported on all terminals)
* @param text - The text to strike through
* @returns Strikethrough text with ANSI escape codes
*/
function strikethrough(text: string): string;Usage Examples:
const colors = require('ansi-colors');
// Basic modifiers
console.log(colors.bold('Important message'));
console.log(colors.italic('Emphasized text'));
console.log(colors.underline('Underlined text'));
// Combining modifiers with colors
console.log(colors.bold.red('Bold red error'));
console.log(colors.dim.gray('Subtle gray text'));
console.log(colors.underline.blue('Underlined blue link'));
// Multiple modifiers
console.log(colors.bold.italic.underline('Heavily styled text'));
// Advanced effects
console.log(colors.inverse('Inverted colors'));
console.log(colors.strikethrough('Crossed out text'));
// Reset formatting
console.log(colors.reset('Back to normal'));
// Complex combinations
console.log(colors.bold.red.bgYellow('Bold red text on yellow background'));
console.log(colors.dim.italic.gray('Subtle italic gray text'));