rich.align

class rich.align.Align(renderable: RenderableType, align: typing_extensions.Literal[left, center, right] = 'left', style: Union[str, Style] = None, *, vertical: typing_extensions.Literal[top, middle, bottom] = None, pad: bool = True, width: int = None, height: int = None)[source]

Align a renderable by adding spaces if necessary.

Parameters
  • renderable (RenderableType) – A console renderable.

  • align (AlignMethod) – One of “left”, “center”, or “right””

  • style (StyleType, optional) – An optional style to apply to the background.

  • vertical (Optional[VerticalAlginMethod], optional) – Optional vertical align, one of “top”, “middle”, or “bottom”. Defaults to None.

  • pad (bool, optional) – Pad the right with spaces. Defaults to True.

  • width (int, optional) – Restrict contents to given width, or None to use default width. Defaults to None.

  • height (int, optional) – Set height of align renderable, or None to fit to contents. Defaults to None.

Raises

ValueError – if align is not one of the expected values.

classmethod center(renderable: RenderableType, style: Union[str, Style] = None, *, vertical: typing_extensions.Literal[top, middle, bottom] = None, pad: bool = True, width: int = None, height: int = None)Align[source]

Align a renderable to the center.

classmethod left(renderable: RenderableType, style: Union[str, Style] = None, *, vertical: typing_extensions.Literal[top, middle, bottom] = None, pad: bool = True, width: int = None, height: int = None)Align[source]

Align a renderable to the left.

classmethod right(renderable: RenderableType, style: Union[str, Style] = None, *, vertical: typing_extensions.Literal[top, middle, bottom] = None, pad: bool = True, width: int = None, height: int = None)Align[source]

Align a renderable to the right.

class rich.align.VerticalCenter(renderable: RenderableType, style: Union[str, Style] = None)[source]

Vertically aligns a renderable.

Warns
  • This class is deprecated and may be removed in a future version. Use Align class with

  • `vertical=”middle”`.

Parameters

renderable (RenderableType) – A renderable object.