Skip to content

ANSI Reference

Coverage License NPM Version Open Issues Size

📟 Functional CLI ANSI formatting functions.

Usage

📦 Node

Install @lou.codes/ansi as a dependency:

Terminal window
1
pnpm add @lou.codes/ansi
2
# or
3
npm install @lou.codes/ansi
4
# or
5
yarn add @lou.codes/ansi

Import it and use it:

1
import { foregroundRed } from "@lou.codes/ansi";
2
3
foregroundRed`Hello world!`; // "Hello world!" in red text.

🦕 Deno

Import @lou.codes/ansi using the npm: prefix, and use it directly:

1
import { foregroundRed } from "npm:@lou.codes/ansi";
2
3
foregroundRed`Hello world!`; // "Hello world!" in red text.

🌎 Browser

Import @lou.codes/ansi using esm.sh, and use it directly:

1
<script type="module">
2
import { foregroundRed } from "https://esm.sh/@lou.codes/ansi";
3
4
foregroundRed`Hello world!`; // "Hello world!" in red text.
5
</script>

Background

backgroundBlack

backgroundBlack<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Black background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with black background.

Remarks

Given an input string, it will return a new string with the ANSI codes for black background around it.

Example

1
backgroundBlack("Lou"); // "\u001B[40mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBlack`Lou`; // "\u001B[40mLou\u001B[49m"

See

View source


backgroundBlue

backgroundBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Blue background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with blue background.

Remarks

Given an input string, it will return a new string with the ANSI codes for blue background around it.

Example

1
backgroundBlue("Lou"); // "\u001B[44mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBlue`Lou`; // "\u001B[44mLou\u001B[49m"

See

View source


backgroundBrightBlue

backgroundBrightBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright blue background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright blue background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright blue background around it.

Example

1
backgroundBrightBlue("Lou"); // "\u001B[104mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightBlue`Lou`; // "\u001B[104mLou\u001B[49m"

See

View source


backgroundBrightCyan

backgroundBrightCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright cyan background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright cyan background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright cyan background around it.

Example

1
backgroundBrightCyan("Lou"); // "\u001B[106mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightCyan`Lou`; // "\u001B[106mLou\u001B[49m"

See

View source


backgroundBrightGreen

backgroundBrightGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright green background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright green background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright green background around it.

Example

1
backgroundBrightGreen("Lou"); // "\u001B[102mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightGreen`Lou`; // "\u001B[102mLou\u001B[49m"

See

View source


backgroundBrightMagenta

backgroundBrightMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright magenta background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright magenta background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright magenta background around it.

Example

1
backgroundBrightMagenta("Lou"); // "\u001B[105mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightMagenta`Lou`; // "\u001B[105mLou\u001B[49m"

See

View source


backgroundBrightRed

backgroundBrightRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright red background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright red background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright red background around it.

Example

1
backgroundBrightRed("Lou"); // "\u001B[101mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightRed`Lou`; // "\u001B[101mLou\u001B[49m"

See

View source


backgroundBrightWhite

backgroundBrightWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright white background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright white background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright white background around it.

Example

1
backgroundBrightWhite("Lou"); // "\u001B[107mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightWhite`Lou`; // "\u001B[107mLou\u001B[49m"

See

View source


backgroundBrightYellow

backgroundBrightYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright yellow background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright yellow background.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright yellow background around it.

Example

1
backgroundBrightYellow("Lou"); // "\u001B[103mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundBrightYellow`Lou`; // "\u001B[103mLou\u001B[49m"

See

View source


backgroundColor

backgroundColor<Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

Background color code wrapper.

Type parameters

NameType
Openextends number

Parameters

NameType
openOpen

Returns

fn

Curried function with close ANSI code for background in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

Formatted input string.

See

format

Remarks

Takes an open ANSI code and an input string and adds the open and close ANSI codes to that string (for background color).

Example

1
backgroundColor(13)("Lou"); // "\u001B[13mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundColor(13)`Lou`; // "\u001B[13mLou\u001B[49m"

