colors: {
    BackgroundColor: BackgroundColor;
    Color: Color;
    ForegroundColor: ForegroundColor;
    Instance: colors.Instance;
    Level: colors.Level;
    Modifiers: Modifiers;
    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;
    stderr: colors.Chalk & {
        supportsColor: false | colors.ColorSupport;
    };
    strikethrough: colors.Chalk;
    supportsColor: false | colors.ColorSupport;
    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;
    default(text, ...placeholders): string;
    default(...text): string;
    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;
}

Main Chalk object that allows to chain styles together. Call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that chalk.red.yellow.green is equivalent to chalk.green.

Type declaration

  • BackgroundColor: BackgroundColor
  • Color: Color
  • ForegroundColor: ForegroundColor
  • Instance: colors.Instance

    Return a new Chalk instance.

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

    Modifier: Make text bold.

  • Readonly cyan: colors.Chalk
  • Readonly cyanBright: colors.Chalk
  • Readonly dim: colors.Chalk

    Modifier: Emitting only a small amount of light.

  • Readonly gray: colors.Chalk
  • Readonly green: colors.Chalk
  • Readonly greenBright: colors.Chalk
  • Readonly grey: colors.Chalk
  • Readonly hidden: colors.Chalk

    Modifier: Prints the text, but makes it invisible.

  • Readonly inverse: colors.Chalk

    Modifier: Inverse background and foreground colors.

  • Readonly 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.
  • Readonly magenta: colors.Chalk
  • Readonly magentaBright: colors.Chalk
  • Readonly red: colors.Chalk
  • Readonly redBright: colors.Chalk
  • Readonly reset: colors.Chalk

    Modifier: Resets the current color chain.

  • stderr: colors.Chalk & {
        supportsColor: false | colors.ColorSupport;
    }
  • Readonly strikethrough: colors.Chalk

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

  • supportsColor: false | colors.ColorSupport
  • Readonly underline: colors.Chalk

    Modifier: Make text underline. (Not widely supported)

  • Readonly 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.

  • Readonly white: colors.Chalk
  • Readonly whiteBright: colors.Chalk
  • Readonly yellow: colors.Chalk
  • Readonly yellowBright: colors.Chalk
  • ansi:function
  • ansi256:function
  • bgAnsi:function
    • 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

  • bgAnsi256:function
  • bgHex:function
    • 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');
  • bgHsl:function
    • Use HSL values to set background color.

      Parameters

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

      Returns colors.Chalk

  • bgHsv:function
    • Use HSV values to set background color.

      Parameters

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

      Returns colors.Chalk

  • bgHwb:function
    • Use HWB values to set background color.

      Parameters

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

      Returns colors.Chalk

  • bgKeyword:function
    • 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');
  • bgRgb:function
    • Use RGB values to set background color.

      Parameters

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

      Returns colors.Chalk

  • default:function
    • 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

  • hex:function
    • 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');
  • hsl:function
    • Use HSL values to set text color.

      Parameters

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

      Returns colors.Chalk

  • hsv:function
    • Use HSV values to set text color.

      Parameters

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

      Returns colors.Chalk

  • hwb:function
    • Use HWB values to set text color.

      Parameters

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

      Returns colors.Chalk

  • keyword:function
    • 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');
  • rgb:function
    • Use RGB values to set text color.

      Parameters

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

      Returns colors.Chalk

Generated using TypeDoc