rich.align

class rich.align.Align(renderable, align='left', style=None, *, vertical=None, pad=True, width=None, height=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.

Return type

None

classmethod center(renderable, style=None, *, vertical=None, pad=True, width=None, height=None)[source]

Align a renderable to the center.

Parameters
Return type

Align

classmethod left(renderable, style=None, *, vertical=None, pad=True, width=None, height=None)[source]

Align a renderable to the left.

Parameters
Return type

Align

classmethod right(renderable, style=None, *, vertical=None, pad=True, width=None, height=None)[source]

Align a renderable to the right.

Parameters
Return type

Align

class rich.align.VerticalCenter(renderable, 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
Return type

None