Getting Started
Purpose¶
rich-gradient layers smooth foreground and background gradients on top of rich renderables.
It includes a drop-in Text subclass, wrappers for common Rich renderables,
utilities for building palettes, and animated variants for live terminal output.
Highlights¶
- Works anywhere Rich expects a
ConsoleRenderable, including panels, tables, and live updates. - Generates color stops automatically or from CSS color names, hex codes, RGB tuples, or
rich.color.Colorobjects. - Supports foreground and background gradients, rainbow palettes, and deterministic color spectrums.
- Ships with ready-to-use renderables:
Installation¶
uv (recommended)
or via uv pip
...or with pip:
pip
Quick start¶
from rich.console import Console
from rich_gradient import Text
console = Console()
console.print(
Text(
"Rich gradients with almost no setup.",
colors=["#38bdf8", "#a855f7", "#f97316"],
style="bold",
justify="center",
)
)
The example above is bundled in examples/text_quickstart.py and renders:
Explore the user guide¶
- Text – gradient-aware drop-in replacement for
rich.text.Text. - Gradient – wrap any renderable with foreground/background gradients.
- Panel – gradient panels with highlighted titles and subtitles.
- Rule – gradient horizontal rules with adjustable thickness.
- Convenience Renderables – gradient
Table,Tree,Columns,Pretty, andSyntax. - Spectrum – generate and preview deterministic palettes.
- Animation – create animated gradients with
Live.
Command line usage¶
This package is the renderable library. The command-line interface now lives in
rich-gradient-cli, which
depends on this package and exposes terminal commands for quick experiments and
asset generation.
Prefer API-level details? See the reference section generated with mkdocstrings.