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
verticalpadding to top and bottom sides andhorizontalpadding to -
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#
only
classmethod
#
Applies padding to the specified sides.
symmetric
classmethod
#
Applies vertical padding to top and bottom sides and horizontal padding to
left and right sides.
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.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,
),
]
)
)
ft.run(main)
