Skip to content

rich_gradient.text.Text

If you pass rich_gradient.text.Text a string, it will print the string to the console in a random gradient. Rich-gradient's Text class inherits from rich.text.Text. In addition to all of it's parent's parameters, rich_gradient.text.Text also accepts:

  • colors: (List[ColorType]) - A list of strings that can be parsed by rich.color.Color.
📝 Note
rich_color_ext extends rich to be able to parse:
  • CSS color names:
    • ◉ rebeccapurple
    • ◉ salmon
    • ◉ aliceblue
  • 3-Digit Hex Color Codes:
    • ◉ #abc
    • ◉ #FDC
    • ◉ #A1f
  • hues: (int) - The number of color stops a gradient should use
  • rainbow: (bool) - Whether to create a gradient that spans the entire spectrum. Defaults to False
  • markup: (bool) - Whether to respect the inputs existing styles. Defaults to True

Gradient Text with Specific Colors

To have more control over the gradient that is printed, you can pass the colors parameter a list of colors. Colors can be parsed from: - CSS colors names, - 3 or 6 digit hex codes, - rich.color.Color instances or names, - any string or style that rich.color.Color can parse.

specific colors


Rainbow Gradient Text Example

If four colors isn't enough, you can use the 'rainbow' parameter to generate a rainbow gradient that spans the entire spectrum of colors randomly.

Rainbow Gradient

*The rainbow gradient is generated randomly each time the code is run.


Still inherits from rich.text.Text

Since rich_gradient.text.Text is a subclass of rich.text.Text, you can still use all the same methods and parameters as you would.

Still Text