Skip to main content

Padding

Defines padding for all sides of a rectangle.

Properties

  • bottom - The padding value for the bottom side of the rectangle.
  • left - The padding value for the left side of the rectangle.
  • right - The padding value for the right side of the rectangle.
  • top - 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

bottomclass-attributeinstance-attribute

bottom: Number = 0

The padding value for the bottom side of the rectangle.

leftclass-attributeinstance-attribute

left: Number = 0

The padding value for the left side of the rectangle.

rightclass-attributeinstance-attribute

right: Number = 0

The padding value for the right side of the rectangle.

topclass-attributeinstance-attribute

top: Number = 0

The padding value for the top side of the rectangle.

Methods

allclassmethod

all(cls, value: Number)

Applies the same padding to all sides.

onlyclassmethod

only(cls, left: Number = 0, top: Number = 0, right: Number = 0, bottom: Number = 0)

Applies padding to the specified sides.

symmetricclassmethod

symmetric(cls, vertical: Number = 0, horizontal: Number = 0)

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

zeroclassmethod

zero(cls)

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