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

References

Re-exports bold

Properties

Instance: Core.colors.Instance

Return a new Chalk instance.

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

Modifier: Emitting only a small amount of light.

greenBright: Core.colors.Chalk
hidden: Core.colors.Chalk

Modifier: Prints the text, but makes it invisible.

inverse: Core.colors.Chalk

Modifier: Inverse background and foreground colors.

italic: Core.colors.Chalk

Modifier: Make text italic. (Not widely supported)

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

Modifier: Resets the current color chain.

strikethrough: Core.colors.Chalk

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

underline: Core.colors.Chalk

Modifier: Make text underline. (Not widely supported)

visible: Core.colors.Chalk

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

whiteBright: Core.colors.Chalk
yellow: Core.colors.Chalk
yellowBright: Core.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 Core.colors.Chalk

  • Use HEX value to set background color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns Core.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 Core.colors.Chalk

  • Use HSV values to set background color.

    Parameters

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

    Returns Core.colors.Chalk

  • Use HWB values to set background color.

    Parameters

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

    Returns Core.colors.Chalk

  • Use keyword color value to set background color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns Core.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 Core.colors.Chalk

  • Use HEX value to set text color.

    Parameters

    • color: string

      Hexadecimal value representing the desired color.

    Returns Core.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 Core.colors.Chalk

  • Use HSV values to set text color.

    Parameters

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

    Returns Core.colors.Chalk

  • Use HWB values to set text color.

    Parameters

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

    Returns Core.colors.Chalk

  • Use keyword color value to set text color.

    Parameters

    • color: string

      Keyword value representing the desired color.

    Returns Core.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 Core.colors.Chalk

Generated using TypeDoc