See

View source


backgroundCyan

backgroundCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Cyan background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with cyan background.

Remarks

Given an input string, it will return a new string with the ANSI codes for cyan background around it.

Example

1
backgroundCyan("Lou"); // "\u001B[46mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundCyan`Lou`; // "\u001B[46mLou\u001B[49m"

See

View source


backgroundGray

backgroundGray<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Gray background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with gray background.

Remarks

Given an input string, it will return a new string with the ANSI codes for gray background around it.

Example

1
backgroundGray("Lou"); // "\u001B[100mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundGray`Lou`; // "\u001B[100mLou\u001B[49m"

See

View source


backgroundGreen

backgroundGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Green background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with green background.

Remarks

Given an input string, it will return a new string with the ANSI codes for green background around it.

Example

1
backgroundGreen("Lou"); // "\u001B[42mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundGreen`Lou`; // "\u001B[42mLou\u001B[49m"

See

View source


backgroundMagenta

backgroundMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Magenta background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with magenta background.

Remarks

Given an input string, it will return a new string with the ANSI codes for magenta background around it.

Example

1
backgroundMagenta("Lou"); // "\u001B[45mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundMagenta`Lou`; // "\u001B[45mLou\u001B[49m"

See

View source


backgroundRed

backgroundRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Red background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with red background.

Remarks

Given an input string, it will return a new string with the ANSI codes for red background around it.

Example

1
backgroundRed("Lou"); // "\u001B[41mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundRed`Lou`; // "\u001B[41mLou\u001B[49m"

See

View source


backgroundWhite

backgroundWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

White background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with white background.

Remarks

Given an input string, it will return a new string with the ANSI codes for white background around it.

Example

1
backgroundWhite("Lou"); // "\u001B[47mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundWhite`Lou`; // "\u001B[47mLou\u001B[49m"

See

View source


backgroundYellow

backgroundYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Yellow background code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with yellow background.

Remarks

Given an input string, it will return a new string with the ANSI codes for yellow background around it.

Example

1
backgroundYellow("Lou"); // "\u001B[43mLou\u001B[49m"
2
// It can also be used as a tag function for tagged templates:
3
backgroundYellow`Lou`; // "\u001B[43mLou\u001B[49m"

See

View source

Common

Formatter

Ƭ Formatter: Function<readonly [input: TemplateStringsArray | string, expressions: ReadOnlyArray], string>

Formatter function that takes a string or a tagged template.

Remarks

Type to represent a function that works both directly on a string or as a tagged template function.

Example

1
const formatter: Formatter = (input, ...expressions) =>
2
typeof input === "string" ? input : (
3
input
4
.flatMap((string, index) => [string, expressions[index] ?? ""])
5
.join("")
6
);
7
8
formatter("Lou"); // "Lou"
9
formatter`Lou`; // "Lou"

See

Tagged templates

Param

Array of strings for template strings or a single string, followed by an array of expressions (if any).

View source


resetToInitialState

Const resetToInitialState: "\u001bc"

RIS sequence.

Remarks

Resets the entire screen to initial state.

Example

1
console.log(resetToInitialState); // "\u001B[c"
2
stdout.write(resetToInitialState); // Resets the entire screen to initial state.

See

View source


controlSequenceIntroducer

controlSequenceIntroducer<Code>(code): <Input>(input: Input) => `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}${Code}`

CSI sequence generator.

Type parameters

NameTypeDescription
Codeextends stringCSI code generic.

Parameters

NameTypeDescription
codeCodeCSI code.

Returns

fn

Curried function with code in context.

▸ <Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}${Code}`

Takes an input number and returns the CSI sequence.

Type parameters
NameTypeDescription
Inputextends number | readonly [Maybe<number>, Maybe<number>]CSI input generic.
Parameters
NameTypeDescription
inputInputCSI input.
Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}${Code}`

CSI sequence.

See

Remarks

Takes a code and an input number and returns the CSI sequence.

Example

