Hierarchy

  • Use a template string.

    Parameters

    • text: TemplateStringsArray
    • Rest ...placeholders: unknown[]

    Returns string

    Remarks

    Template literals are unsupported for nested calls (see issue #341)

    Example

    import chalk = require('chalk');

    log(chalk`
    CPU: {red ${cpu.totalPercent}%}
    RAM: {green ${ram.used / ram.total * 100}%}
    DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
    `);

    Example

    import chalk = require('chalk');

    log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
  • Parameters

    • Rest ...text: unknown[]

    Returns string

References

Re-exports bold

Properties

Instance: Instance

Return a new Chalk instance.

bgBlack: Chalk
bgBlackBright: Chalk
bgBlue: Chalk
bgBlueBright: Chalk
bgCyan: Chalk
bgCyanBright: Chalk
bgGray: Chalk
bgGreen: Chalk
bgGreenBright: Chalk
bgGrey: Chalk
bgMagenta: Chalk
bgMagentaBright: Chalk
bgRed: Chalk
bgRedBright: Chalk
bgWhite: Chalk
bgWhiteBright: Chalk
bgYellow: Chalk
bgYellowBright: Chalk
black: Chalk
blackBright: Chalk
blue: Chalk
blueBright: Chalk
cyan: Chalk
cyanBright: Chalk
dim: Chalk

Modifier: Emitting only a small amount of light.

gray: Chalk
green: Chalk
greenBright: Chalk
grey: Chalk
hidden: Chalk

Modifier: Prints the text, but makes it invisible.

inverse: Chalk

Modifier: Inverse background and foreground colors.

italic: Chalk

Modifier: Make text italic. (Not widely supported)

level: Level

The color support for Chalk.

By default, color support is automatically detected based on the environment.

Levels:

  • 0 - All colors disabled.
  • 1 - Basic 16 colors support.
  • 2 - ANSI 256 colors support.
  • 3 - Truecolor 16 million colors support.
magenta: Chalk
magentaBright: Chalk
red: Chalk
redBright: Chalk
reset: Chalk

Modifier: Resets the current color chain.

strikethrough: Chalk

Modifier: Puts a horizontal line through the center of the text. (Not widely supported)

underline: Chalk

Modifier: Make text underline. (Not widely supported)

visible: Chalk

Modifier: Prints the text only when Chalk has a color support level > 0. Can be useful for things that are purely cosmetic.

white: Chalk
whiteBright: Chalk
yellow: Chalk
yellowBright: Chalk

Methods

  • Use a Select/Set Graphic Rendition (SGR) color code number to set text color.

    30 <= code && code < 38 || 90 <= code && code < 98 For example, 31 for red, 91 for redBright.

    Parameters

    • code: number

    Returns Chalk

  • Use a 8-bit unsigned number to set text color.

    Parameters

    • index: number

    Returns Chalk

  • Use a Select/Set Graphic Rendition (SGR) color code number to set background color.

    30 <= code && code < 38 || 90 <= code && code < 98 For example, 31 for red, 91 for redBright. Use the foreground code, not the background code (for example, not 41, nor 101).

    Parameters

    • code: number

    Returns Chalk

  • Use a 8-bit unsigned number to set background color.

    Parameters

    • index: number

    Returns Chalk

  • Use HEX value to set background color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns Chalk

    Example

    import chalk = require('chalk');

    chalk.bgHex('#DEADED');
  • Use HSL values to set background color.

    Parameters

    • hue: number
    • saturation: number
    • lightness: number

    Returns Chalk

  • Use HSV values to set background color.

    Parameters

    • hue: number
    • saturation: number
    • value: number

    Returns Chalk

  • Use HWB values to set background color.

    Parameters

    • hue: number
    • whiteness: number
    • blackness: number

    Returns Chalk

  • Use keyword color value to set background color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns Chalk

    Example

    import chalk = require('chalk');

    chalk.bgKeyword('orange');
  • Use RGB values to set background color.

    Parameters

    • red: number
    • green: number
    • blue: number

    Returns Chalk

  • Use HEX value to set text color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns Chalk

    Example

    import chalk = require('chalk');

    chalk.hex('#DEADED');
  • Use HSL values to set text color.

    Parameters

    • hue: number
    • saturation: number
    • lightness: number

    Returns Chalk

  • Use HSV values to set text color.

    Parameters

    • hue: number
    • saturation: number
    • value: number

    Returns Chalk

  • Use HWB values to set text color.

    Parameters

    • hue: number
    • whiteness: number
    • blackness: number

    Returns Chalk

  • Use keyword color value to set text color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns Chalk

    Example

    import chalk = require('chalk');

    chalk.keyword('orange');
  • Use RGB values to set text color.

    Parameters

    • red: number
    • green: number
    • blue: number

    Returns Chalk

Generated using TypeDoc