Skip to main content Link Search Menu Expand Document (external link)

Style overview

This module defines Style, a callable type that applies ANSI formatting to text. Styles can be composed and nested. For instance, ASStyle.red('foo') creates a text containing the string ‘foo’ styled in red.


Table of contents


Constructors

bgColor

Builds a Style that applies color as background color

Signature

export declare const bgColor: (color: ASColor.Type) => Type

color

Builds a Style that applies color as foreground color

Signature

export declare const color: (color: ASColor.Type) => Type

Destructors

toString

Returns the id of self

Signature

export declare const toString: (self: Type) => string

Equivalences

equivalence

Equivalence

Signature

export declare const equivalence: Equivalence.Equivalence<Type>

Getters

style

Gets the style property of self

Signature

export declare const style: MTypes.OneArgFunction<Type, ASStyleCharacteristics.Type>

Instances

bgBlack

Original black background color style instance

Signature

export declare const bgBlack: Type

bgBlue

Original blue background color style instance

Signature

export declare const bgBlue: Type

bgBrightBlack

Original bright black background color style instance

Signature

export declare const bgBrightBlack: Type

bgBrightBlue

Original bright blue background color style instance

Signature

export declare const bgBrightBlue: Type

bgBrightCyan

Original bright cyan background color style instance

Signature

export declare const bgBrightCyan: Type

bgBrightGreen

Original bright green background color style instance

Signature

export declare const bgBrightGreen: Type

bgBrightMagenta

Original bright magenta background color style instance

Signature

export declare const bgBrightMagenta: Type

bgBrightRed

Original bright red background color style instance

Signature

export declare const bgBrightRed: Type

bgBrightWhite

Original bright white background color style instance

Signature

export declare const bgBrightWhite: Type

bgBrightYellow

Original bright yellow background color style instance

Signature

export declare const bgBrightYellow: Type

bgCyan

Original cyan background color style instance

Signature

export declare const bgCyan: Type

bgDefaultColor

Default background color Style instance

Signature

export declare const bgDefaultColor: Type

bgGreen

Original green background color style instance

Signature

export declare const bgGreen: Type

bgMagenta

Original magenta background color style instance

Signature

export declare const bgMagenta: Type

bgRed

Original red background color style instance

Signature

export declare const bgRed: Type

bgWhite

Original white background color style instance

Signature

export declare const bgWhite: Type

bgYellow

Original yellow background color style instance

Signature

export declare const bgYellow: Type

black

Original black color style instance

Signature

export declare const black: Type

blinking

Blinking Style instance

Signature

export declare const blinking: Type

blue

Original blue color style instance

Signature

export declare const blue: Type

bold

Bold Style instance

Signature

export declare const bold: Type

brightBlack

Original bright black color style instance

Signature

export declare const brightBlack: Type

brightBlue

Original bright blue color style instance

Signature

export declare const brightBlue: Type

brightCyan

Original bright cyan color style instance

Signature

export declare const brightCyan: Type

brightGreen

Original bright green color style instance

Signature

export declare const brightGreen: Type

brightMagenta

Original bright magenta color style instance

Signature

export declare const brightMagenta: Type

brightRed

Original bright red color style instance

Signature

export declare const brightRed: Type

brightWhite

Original bright white color style instance

Signature

export declare const brightWhite: Type

brightYellow

Original bright yellow color style instance

Signature

export declare const brightYellow: Type

cyan

Original cyan color style instance

Signature

export declare const cyan: Type

defaultColor

Default foreground color Style instance

Signature

export declare const defaultColor: Type

dim

Dim Style instance

Signature

export declare const dim: Type

green

Original green color style instance

Signature

export declare const green: Type

hidden

Hidden Style instance

Signature

export declare const hidden: Type

inversed

Inversed Style instance

Signature

export declare const inversed: Type

italic

Italic Style instance

Signature

export declare const italic: Type

magenta

Original magenta color style instance

Signature

export declare const magenta: Type

none

None Style instance, i.e. Style that performs no styling

Signature

export declare const none: Type

notBlinking

NotBlinking Style instance

Signature

export declare const notBlinking: Type

notBold

NotBold Style instance

Signature

export declare const notBold: Type

notDim

NotDim Style instance

Signature

export declare const notDim: Type

notHidden

NotHidden Style instance

Signature

export declare const notHidden: Type

notInversed

NotInversed Style instance

Signature

export declare const notInversed: Type

notItalic

NotItalic Style instance

Signature

export declare const notItalic: Type

notOverlined

NotOverlined Style instance

Signature

export declare const notOverlined: Type

notStruckThrough

NotStruckThrough Style instance

Signature

export declare const notStruckThrough: Type

notUnderlined

NotUnderlined Style instance

Signature

export declare const notUnderlined: Type

overlined

Overlined Style instance

Signature

export declare const overlined: Type

red

Original red color style instance

Signature

export declare const red: Type

struckThrough

Struck-through Style instance

Signature

export declare const struckThrough: Type

underlined

Underlined Style instance

Signature

export declare const underlined: Type

white

Original white color style instance

Signature

export declare const white: Type

yellow

Original yellow color style instance

Signature

export declare const yellow: Type

Models

Action (namespace)

Namespace of a Style used as an action

Type (interface)

Type of the action

Signature

export interface Type {
  (...args: ReadonlyArray<string | ASText.Type>): ASText.Type
}

Type (interface)

Type that represents a Style

Signature

export interface Type extends Action.Type {
  /** StyleCharacteristics that define this Style */
  readonly style: ASStyleCharacteristics.Type
  /** .toString() method */
  readonly toString: () => string

  /** @internal */
  readonly [TypeId]: TypeId
}

Module markers

moduleTag

Module tag

Signature

export declare const moduleTag: "@parischap/ansi-styles/Style/"

Utils

mergeOver

Builds a new Style by merging self and that. In case of conflict (e.g self contains Bold and that contains NotBold), the style in that will prevail.

Signature

export declare const mergeOver: (that: Type) => (self: Type) => Type

mergeUnder

Builds a new Style by merging self and that. In case of conflict (e.g self contains Bold and that contains NotBold), the style in self will prevail.

Signature

export declare const mergeUnder: (that: Type) => (self: Type) => Type