1
const selectGraphicRendition = controlSequenceIntroducer("m");
2
selectGraphicRendition(13); // "\u001B[13m"
3
selectGraphicRendition(42); // "\u001B[42m"

See

View source


escapeSequence

escapeSequence<Input>(input): `${Input}`

Takes an input string and returns an escaped sequence based on it.

Type parameters

NameTypeDescription
Inputextends stringString to escape generic.

Parameters

NameTypeDescription
inputInputString to escape.

Returns

`${Input}`

String with ESC character prepended.

Remarks

Escape sequences are used to control the cursor, change colors, and more in the terminal. They are preceded by the ESC character (ASCII code 27, or 0x1b). This functions prepends any given string with the ESC character.

Example

1
escapeSequence("Lou"); // "\x1bLou"

See

ANSI escape code

View source


format

format<Close>(close): <Open>(open: Open) => <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

Format wrapper function.

Type parameters

NameTypeDescription
Closeextends numberClose string generic.

Parameters

NameTypeDescription
closeCloseClose string.

Returns

fn

Curried function with close in context.

▸ <Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

format function with close set.

Type parameters
NameTypeDescription
Openextends numberOpen string generic.
Parameters
NameTypeDescription
openOpenOpen string.
Returns

fn

Curried function with close and open in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

Formatted input string.

See

format

See

format

Remarks

Given an open, a close string and an input string, return formatted input (surrounded by open and close).

Example

1
format(13)(42)("Lou"); // "\u001B[42mLou\u001B[13m"
2
// It can also be used as a tag function for tagged templates:
3
format(13)(42)`Lou`; // "\u001B[42mLou\u001B[13m"

See

View source


mix

mix(...formatters): Formatter

Composes formatters.

Parameters

NameTypeDescription
...formattersReadOnlyArray<Formatter>Array of formatters to be composed.

Returns

Formatter

Formatter composed of the given formatters.

Remarks

Given an array of formatters, it will return a new formatter that will apply all of them to the input string.

Example

1
const redTextWhiteBackground = mix(foregroundRed, backgroundWhite);
2
3
redTextWhiteBackground("Lou");
4
// It can also be used as a tag function for tagged templates:
5
redTextWhiteBackground`Lou`;

See

Formatter

View source


normalizeString

normalizeString<Input>(input, ...expressions): Input extends string ? Input : string

Takes a string or a template string and returns a plain string.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameTypeDescription
inputInputString or template string.
...expressionsReadOnlyArrayPossible values passed to the template string.

Returns

Input extends string ? Input : string

Plain string.

Example

1
normalizeString(`Hello ${13}!`); // "Hello 13!"
2
normalizeString`Hello ${13}!`; // "Hello 13!"

See

Tagged templates

View source


optionalFormat

optionalFormat<Close>(close): <Open>(open: Open) => <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

Process dependant format function.

Type parameters

NameType
Closeextends number

Parameters

NameType
closeClose

Returns

fn

Either the formatted string, or just the passed string.

▸ <Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

format function with close set.

Type parameters
NameTypeDescription
Openextends numberOpen string generic.
Parameters
NameTypeDescription
openOpenOpen string.
Returns

fn

Curried function with close and open in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}[${Close extends readonly [Maybe<number>, Maybe<number>] ? `${First<Close> extends number ? First : ""};${Second<Close> extends number ? Second : ""}` : `${Close}`}m`

Formatted input string.

See

format

See

format

Remarks

Impure version of format which changes depending on the current NodeJS globalThis.process environment.

Example

1
// In a environment with color:
2
optionalFormat(42)(13)("Lou"); // "\u001B[42mLou\u001B[13m"
3
// In an environment without color:
4
optionalFormat(42)(13)("Lou"); // "Lou"
5
// It also works with tagged templates:
6
optionalFormat(42)(13)`Lou`; // "\u001B[42mLou\u001B[13m"

See

View source


selectGraphicRendition

selectGraphicRendition<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}m`

Takes an input number and returns the a SGR sequence.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputInput to escape.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}m`

SGR sequence.

Example

1
controlSequenceIntroducer(13); // "\u001B[13m"
2
controlSequenceIntroducer(42); // "\u001B[42m"

See

View source

Cursor

cursorBack

cursorBack<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}D`

