rich theme

The rich console is themeable, I've been a long time user of rich and had no Idea. You can define your own theme keywords and use them just like you use...

Copy this post

The rich console is themeable, I’ve been a long time user of rich and had no Idea. You can define your own theme keywords and use them just like you use normal rich keywords in square brackets like'[bold red]'.

from rich.console import Console
from rich.theme import Theme
custom_theme = Theme({
    "info": "dim cyan",
    "warning": "magenta",
    "danger": "bold red"
})
console = Console(theme=custom_theme)
console.print("This is information", style="info")
console.print("[warning]The pod bay doors are locked[/warning]")
console.print("Something terrible happened!", style="danger")

Interactions (1)

🔗 1 Mention