class rich.color.Color(name: str, type: rich.color.ColorType, number: Optional[int] = None, triplet: Optional[rich.color_triplet.ColorTriplet] = None)[source]

Terminal color definition.

classmethod default() rich.color.Color[source]

Get a Color instance representing the default color.


Default color.

Return type


downgrade(system: rich.color.ColorSystem) rich.color.Color[source]

Downgrade a color system to a system with fewer colors.

classmethod from_ansi(number: int) rich.color.Color[source]

Create a Color number from it’s 8-bit ansi number.


number (int) – A number between 0-255 inclusive.


A new Color instance.

Return type


classmethod from_rgb(red: float, green: float, blue: float) rich.color.Color[source]

Create a truecolor from three color components in the range(0->255).

  • red (float) – Red component in range 0-255.

  • green (float) – Green component in range 0-255.

  • blue (float) – Blue component in range 0-255.


A new color object.

Return type


classmethod from_triplet(triplet: rich.color_triplet.ColorTriplet) rich.color.Color[source]

Create a truecolor RGB color from a triplet of values.


triplet (ColorTriplet) – A color triplet containing red, green and blue components.


A new color object.

Return type


get_ansi_codes(foreground: bool = True) Tuple[str, ...][source]

Get the ANSI escape codes for this color.

get_truecolor(theme: Optional[TerminalTheme] = None, foreground: bool = True) rich.color_triplet.ColorTriplet[source]

Get an equivalent color triplet for this color.

  • theme (TerminalTheme, optional) – Optional terminal theme, or None to use default. Defaults to None.

  • foreground (bool, optional) – True for a foreground color, or False for background. Defaults to True.


A color triplet containing RGB components.

Return type


property is_default: bool

Check if the color is a default color.

property is_system_defined: bool

Check if the color is ultimately defined by the system.

property name

The name of the color (typically the input to Color.parse).

property number

The color number, if a standard color, or None.

classmethod parse(color: str) rich.color.Color[source]

Parse a color definition.

property system: rich.color.ColorSystem

Get the native color system for this color.

property triplet

A triplet of color components, if an RGB color.

property type

The type of the color.

exception rich.color.ColorParseError[source]

The color could not be parsed.

class rich.color.ColorSystem(value)[source]

One of the 3 color system supported by terminals.

class rich.color.ColorType(value)[source]

Type of color stored in Color class.

rich.color.blend_rgb(color1: rich.color_triplet.ColorTriplet, color2: rich.color_triplet.ColorTriplet, cross_fade: float = 0.5) rich.color_triplet.ColorTriplet[source]

Blend one RGB color in to another.

rich.color.parse_rgb_hex(hex_color: str) rich.color_triplet.ColorTriplet[source]

Parse six hex characters in to RGB triplet.