Moves the cursor input cells back.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells back.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}D`

CUB sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

1
cursorBack(13); // "\u001B[13C"

See

View source


cursorDown

cursorDown<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}B`

Moves the cursor input cells down.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}B`

CUD sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

1
cursorDown(13); // "\u001B[13B"

See

View source


cursorForward

cursorForward<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}C`

Moves the cursor input cells forward.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells forward.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}C`

CUF sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

1
cursorForward(13); // "\u001B[13C"

See

View source


cursorHorizontalAbsolute

cursorHorizontalAbsolute<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}G`

Moves cursor to the column input.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputColumn number.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}G`

CHA sequence.

Example

1
cursorHorizontalAbsolute(13); // "\u001B[13G"

See

View source


cursorNextLine

cursorNextLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}E`

Moves cursor to beginning of the line input lines down.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}E`

CNL sequence.

Example

1
cursorNextLine(13); // "\u001B[13E"

See

View source


cursorPosition

cursorPosition<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}H`

Moves the cursor to position input.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputPosition (row, column)

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}H`

CUP sequence.

Example

1
cursorPosition([13, 42]); // "\u001B[13;42H"
2
cursorPosition([undefined, 42]); // "\u001B[;42H"
3
cursorPosition([13, undefined]); // "\u001B[13;H"

See

View source


cursorPreviousLine

cursorPreviousLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}F`

Moves cursor to beginning of the line input lines up.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}F`

CPL sequence.

Example

1
cursorPreviousLine(13); // "\u001B[13F"

See

View source


cursorUp

cursorUp<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}A`

Moves the cursor input cells up.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of cells up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}A`

CUU sequence.

Remarks

If the cursor is already at the edge of the screen, this has no effect.

Example

1
cursorUp(13); // "\u001B[13A"

See

View source

Erase

eraseInDisplay

eraseInDisplay<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}J`

Clear screen from cursor to beginning, to end of screen, or entire screen.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInput0 (to end of screen), 1 (to beginning of screen), or 2 (entire screen).

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}J`

ED sequence.

Example

1
eraseInDisplay(0); // "\u001B[0J" Clear from cursor to end of screen.
2
eraseInDisplay(1); // "\u001B[1J" Clear from cursor to beginning of screen.
3
eraseInDisplay(2); // "\u001B[2J" Clear entire screen.

See

View source


eraseInLine

eraseInLine<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}K`

