interface Chalk {
    Instance: colors.Instance;
    bgBlack: colors.Chalk;
    bgBlackBright: colors.Chalk;
    bgBlue: colors.Chalk;
    bgBlueBright: colors.Chalk;
    bgCyan: colors.Chalk;
    bgCyanBright: colors.Chalk;
    bgGray: colors.Chalk;
    bgGreen: colors.Chalk;
    bgGreenBright: colors.Chalk;
    bgGrey: colors.Chalk;
    bgMagenta: colors.Chalk;
    bgMagentaBright: colors.Chalk;
    bgRed: colors.Chalk;
    bgRedBright: colors.Chalk;
    bgWhite: colors.Chalk;
    bgWhiteBright: colors.Chalk;
    bgYellow: colors.Chalk;
    bgYellowBright: colors.Chalk;
    black: colors.Chalk;
    blackBright: colors.Chalk;
    blue: colors.Chalk;
    blueBright: colors.Chalk;
    bold: colors.Chalk;
    cyan: colors.Chalk;
    cyanBright: colors.Chalk;
    dim: colors.Chalk;
    gray: colors.Chalk;
    green: colors.Chalk;
    greenBright: colors.Chalk;
    grey: colors.Chalk;
    hidden: colors.Chalk;
    inverse: colors.Chalk;
    italic: colors.Chalk;
    level: colors.Level;
    magenta: colors.Chalk;
    magentaBright: colors.Chalk;
    red: colors.Chalk;
    redBright: colors.Chalk;
    reset: colors.Chalk;
    strikethrough: colors.Chalk;
    underline: colors.Chalk;
    visible: colors.Chalk;
    white: colors.Chalk;
    whiteBright: colors.Chalk;
    yellow: colors.Chalk;
    yellowBright: colors.Chalk;
    ansi(code): colors.Chalk;
    ansi256(index): colors.Chalk;
    bgAnsi(code): colors.Chalk;
    bgAnsi256(index): colors.Chalk;
    bgHex(color): colors.Chalk;
    bgHsl(hue, saturation, lightness): colors.Chalk;
    bgHsv(hue, saturation, value): colors.Chalk;
    bgHwb(hue, whiteness, blackness): colors.Chalk;
    bgKeyword(color): colors.Chalk;
    bgRgb(red, green, blue): colors.Chalk;
    hex(color): colors.Chalk;
    hsl(hue, saturation, lightness): colors.Chalk;
    hsv(hue, saturation, value): colors.Chalk;
    hwb(hue, whiteness, blackness): colors.Chalk;
    keyword(color): colors.Chalk;
    rgb(red, green, blue): colors.Chalk;
    (text, ...placeholders): string;
    (...text): string;
}

Hierarchy (view full)

  • 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

Properties

Instance: colors.Instance

Return a new Chalk instance.

bgBlack: colors.Chalk
bgBlackBright: colors.Chalk
bgBlue: colors.Chalk
bgBlueBright: colors.Chalk
bgCyan: colors.Chalk
bgCyanBright: colors.Chalk
bgGray: colors.Chalk
bgGreen: colors.Chalk
bgGreenBright: colors.Chalk
bgGrey: colors.Chalk
bgMagenta: colors.Chalk
bgMagentaBright: colors.Chalk
bgRed: colors.Chalk
bgRedBright: colors.Chalk
bgWhite: colors.Chalk
bgWhiteBright: colors.Chalk
bgYellow: colors.Chalk
bgYellowBright: colors.Chalk
black: colors.Chalk
blackBright: colors.Chalk
blueBright: colors.Chalk

Modifier: Make text bold.

cyanBright: colors.Chalk

Modifier: Emitting only a small amount of light.

green: colors.Chalk
greenBright: colors.Chalk
hidden: colors.Chalk

Modifier: Prints the text, but makes it invisible.

inverse: colors.Chalk

Modifier: Inverse background and foreground colors.

italic: colors.Chalk

Modifier: Make text italic. (Not widely supported)

level: colors.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: colors.Chalk
magentaBright: colors.Chalk
redBright: colors.Chalk
reset: colors.Chalk

Modifier: Resets the current color chain.

strikethrough: colors.Chalk

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

underline: colors.Chalk

Modifier: Make text underline. (Not widely supported)

visible: colors.Chalk

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

white: colors.Chalk
whiteBright: colors.Chalk
yellow: colors.Chalk
yellowBright: colors.Chalk

Methods

  • 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 colors.Chalk

  • Use HEX value to set background color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns colors.Chalk

    Example

    import chalk = require('chalk');

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

    Parameters

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

    Returns colors.Chalk

  • Use HSV values to set background color.

    Parameters

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

    Returns colors.Chalk

  • Use HWB values to set background color.

    Parameters

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

    Returns colors.Chalk

  • Use keyword color value to set background color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns colors.Chalk

    Example

    import chalk = require('chalk');

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

    Parameters

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

    Returns colors.Chalk

  • Use HEX value to set text color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns colors.Chalk

    Example

    import chalk = require('chalk');

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

    Parameters

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

    Returns colors.Chalk

  • Use HSV values to set text color.

    Parameters

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

    Returns colors.Chalk

  • Use HWB values to set text color.

    Parameters

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

    Returns colors.Chalk

  • Use keyword color value to set text color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns colors.Chalk

    Example

    import chalk = require('chalk');

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

    Parameters

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

    Returns colors.Chalk

Generated using TypeDoc