API Reference

Rich

Python library for rich text, tables, progress bars, and syntax highlighting in the terminal.

Official Documentation ↗
CompatibilityThis documentation covers version v15.0.0. Check the official docs for the latest API surface.

Installation

pippip install rich

Methods

Rich is a Python library for rich text and beautiful formatting in the terminal. It lets you render styled text, tables, progress bars, trees, syntax-highlighted code, and tracebacks with minimal effort.

Key Features

  • Styled text: Markup tags for color and style
  • Tables: Styled, aligned tabular output
  • Progress: Animated multi-task progress bars
  • Syntax highlighting: Pygments-powered code rendering
  • Tracebacks: Beautiful error formatting

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T19:28:00+08:00 via WebFetch https://rich.readthedocs.io/en/stable/reference/console.html;WebFetch https://rich.readthedocs.io/en/stable/reference/table.html;WebFetch https://rich.readthedocs.io/en/stable/reference/progress.html.

  • Console → signature from https://rich.readthedocs.io/en/stable/reference/console.html; official text: “class rich.console.Console(*, color_system=‘auto’, force_terminal=None, force_jupyter=None, force_interactive=None, soft_wrap=False, theme=None, stderr=False, file=None, quiet=False, width=None, height=None, style=None, “
  • Table → signature from https://rich.readthedocs.io/en/stable/reference/table.html; official text: “class rich.table.Table(*headers, title=None, caption=None, width=None, min_width=None, box=Box(…), safe_box=None, padding=(0, 1), collapse_padding=False, pad_edge=True, expand=False, show_header=True, show_footer=False”
  • Progress → signature from https://rich.readthedocs.io/en/stable/reference/progress.html; official text: “class rich.progress.Progress(*columns, console=None, auto_refresh=True, refresh_per_second=10, speed_estimate_period=30.0, transient=False, redirect_stdout=True, redirect_stderr=True, get_time=None, disable=False, expand”

FAQ

How do I use Rich with logging?
Use RichHandler from rich.logging to get colorized, timestamped log records with tracebacks. Add it to your logger handlers and Rich formats exceptions with syntax highlighting and locals.
Can Rich output be captured or exported?
Yes. Create a Console with record=True and call console.export_text() or console.export_html() to capture output. This is useful for tests, reports, or embedding Rich output in other formats.
Does Rich work in non-terminal environments?
Rich detects terminal capabilities and degrades gracefully, stripping colors when output is piped. You can force behavior with Console(force_terminal=True) or color_system=None for plain output.