Skip to content

GradientRule

GradientRule

The 'GradientRule` class is based off of the rich.rule.Rule class and is used to define a rule in gradient color and variable thickness.

Usage

from rich.console import Console
from rich_gradient.rule import GradientRule

console = Console()
console.print(
    GradientRule(
        "Hello, world!",
    )
)

GradientRule

Alignment

The GradientRule class supports the same alignment options as the Rule class.

console.print(
    GradientRule(
        "Hello, world! on the left",
        align="left",
    )
)

GradientRule Alignment

Thickness

The GradientRule class add the ability to determine the thickness of the rule. Valid values are thin, medium, and thick. Defaults to medium.

console.print(
    GradientRule(
        "Hello, world! thick",
        thickness="thick"
    )
)

GradientRule Thickness