ansi-styles

  • Version 6.1.0
  • Published
  • 15.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

variable ansiStyles

const ansiStyles: {
readonly modifier: Modifier;
readonly color: ColorBase & ForegroundColor;
readonly bgColor: ColorBase & BackgroundColor;
readonly codes: ReadonlyMap<number, number>;
} & ForegroundColor &
BackgroundColor &
Modifier &
ConvertColor;

    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 {}

                                        property close

                                        readonly close: string;
                                        • The ANSI terminal control sequence for ending this color.

                                        method ansi

                                        ansi: (code: number) => string;

                                          method ansi16m

                                          ansi16m: (red: number, green: number, blue: number) => string;

                                            method ansi256

                                            ansi256: (code: number) => string;

                                              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 {}

                                                  property close

                                                  readonly close: string;
                                                  • The ANSI terminal control sequence for ending this style.

                                                  property open

                                                  readonly open: string;
                                                  • The ANSI terminal control sequence for starting this style.

                                                  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)

                                                                                      Package Files (1)

                                                                                      Dependencies (0)

                                                                                      No dependencies.

                                                                                      Dev Dependencies (4)

                                                                                      Peer Dependencies (0)

                                                                                      No peer dependencies.

                                                                                      Badge

                                                                                      To add a badge like this onejsDocs.io badgeto 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>