Standard 16-color terminal palette for foreground text coloring. These colors are widely supported across terminal emulators and provide consistent basic color styling.
The eight standard ANSI colors available in most terminals.
/**
* Standard foreground colors (all return ChalkInstance for chaining)
*/
readonly black: ChalkInstance;
readonly red: ChalkInstance;
readonly green: ChalkInstance;
readonly yellow: ChalkInstance;
readonly blue: ChalkInstance;
readonly magenta: ChalkInstance;
readonly cyan: ChalkInstance;
readonly white: ChalkInstance;Usage Examples:
import chalk from 'chalk';
console.log(chalk.black('Black text'));
console.log(chalk.red('Red text'));
console.log(chalk.green('Green text'));
console.log(chalk.yellow('Yellow text'));
console.log(chalk.blue('Blue text'));
console.log(chalk.magenta('Magenta text'));
console.log(chalk.cyan('Cyan text'));
console.log(chalk.white('White text'));Brighter/more vivid versions of the standard colors for enhanced visibility.
/**
* Bright foreground color variants (all return ChalkInstance for chaining)
*/
readonly blackBright: ChalkInstance;
readonly redBright: ChalkInstance;
readonly greenBright: ChalkInstance;
readonly yellowBright: ChalkInstance;
readonly blueBright: ChalkInstance;
readonly magentaBright: ChalkInstance;
readonly cyanBright: ChalkInstance;
readonly whiteBright: ChalkInstance;Usage Examples:
import chalk from 'chalk';
console.log(chalk.blackBright('Bright black text'));
console.log(chalk.redBright('Bright red text'));
console.log(chalk.greenBright('Bright green text'));
console.log(chalk.yellowBright('Bright yellow text'));
console.log(chalk.blueBright('Bright blue text'));
console.log(chalk.magentaBright('Bright magenta text'));
console.log(chalk.cyanBright('Bright cyan text'));
console.log(chalk.whiteBright('Bright white text'));Convenient aliases for blackBright that provide more intuitive naming for gray text.
/**
* Aliases for blackBright providing intuitive gray color naming
*/
readonly gray: ChalkInstance; // Alias for blackBright
readonly grey: ChalkInstance; // Alias for blackBrightUsage Examples:
import chalk from 'chalk';
console.log(chalk.gray('Gray text using American spelling'));
console.log(chalk.grey('Grey text using British spelling'));
// These are equivalent to:
console.log(chalk.blackBright('Same as gray/grey'));Basic colors can be combined with modifiers and background colors:
import chalk from 'chalk';
// Colors with modifiers
console.log(chalk.red.bold('Bold red text'));
console.log(chalk.blue.italic('Italic blue text'));
console.log(chalk.green.underline('Underlined green text'));
// Colors with background colors
console.log(chalk.yellow.bgBlue('Yellow text on blue background'));
console.log(chalk.white.bgRed('White text on red background'));
// Multiple combinations
console.log(chalk.cyan.bold.bgYellow('Cyan bold text on yellow background'));Common patterns for using basic colors in applications:
import chalk from 'chalk';
// Status indicators
const success = chalk.green;
const warning = chalk.yellow;
const error = chalk.red;
const info = chalk.blue;
console.log(success('✓ Operation completed successfully'));
console.log(warning('⚠ Warning: Check your configuration'));
console.log(error('✗ Error: Operation failed'));
console.log(info('ℹ Info: Additional details available'));
// Log levels with modifiers
const logLevels = {
debug: chalk.gray,
info: chalk.blue,
warn: chalk.yellow.bold,
error: chalk.red.bold,
fatal: chalk.red.bold.inverse
};
console.log(logLevels.debug('[DEBUG] Debug message'));
console.log(logLevels.info('[INFO] Information message'));
console.log(logLevels.warn('[WARN] Warning message'));
console.log(logLevels.error('[ERROR] Error message'));
console.log(logLevels.fatal('[FATAL] Fatal error message'));For programmatic color handling and validation:
import { foregroundColorNames } from 'chalk';
console.log('Available foreground colors:', foregroundColorNames);
// Outputs: ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'blackBright', 'redBright', ...]
// Validation example
function isValidColor(colorName) {
return foregroundColorNames.includes(colorName);
}
console.log(isValidColor('red')); // true
console.log(isValidColor('purple')); // false