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[VerticalAlignMethod], 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
alignis not one of the expected values.
- classmethod center(renderable, style=None, *, vertical=None, pad=True, width=None, height=None)[source]
Align a renderable to the center.
- classmethod left(renderable, style=None, *, vertical=None, pad=True, width=None, height=None)[source]
Align a renderable to the left.
- 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:
renderable (RenderableType) – A renderable object.
style (StyleType, optional) – An optional style to apply to the background. Defaults to None.