rich.align

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

Align a renderable by adding spaces if necessary.

Parameters
  • renderable (RenderableType) – A console renderable.

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

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

  • 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.

Raises

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

classmethod center(renderable: RenderableType, style: Union[str, Style] = None, *, pad: bool = True, width: int = None)Align[source]

Align a renderable to the center.

classmethod left(renderable: RenderableType, style: Union[str, Style] = None, *, pad: bool = True, width: int = None)Align[source]

Align a renderable to the left.

classmethod right(renderable: RenderableType, style: Union[str, Style] = None, *, pad: bool = True, width: int = None)Align[source]

Align a renderable to the right.