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

Style.ts 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.


Exports Grouped by Category


Constructors

bgColor

Builds a Style that applies color as background color

Signature

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

Source

color

Builds a Style that applies color as foreground color

Signature

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

Source

Destructors

toString

Returns the id of self

Signature

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

Source

Equivalences

equivalence

Equivalence

Signature

declare const equivalence: Equivalence.Equivalence<Type>

Source

Getters

style

Gets the style property of self

Signature

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

Source

Instances

bgBlack

Original black background color style instance

Signature

declare const bgBlack: Type

Source

bgBlue

Original blue background color style instance

Signature

declare const bgBlue: Type

Source

bgBrightBlack

Original bright black background color style instance

Signature

declare const bgBrightBlack: Type

Source

bgBrightBlue

Original bright blue background color style instance

Signature

declare const bgBrightBlue: Type

Source

bgBrightCyan

Original bright cyan background color style instance

Signature

declare const bgBrightCyan: Type

Source

bgBrightGreen

Original bright green background color style instance

Signature

declare const bgBrightGreen: Type

Source

bgBrightMagenta

Original bright magenta background color style instance

Signature

declare const bgBrightMagenta: Type

Source

bgBrightRed

Original bright red background color style instance

Signature

declare const bgBrightRed: Type

Source

bgBrightWhite

Original bright white background color style instance

Signature

declare const bgBrightWhite: Type

Source

bgBrightYellow

Original bright yellow background color style instance

Signature

declare const bgBrightYellow: Type

Source

bgCyan

Original cyan background color style instance

Signature

declare const bgCyan: Type

Source

bgDefaultColor

Default background color Style instance

Signature

declare const bgDefaultColor: Type

Source

bgGreen

Original green background color style instance

Signature

declare const bgGreen: Type

Source

bgMagenta

Original magenta background color style instance

Signature

declare const bgMagenta: Type

Source

bgRed

Original red background color style instance

Signature

declare const bgRed: Type

Source

bgWhite

Original white background color style instance

Signature

declare const bgWhite: Type

Source

bgYellow

Original yellow background color style instance

Signature

declare const bgYellow: Type

Source

black

Original black color style instance

Signature

declare const black: Type

Source

blinking

Blinking Style instance

Signature

declare const blinking: Type

Source

blue

Original blue color style instance

Signature

declare const blue: Type

Source

bold

Bold Style instance

Signature

declare const bold: Type

Source

brightBlack

Original bright black color style instance

Signature

declare const brightBlack: Type

Source

brightBlue

Original bright blue color style instance

Signature

declare const brightBlue: Type

Source

brightCyan

Original bright cyan color style instance

Signature

declare const brightCyan: Type

Source

brightGreen

Original bright green color style instance

Signature

declare const brightGreen: Type

Source

brightMagenta

Original bright magenta color style instance

Signature

declare const brightMagenta: Type

Source

brightRed

Original bright red color style instance

Signature

declare const brightRed: Type

Source

brightWhite

Original bright white color style instance

Signature

declare const brightWhite: Type

Source

brightYellow

Original bright yellow color style instance

Signature

declare const brightYellow: Type

Source

cyan

Original cyan color style instance

Signature

declare const cyan: Type

Source

defaultColor

Default foreground color Style instance

Signature

declare const defaultColor: Type

Source

dim

Dim Style instance

Signature

declare const dim: Type

Source

green

Original green color style instance

Signature

declare const green: Type

Source

hidden

Hidden Style instance

Signature

declare const hidden: Type

Source

inversed

Inversed Style instance

Signature

declare const inversed: Type

Source

italic

Italic Style instance

Signature

declare const italic: Type

Source

magenta

Original magenta color style instance

Signature

declare const magenta: Type

Source

none

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

Signature

declare const none: Type

Source

notBlinking

NotBlinking Style instance

Signature

declare const notBlinking: Type

Source

notBold

NotBold Style instance

Signature

declare const notBold: Type

Source

notDim

NotDim Style instance

Signature

declare const notDim: Type

Source

notHidden

NotHidden Style instance

Signature

declare const notHidden: Type

Source

notInversed

NotInversed Style instance

Signature

declare const notInversed: Type

Source

notItalic

NotItalic Style instance

Signature

declare const notItalic: Type

Source

notOverlined

NotOverlined Style instance

Signature

declare const notOverlined: Type

Source

notStruckThrough

NotStruckThrough Style instance

Signature

declare const notStruckThrough: Type

Source

notUnderlined

NotUnderlined Style instance

Signature

declare const notUnderlined: Type

Source

overlined

Overlined Style instance

Signature

declare const overlined: Type

Source

red

Original red color style instance

Signature

declare const red: Type

Source

struckThrough

Struck-through Style instance

Signature

declare const struckThrough: Type

Source

underlined

Underlined Style instance

Signature

declare const underlined: Type

Source

white

Original white color style instance

Signature

declare const white: Type

Source

yellow

Original yellow color style instance

Signature

declare const yellow: Type

Source

Models

Action (namespace)

Namespace of a Style used as an action

Source

Type (interface)

Type of the action

Signature

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

Source

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
}

Source

Module markers

moduleTag

Module tag

Signature

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

Source

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

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

Source

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

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

Source