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 Panel and Rule, utilities for building palettes, and
a Click/rich-click CLI for trying gradients from the terminal.
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.
- Spectrum – generate and preview deterministic palettes.
- Animation – create animated gradients with
Live.
Prefer API-level details? See the reference section generated with mkdocstrings.