ansi-styles
- Version 6.2.1
- Published
- 17.5 kB
- No dependencies
- MIT license
Install
npm i ansi-styles
yarn add ansi-styles
pnpm add ansi-styles
Overview
ANSI escape codes for styling strings in the terminal
Index
Variables
Interfaces
Type Aliases
Variables
variable ansiStyles
const ansiStyles: { readonly modifier: Modifier; readonly color: ColorBase & ForegroundColor; readonly bgColor: ColorBase & BackgroundColor; readonly codes: ReadonlyMap<number, number>;} & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
variable backgroundColorNames
const backgroundColorNames: readonly (keyof BackgroundColor)[];
Basic background color names.
variable colorNames
const colorNames: readonly ColorName[];
variable foregroundColorNames
const foregroundColorNames: readonly (keyof ForegroundColor)[];
Basic foreground color names.
variable modifierNames
const modifierNames: readonly (keyof Modifier)[];
Basic modifier names.
Interfaces
interface BackgroundColor
interface BackgroundColor {}
property bgBlack
readonly bgBlack: CSPair;
property bgBlackBright
readonly bgBlackBright: CSPair;
property bgBlue
readonly bgBlue: CSPair;
property bgBlueBright
readonly bgBlueBright: CSPair;
property bgCyan
readonly bgCyan: CSPair;
property bgCyanBright
readonly bgCyanBright: CSPair;
property bgGray
readonly bgGray: CSPair;
Alias for
bgBlackBright
.
property bgGreen
readonly bgGreen: CSPair;
property bgGreenBright
readonly bgGreenBright: CSPair;
property bgGrey
readonly bgGrey: CSPair;
Alias for
bgBlackBright
.
property bgMagenta
readonly bgMagenta: CSPair;
property bgMagentaBright
readonly bgMagentaBright: CSPair;
property bgRed
readonly bgRed: CSPair;
property bgRedBright
readonly bgRedBright: CSPair;
property bgWhite
readonly bgWhite: CSPair;
property bgWhiteBright
readonly bgWhiteBright: CSPair;
property bgYellow
readonly bgYellow: CSPair;
property bgYellowBright
readonly bgYellowBright: CSPair;
interface ColorBase
interface ColorBase {}
interface ConvertColor
interface ConvertColor {}
method ansi256ToAnsi
ansi256ToAnsi: (code: number) => number;
Convert from the ANSI 256 color space to the ANSI 16 color space.
Parameter code
A number representing the ANSI 256 color.
method hexToAnsi
hexToAnsi: (hex: string) => number;
Convert from the RGB HEX color space to the ANSI 16 color space.
Parameter hex
A hexadecimal string containing RGB data.
method hexToAnsi256
hexToAnsi256: (hex: string) => number;
Convert from the RGB HEX color space to the ANSI 256 color space.
Parameter hex
A hexadecimal string containing RGB data.
method hexToRgb
hexToRgb: (hex: string) => [red: number, green: number, blue: number];
Convert from the RGB HEX color space to the RGB color space.
Parameter hex
A hexadecimal string containing RGB data.
method rgbToAnsi
rgbToAnsi: (red: number, green: number, blue: number) => number;
Convert from the RGB color space to the ANSI 16 color space.
Parameter red
(
0...255
)Parameter green
(
0...255
)Parameter blue
(
0...255
)
method rgbToAnsi256
rgbToAnsi256: (red: number, green: number, blue: number) => number;
Convert from the RGB color space to the ANSI 256 color space.
Parameter red
(
0...255
)Parameter green
(
0...255
)Parameter blue
(
0...255
)
interface CSPair
interface CSPair {}
interface ForegroundColor
interface ForegroundColor {}
property black
readonly black: CSPair;
property blackBright
readonly blackBright: CSPair;
property blue
readonly blue: CSPair;
property blueBright
readonly blueBright: CSPair;
property cyan
readonly cyan: CSPair;
property cyanBright
readonly cyanBright: CSPair;
property gray
readonly gray: CSPair;
Alias for
blackBright
.
property green
readonly green: CSPair;
property greenBright
readonly greenBright: CSPair;
property grey
readonly grey: CSPair;
Alias for
blackBright
.
property magenta
readonly magenta: CSPair;
property magentaBright
readonly magentaBright: CSPair;
property red
readonly red: CSPair;
property redBright
readonly redBright: CSPair;
property white
readonly white: CSPair;
property whiteBright
readonly whiteBright: CSPair;
property yellow
readonly yellow: CSPair;
property yellowBright
readonly yellowBright: CSPair;
interface Modifier
interface Modifier {}
property bold
readonly bold: CSPair;
Make text bold.
property dim
readonly dim: CSPair;
Emitting only a small amount of light.
property hidden
readonly hidden: CSPair;
Prints the text, but makes it invisible.
property inverse
readonly inverse: CSPair;
Inverse background and foreground colors.
property italic
readonly italic: CSPair;
Make text italic. (Not widely supported)
property overline
readonly overline: CSPair;
Make text overline.
Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
property reset
readonly reset: CSPair;
Resets the current color chain.
property strikethrough
readonly strikethrough: CSPair;
Puts a horizontal line through the center of the text. (Not widely supported)
property underline
readonly underline: CSPair;
Make text underline. (Not widely supported)
Type Aliases
type BackgroundColorName
type BackgroundColorName = keyof BackgroundColor;
Basic background color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
type ColorName
type ColorName = ForegroundColorName | BackgroundColorName;
Basic color names. The combination of foreground and background color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
type ForegroundColorName
type ForegroundColorName = keyof ForegroundColor;
Basic foreground color names.
[More colors here.](https://github.com/chalk/chalk/blob/main/readme.md#256-and-truecolor-color-support)
type ModifierName
type ModifierName = keyof Modifier;
Basic modifier names.
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (4)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ansi-styles
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ansi-styles)
- HTML<a href="https://www.jsdocs.io/package/ansi-styles"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4456 ms. - Missing or incorrect documentation? Open an issue for this package.