Erases the line from cursor to beginning, to end of line, or entire line.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInput0 (to end of line), 1 (to beginning of line), or 2 (entire line).

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}K`

EL sequence.

Remarks

inputerases…
0…to end of line.
1…to beginning of line.
2…entire line.

Example

1
eraseInLine(0); // "\u001B[0K" Clear from cursor to end of line.
2
eraseInLine(1); // "\u001B[1K" Clear from cursor to beginning of line.
3
eraseInLine(2); // "\u001B[2K" Clear entire line.

See

CSI (Control Sequence Introducer) sequences

View source

Foreground

foregroundBlack

foregroundBlack<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Black foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with black foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for black foreground.

Example

1
foregroundBlack("Lou"); // "\u001B[30mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBlack`Lou`; // "\u001B[30mLou\u001B[39m"

See

View source


foregroundBlue

foregroundBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Blue foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with blue foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for blue foreground.

Example

1
foregroundBlue("Lou"); // "\u001B[34mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBlue`Lou`; // "\u001B[34mLou\u001B[39m"

See

View source


foregroundBrightBlue

foregroundBrightBlue<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright blue foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright blue foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright blue foreground.

Example

1
foregroundBrightBlue("Lou"); // "\u001B[94mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightBlue`Lou`; // "\u001B[94mLou\u001B[39m"

See

View source


foregroundBrightCyan

foregroundBrightCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright Cyan foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright cyan foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright Cyan foreground.

Example

1
foregroundBrightCyan("Lou"); // "\u001B[96mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightCyan`Lou`; // "\u001B[96mLou\u001B[39m"

See

View source


foregroundBrightGreen

foregroundBrightGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright green foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright green foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright green foreground.

Example

1
foregroundBrightGreen("Lou"); // "\u001B[92mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightGreen`Lou`; // "\u001B[92mLou\u001B[39m"

See

View source


foregroundBrightMagenta

foregroundBrightMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright magenta foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright magenta foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright magenta foreground.

Example

1
foregroundBrightMagenta("Lou"); // "\u001B[95mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightMagenta`Lou`; // "\u001B[95mLou\u001B[39m"

See

View source


foregroundBrightRed

foregroundBrightRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright red foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright red foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright red foreground.

Example

1
foregroundBrightRed("Lou"); // "\u001B[91mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightRed`Lou`; // "\u001B[91mLou\u001B[39m"

See

View source


foregroundBrightWhite

foregroundBrightWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright white foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright white foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright white foreground.

Example

1
foregroundBrightWhite("Lou"); // "\u001B[97mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightWhite`Lou`; // "\u001B[97mLou\u001B[39m"

See

View source


foregroundBrightYellow

foregroundBrightYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bright yellow foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bright yellow foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for bright yellow foreground.

Example

1
foregroundBrightYellow("Lou"); // "\u001B[93mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundBrightYellow`Lou`; // "\u001B[93mLou\u001B[39m"

See

View source


foregroundColor

foregroundColor<Open>(open): <Input>(input: Input, …expressions: ReadOnlyArray) => `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

Foreground color code wrapper.

Type parameters

NameType
Openextends number

Parameters

NameType
openOpen

Returns

fn

Curried function with close ANSI code for foreground in context.

