Skip to content

Padding

Defines padding for all sides of a rectangle.

Properties

  • bottom(Number) –

    The padding value for the bottom side of the rectangle.

  • left(Number) –

    The padding value for the left side of the rectangle.

  • right(Number) –

    The padding value for the right side of the rectangle.

  • top(Number) –

    The padding value for the top side of the rectangle.

Methods

  • all

    Applies the same padding to all sides.

  • only

    Applies padding to the specified sides.

  • symmetric

    Applies vertical padding to top and bottom sides and horizontal padding to left and right sides.

  • zero

Properties#

bottom class-attribute instance-attribute #

bottom: Number = 0

The padding value for the bottom side of the rectangle.

left class-attribute instance-attribute #

left: Number = 0

The padding value for the left side of the rectangle.

right class-attribute instance-attribute #

right: Number = 0

The padding value for the right side of the rectangle.

top class-attribute instance-attribute #

top: Number = 0

The padding value for the top side of the rectangle.

Methods#

all classmethod #

all(value: Number) -> Padding

Applies the same padding to all sides.

only classmethod #

only(
    *,
    left: Number = 0,
    top: Number = 0,
    right: Number = 0,
    bottom: Number = 0,
) -> Padding

Applies padding to the specified sides.

symmetric classmethod #

symmetric(
    *, vertical: Number = 0, horizontal: Number = 0
) -> Padding

Applies vertical padding to top and bottom sides and horizontal padding to left and right sides.

zero classmethod #

zero() -> Padding

Examples#

Example 1#

import flet as ft


def main(page: ft.Page):
    page.title = "Containers with different padding"

    page.add(
        ft.SafeArea(
            content=ft.Column(
                controls=[
                    ft.Row(
                        controls=[
                            ft.Container(
                                content=ft.Button("container_1"),
                                bgcolor=ft.Colors.AMBER,
                                padding=ft.Padding.all(10),
                                width=150,
                                height=150,
                            ),
                            ft.Container(
                                content=ft.Button("container_2"),
                                bgcolor=ft.Colors.AMBER,
                                padding=ft.Padding.all(20),
                                width=150,
                                height=150,
                            ),
                            ft.Container(
                                content=ft.Button("container_3"),
                                bgcolor=ft.Colors.AMBER,
                                padding=ft.Padding.symmetric(horizontal=10),
                                width=150,
                                height=150,
                            ),
                            ft.Container(
                                content=ft.Button("container_4"),
                                bgcolor=ft.Colors.AMBER,
                                padding=ft.Padding.only(left=10),
                                width=150,
                                height=150,
                            ),
                        ]
                    )
                ],
            ),
        )
    )


if __name__ == "__main__":
    ft.run(main)

container