2 Basic foreground colors.
4 [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
6 declare type ForegroundColor =
27 Basic background colors.
29 [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
31 declare type BackgroundColor =
54 [More colors here.](https://github.com/chalk/chalk/blob/master/readme.md#256-and-truecolor-color-support)
56 declare type Color = ForegroundColor | BackgroundColor;
58 declare type Modifiers =
69 declare namespace chalk {
72 - `0` - All colors disabled.
73 - `1` - Basic 16 colors support.
74 - `2` - ANSI 256 colors support.
75 - `3` - Truecolor 16 million colors support.
77 type Level = 0 | 1 | 2 | 3;
81 Specify the color support for Chalk.
83 By default, color support is automatically detected based on the environment.
86 - `0` - All colors disabled.
87 - `1` - Basic 16 colors support.
88 - `2` - ANSI 256 colors support.
89 - `3` - Truecolor 16 million colors support.
95 Return a new Chalk instance.
97 type Instance = new (options?: Options) => Chalk;
100 Detect whether the terminal supports color.
102 interface ColorSupport {
104 The color level used by Chalk.
109 Return whether Chalk supports basic 16 colors.
114 Return whether Chalk supports ANSI 256 colors.
119 Return whether Chalk supports Truecolor 16 million colors.
124 interface ChalkFunction {
126 Use a template string.
128 @remarks Template literals are unsupported for nested calls (see [issue #341](https://github.com/chalk/chalk/issues/341))
132 import chalk = require('chalk');
135 CPU: {red ${cpu.totalPercent}%}
136 RAM: {green ${ram.used / ram.total * 100}%}
137 DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
143 import chalk = require('chalk');
145 log(chalk.red.bgBlack`2 + 3 = {bold ${2 + 3}}`)
148 (text: TemplateStringsArray, ...placeholders: unknown[]): string;
150 (...text: unknown[]): string;
153 interface Chalk extends ChalkFunction {
155 Return a new Chalk instance.
160 The color support for Chalk.
162 By default, color support is automatically detected based on the environment.
165 - `0` - All colors disabled.
166 - `1` - Basic 16 colors support.
167 - `2` - ANSI 256 colors support.
168 - `3` - Truecolor 16 million colors support.
173 Use HEX value to set text color.
175 @param color - Hexadecimal value representing the desired color.
179 import chalk = require('chalk');
181 chalk.hex('#DEADED');
184 hex(color: string): Chalk;
187 Use keyword color value to set text color.
189 @param color - Keyword value representing the desired color.
193 import chalk = require('chalk');
195 chalk.keyword('orange');
198 keyword(color: string): Chalk;
201 Use RGB values to set text color.
203 rgb(red: number, green: number, blue: number): Chalk;
206 Use HSL values to set text color.
208 hsl(hue: number, saturation: number, lightness: number): Chalk;
211 Use HSV values to set text color.
213 hsv(hue: number, saturation: number, value: number): Chalk;
216 Use HWB values to set text color.
218 hwb(hue: number, whiteness: number, blackness: number): Chalk;
221 Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set text color.
223 30 <= code && code < 38 || 90 <= code && code < 98
224 For example, 31 for red, 91 for redBright.
226 ansi(code: number): Chalk;
229 Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
231 ansi256(index: number): Chalk;
234 Use HEX value to set background color.
236 @param color - Hexadecimal value representing the desired color.
240 import chalk = require('chalk');
242 chalk.bgHex('#DEADED');
245 bgHex(color: string): Chalk;
248 Use keyword color value to set background color.
250 @param color - Keyword value representing the desired color.
254 import chalk = require('chalk');
256 chalk.bgKeyword('orange');
259 bgKeyword(color: string): Chalk;
262 Use RGB values to set background color.
264 bgRgb(red: number, green: number, blue: number): Chalk;
267 Use HSL values to set background color.
269 bgHsl(hue: number, saturation: number, lightness: number): Chalk;
272 Use HSV values to set background color.
274 bgHsv(hue: number, saturation: number, value: number): Chalk;
277 Use HWB values to set background color.
279 bgHwb(hue: number, whiteness: number, blackness: number): Chalk;
282 Use a [Select/Set Graphic Rendition](https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters) (SGR) [color code number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4_bit) to set background color.
284 30 <= code && code < 38 || 90 <= code && code < 98
285 For example, 31 for red, 91 for redBright.
286 Use the foreground code, not the background code (for example, not 41, nor 101).
288 bgAnsi(code: number): Chalk;
291 Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
293 bgAnsi256(index: number): Chalk;
296 Modifier: Resets the current color chain.
298 readonly reset: Chalk;
301 Modifier: Make text bold.
303 readonly bold: Chalk;
306 Modifier: Emitting only a small amount of light.
311 Modifier: Make text italic. (Not widely supported)
313 readonly italic: Chalk;
316 Modifier: Make text underline. (Not widely supported)
318 readonly underline: Chalk;
321 Modifier: Inverse background and foreground colors.
323 readonly inverse: Chalk;
326 Modifier: Prints the text, but makes it invisible.
328 readonly hidden: Chalk;
331 Modifier: Puts a horizontal line through the center of the text. (Not widely supported)
333 readonly strikethrough: Chalk;
336 Modifier: Prints the text only when Chalk has a color support level > 0.
337 Can be useful for things that are purely cosmetic.
339 readonly visible: Chalk;
341 readonly black: Chalk;
343 readonly green: Chalk;
344 readonly yellow: Chalk;
345 readonly blue: Chalk;
346 readonly magenta: Chalk;
347 readonly cyan: Chalk;
348 readonly white: Chalk;
351 Alias for `blackBright`.
353 readonly gray: Chalk;
356 Alias for `blackBright`.
358 readonly grey: Chalk;
360 readonly blackBright: Chalk;
361 readonly redBright: Chalk;
362 readonly greenBright: Chalk;
363 readonly yellowBright: Chalk;
364 readonly blueBright: Chalk;
365 readonly magentaBright: Chalk;
366 readonly cyanBright: Chalk;
367 readonly whiteBright: Chalk;
369 readonly bgBlack: Chalk;
370 readonly bgRed: Chalk;
371 readonly bgGreen: Chalk;
372 readonly bgYellow: Chalk;
373 readonly bgBlue: Chalk;
374 readonly bgMagenta: Chalk;
375 readonly bgCyan: Chalk;
376 readonly bgWhite: Chalk;
379 Alias for `bgBlackBright`.
381 readonly bgGray: Chalk;
384 Alias for `bgBlackBright`.
386 readonly bgGrey: Chalk;
388 readonly bgBlackBright: Chalk;
389 readonly bgRedBright: Chalk;
390 readonly bgGreenBright: Chalk;
391 readonly bgYellowBright: Chalk;
392 readonly bgBlueBright: Chalk;
393 readonly bgMagentaBright: Chalk;
394 readonly bgCyanBright: Chalk;
395 readonly bgWhiteBright: Chalk;
400 Main Chalk object that allows to chain styles together.
401 Call the last one as a method with a string argument.
402 Order doesn't matter, and later styles take precedent in case of a conflict.
403 This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
405 declare const chalk: chalk.Chalk & chalk.ChalkFunction & {
406 supportsColor: chalk.ColorSupport | false;
409 ForegroundColor: ForegroundColor;
410 BackgroundColor: BackgroundColor;
411 Modifiers: Modifiers;
412 stderr: chalk.Chalk & {supportsColor: chalk.ColorSupport | false};