Skip to content

Columns Reference

See the Columns guide for usage examples.

Bases: Gradient

A Rich columns convenience constructor with gradient rendering.

Parameters:

Name Type Description Default
renderables Iterable[RenderableType]

Renderables to arrange in columns.

required
width int | None

Optional desired column width.

None
padding PaddingDimensions

Padding around column cells.

(0, 1)
columns_expand bool

Whether Rich columns expand to full width.

False
equal bool

Whether columns are equal-sized.

False
column_first bool

Whether to lay out top-to-bottom first.

False
right_to_left bool

Whether columns start from the right.

False
align AlignMethod | None

Column content alignment.

None
title TextType | None

Optional title.

None
colors Sequence[ColorType] | None

Foreground gradient color stops.

None
bg_colors Sequence[ColorType] | None

Background gradient color stops.

None
rainbow bool

Whether to generate a rainbow palette.

False
hues int

Number of auto-generated hues.

5
repeat_scale float | None

Scale factor controlling gradient repeats. Defaults to None, which derives it from the color stops.

None
expand bool

Whether the gradient frame expands.

True
justify AlignMethod

Horizontal alignment.

'left'
vertical_justify VerticalAlignMethod

Vertical alignment.

'middle'
console Console | None

Optional Rich console.

None
highlight_words HighlightWordsType | None

Word highlight configuration.

None
highlight_regex HighlightRegexType | None

Regex highlight configuration.

None
Source code in src/rich_gradient/columns.py
class Columns(Gradient):
    """A Rich columns convenience constructor with gradient rendering.

    Args:
        renderables: Renderables to arrange in columns.
        width: Optional desired column width.
        padding: Padding around column cells.
        columns_expand: Whether Rich columns expand to full width.
        equal: Whether columns are equal-sized.
        column_first: Whether to lay out top-to-bottom first.
        right_to_left: Whether columns start from the right.
        align: Column content alignment.
        title: Optional title.
        colors: Foreground gradient color stops.
        bg_colors: Background gradient color stops.
        rainbow: Whether to generate a rainbow palette.
        hues: Number of auto-generated hues.
        repeat_scale: Scale factor controlling gradient repeats. Defaults to None,
            which derives it from the color stops.
        expand: Whether the gradient frame expands.
        justify: Horizontal alignment.
        vertical_justify: Vertical alignment.
        console: Optional Rich console.
        highlight_words: Word highlight configuration.
        highlight_regex: Regex highlight configuration.
    """

    def __init__(
        self,
        renderables: Iterable[RenderableType],
        *,
        width: int | None = None,
        padding: PaddingDimensions = (0, 1),
        columns_expand: bool = False,
        equal: bool = False,
        column_first: bool = False,
        right_to_left: bool = False,
        align: AlignMethod | None = None,
        title: TextType | None = None,
        colors: Sequence[ColorType] | None = None,
        bg_colors: Sequence[ColorType] | None = None,
        rainbow: bool = False,
        hues: int = 5,
        repeat_scale: float | None = None,
        expand: bool = True,
        justify: AlignMethod = "left",
        vertical_justify: VerticalAlignMethod = "middle",
        console: Console | None = None,
        highlight_words: HighlightWordsType | None = None,
        highlight_regex: HighlightRegexType | None = None,
    ) -> None:
        """Initialize gradient-enabled Rich columns."""
        columns = RichColumns(
            renderables,
            width=width,
            padding=padding,
            expand=columns_expand,
            equal=equal,
            column_first=column_first,
            right_to_left=right_to_left,
            align=align,
            title=title,
        )
        self._columns = columns
        super().__init__(
            columns,
            colors=list(colors) if colors is not None else None,
            bg_colors=list(bg_colors) if bg_colors is not None else None,
            console=console,
            hues=hues,
            rainbow=rainbow,
            expand=expand,
            justify=justify,
            vertical_justify=vertical_justify,
            repeat_scale=repeat_scale,
            highlight_words=highlight_words,
            highlight_regex=highlight_regex,
        )

    @property
    def columns(self) -> RichColumns:
        """Return the underlying Rich columns renderable."""
        return self._columns

columns property

Return the underlying Rich columns renderable.

__init__(renderables, *, width=None, padding=(0, 1), columns_expand=False, equal=False, column_first=False, right_to_left=False, align=None, title=None, colors=None, bg_colors=None, rainbow=False, hues=5, repeat_scale=None, expand=True, justify='left', vertical_justify='middle', console=None, highlight_words=None, highlight_regex=None)

Initialize gradient-enabled Rich columns.

Source code in src/rich_gradient/columns.py
def __init__(
    self,
    renderables: Iterable[RenderableType],
    *,
    width: int | None = None,
    padding: PaddingDimensions = (0, 1),
    columns_expand: bool = False,
    equal: bool = False,
    column_first: bool = False,
    right_to_left: bool = False,
    align: AlignMethod | None = None,
    title: TextType | None = None,
    colors: Sequence[ColorType] | None = None,
    bg_colors: Sequence[ColorType] | None = None,
    rainbow: bool = False,
    hues: int = 5,
    repeat_scale: float | None = None,
    expand: bool = True,
    justify: AlignMethod = "left",
    vertical_justify: VerticalAlignMethod = "middle",
    console: Console | None = None,
    highlight_words: HighlightWordsType | None = None,
    highlight_regex: HighlightRegexType | None = None,
) -> None:
    """Initialize gradient-enabled Rich columns."""
    columns = RichColumns(
        renderables,
        width=width,
        padding=padding,
        expand=columns_expand,
        equal=equal,
        column_first=column_first,
        right_to_left=right_to_left,
        align=align,
        title=title,
    )
    self._columns = columns
    super().__init__(
        columns,
        colors=list(colors) if colors is not None else None,
        bg_colors=list(bg_colors) if bg_colors is not None else None,
        console=console,
        hues=hues,
        rainbow=rainbow,
        expand=expand,
        justify=justify,
        vertical_justify=vertical_justify,
        repeat_scale=repeat_scale,
        highlight_words=highlight_words,
        highlight_regex=highlight_regex,
    )