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