▸ <Input>(input, ...expressions): `[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

format function with close and open set.

Type parameters
NameType
Inputextends string | TemplateStringsArray
Parameters
NameTypeDescription
inputInputInput string or TemplateStringArray (when using tagged templates).
...expressionsReadOnlyArrayInput expressions (when using tagged templates)
Returns

`[${Open extends readonly [Maybe<number>, Maybe<number>] ? `${First<Open> extends number ? First : ""};${Second<Open> extends number ? Second : ""}` : `${Open}`}m${Input extends string ? Input : string}`

Formatted input string.

See

format

Remarks

Takes an open ANSI code and an input string and adds the open and close ANSI codes to that string (for foreground color).

Example

1
foregroundColor(13)("Lou"); // "\u001B[13mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundColor(13)`Lou`; // "\u001B[13mLou\u001B[39m"

See

View source


foregroundCyan

foregroundCyan<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Cyan foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with cyan foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for cyan foreground.

Example

1
foregroundCyan("Lou"); // "\u001B[36mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundCyan`Lou`; // "\u001B[36mLou\u001B[39m"

See

View source


foregroundGray

foregroundGray<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Gray foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with gray foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for gray foreground.

Example

1
foregroundGray("Lou"); // "\u001B[90mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundGray`Lou`; // "\u001B[90mLou\u001B[39m"

See

View source


foregroundGreen

foregroundGreen<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Green foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with green foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for green foreground.

Example

1
foregroundGreen("Lou"); // "\u001B[32mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundGreen`Lou`; // "\u001B[32mLou\u001B[39m"

See

View source


foregroundMagenta

foregroundMagenta<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Magenta foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with magenta foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for magenta foreground.

Example

1
foregroundMagenta("Lou"); // "\u001B[35mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundMagenta`Lou`; // "\u001B[35mLou\u001B[39m"

See

View source


foregroundRed

foregroundRed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Red foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with red foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for red foreground.

Example

1
foregroundRed("Lou"); // "\u001B[31mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundRed`Lou`; // "\u001B[31mLou\u001B[39m"

See

View source


foregroundWhite

foregroundWhite<Input>(input, ...expressions): `${Input extends string ? Input : string}`

White foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with white foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for white foreground.

Example

1
foregroundWhite("Lou"); // "\u001B[37mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundWhite`Lou`; // "\u001B[37mLou\u001B[39m"

See

View source


foregroundYellow

foregroundYellow<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Yellow foreground code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with yellow foreground.

Remarks

Given an input string, it will return a new string with the ANSI codes for yellow foreground.

Example

1
foregroundYellow("Lou"); // "\u001B[33mLou\u001B[39m"
2
// It can also be used as a tag function for tagged templates:
3
foregroundYellow`Lou`; // "\u001B[33mLou\u001B[39m"

See

View source

Scroll

scrollDown

scrollDown<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}S`

Scroll whole page down by input lines. New lines are added at the top.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines down.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}S`

SD sequence.

Example

1
scrollDown(13); // "\u001B[13S"

See

View source


scrollUp

scrollUp<Input>(input): `[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}S`

Scroll whole page up by input lines. New lines are added at the bottom.

Type parameters

NameType
Inputextends number | readonly [Maybe<number>, Maybe<number>]

Parameters

NameTypeDescription
inputInputAmount of lines up.

Returns

`[${Input extends readonly [Maybe<number>, Maybe<number>] ? `${First<Input> extends number ? First : ""};${Second<Input> extends number ? Second : ""}` : `${Input & number}`}S`

SU sequence.

Example

1
scrollUp(13); // "\u001B[13S"

See

View source

Text

bold

bold<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Bold code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with bold format.

Remarks

Given an input string, it will return a new string with the ANSI codes for bold around it.

Example

1
bold("Lou"); // "\u001B[1mLou\u001B[22m"
2
// It can also be used as a tag function for tagged templates:
3
bold`Lou`; // "\u001B[1mLou\u001B[22m"

See

View source


dimmed

dimmed<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Dimmed code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with dimmed format.

Remarks

Given an input string, it will return a new string with the ANSI codes for dimmed around it.

Example

1
dimmed("Lou"); // "\u001B[2mLou\u001B[22m"
2
// It can also be used as a tag function for tagged templates:
3
dimmed`Lou`; // "\u001B[2mLou\u001B[22m"

See

View source


inverse

inverse<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Inverse code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with inverse format.

Remarks

Given an input string, it will return a new string with the ANSI codes for inverse around it.

Example

1
inverse("Lou"); // "\u001B[7mLou\u001B[27m"
2
// It can also be used as a tag function for tagged templates:
3
inverse`Lou`; // "\u001B[7mLou\u001B[27m"

See

View source


italic

italic<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Italic code wrapper.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with italic format.

Remarks

Given an input string, it will return a new string with the ANSI codes for italic around it.

Example

1
italic("Lou"); // "\u001B[3mLou\u001B[23m"
2
// It can also be used as a tag function for tagged templates:
3
italic`Lou`; // "\u001B[3mLou\u001B[23m"

See

View source


strikethrough

strikethrough<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Takes an input string and adds the ANSI codes for strikethrough text.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with strikethrough format.

Example

1
strikethrough("Lou"); // "\u001B[9mLou\u001B[29m"
2
// It can also be used as a tag function for tagged templates:
3
strikethrough`Lou`; // "\u001B[9mLou\u001B[29m"

See

optionalFormat

View source


underlined

underlined<Input>(input, ...expressions): `${Input extends string ? Input : string}`

Takes an input string and adds the ANSI codes for underlined text.

Type parameters

NameType
Inputextends string | TemplateStringsArray

Parameters

NameType
inputInput
...expressionsReadOnlyArray

Returns

`${Input extends string ? Input : string}`

input string with underlined format.

Example

1
underlined("Lou"); // "\u001B[4mLou\u001B[24m"
2
// It can also be used as a tag function for tagged templates:
3
underlined`Lou`; // "\u001B[4mLou\u001B[24m"

See

optionalFormat

View source