Skip to content

padding

padding #

Padding — empty space of a given size, along whichever axis its stack runs.

Padding #

Bases: Component

size pixels of empty space: height in a VStack, width in an HStack.

The unit is the pixel, as a stack's gap is.

cg.ui.Padding(32)
Source code in capturegraph-lib/capturegraph/ui/padding.py
class Padding(Component):
    """``size`` pixels of empty space: height in a ``VStack``, width in an ``HStack``.

    The unit is the pixel, as a stack's ``gap`` is.

    ```python
    cg.ui.Padding(32)
    ```
    """

    size: float = 16

    def html(self, render: Render) -> str:
        """An empty block that takes ``size`` pixels along its stack's axis and never grows."""
        return element(
            "div",
            {"class": "cg-padding", "style": f"flex:0 0 {self.size:g}px", "aria-hidden": "true"},
        )

html(render) #

An empty block that takes size pixels along its stack's axis and never grows.

Source code in capturegraph-lib/capturegraph/ui/padding.py
def html(self, render: Render) -> str:
    """An empty block that takes ``size`` pixels along its stack's axis and never grows."""
    return element(
        "div",
        {"class": "cg-padding", "style": f"flex:0 0 {self.size:g}px", "aria-hidden": "true"},
    )