Skip to content

Padding

Padding #

Defines padding for all sides of a rectangle.

bottom #

bottom: Number = 0

The padding value for the bottom side of the rectangle.

left #

left: Number = 0

The padding value for the left side of the rectangle.

right #

right: Number = 0

The padding value for the right side of the rectangle.

top #

top: Number = 0

The padding value for the top side of the rectangle.

all #

all(value: Number) -> Padding

Applies the same padding to all sides.

only #

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

Applies padding to the specified sides.

symmetric #

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 #

zero() -> Padding

Examples#

Example 1#

import flet as ft


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

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


ft.run(main)

container