class rich.padding.Padding(renderable: RenderableType, pad: PaddingDimensions = (0, 0, 0, 0), *, style: Union[str,] = 'none', expand: bool = True)[source]

Draw space around content.


>>> print(Padding("Hello", (2, 4), style="on blue"))
  • renderable (RenderableType) – String or other renderable.

  • pad (Union[int, Tuple[int]]) – Padding for top, right, bottom, and left borders. May be specified with 1, 2, or 4 integers (CSS style).

  • style (Union[str, Style], optional) – Style for padding characters. Defaults to “none”.

  • expand (bool, optional) – Expand padding to fit available width. Defaults to True.

classmethod indent(renderable: RenderableType, level: int) Padding[source]

Make padding instance to render an indent.

  • renderable (RenderableType) – String or other renderable.

  • level (int) – Number of characters to indent.


A Padding instance.

Return type


static unpack(pad: Union[int, Tuple[int], Tuple[int, int], Tuple[int, int, int, int]]) Tuple[int, int, int, int][source]

Unpack padding specified in CSS style.