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)Color[source]

Downgrade a color system to a system with fewer colors.

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: TerminalTheme = None, foreground=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

Check if the color is a default color.

property is_system_defined

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)Color[source]

Parse a color definition.

property system

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.