Alignment
Defines an alignment relative to the center.

Properties
BOTTOM_CENTER- Represents the bottom center and is equivalent toAlignment(0.0, 1.0).BOTTOM_LEFT- Represents the bottom left corner and is equivalent toAlignment(-1.0, 1.0).BOTTOM_RIGHT- Represents the bottom right corner and is equivalent toAlignment(1.0, 1.0).CENTER- Represents the center and is equivalent toAlignment(0.0, 0.0).CENTER_LEFT- Represents the center left and is equivalent toAlignment(-1.0, 0.0).CENTER_RIGHT- Represents the center right and is equivalent toAlignment(1.0, 0.0).TOP_CENTER- Represents the top center and is equivalent toAlignment(0.0, -1.0).TOP_LEFT- Represents the top left corner and is equivalent toAlignment(-1.0, -1.0).TOP_RIGHT- Represents the top right corner and is equivalent toAlignment(1.0, -1.0).x- Represents the horizontal distance from the center.y- Represents the vertical distance from the center.
Methods
copy- Returns a copy of this object with the specified properties overridden.
Properties
BOTTOM_CENTERclass-attribute
BOTTOM_CENTER: AlignmentPropertyRepresents the bottom center and is equivalent to Alignment(0.0, 1.0).
BOTTOM_LEFTclass-attribute
BOTTOM_LEFT: AlignmentPropertyRepresents the bottom left corner and is equivalent to Alignment(-1.0, 1.0).
BOTTOM_RIGHTclass-attribute
BOTTOM_RIGHT: AlignmentPropertyRepresents the bottom right corner and is equivalent to Alignment(1.0, 1.0).
CENTERclass-attribute
CENTER: AlignmentPropertyRepresents the center and is equivalent to Alignment(0.0, 0.0).
CENTER_LEFTclass-attribute
CENTER_LEFT: AlignmentPropertyRepresents the center left and is equivalent to Alignment(-1.0, 0.0).
CENTER_RIGHTclass-attribute
CENTER_RIGHT: AlignmentPropertyRepresents the center right and is equivalent to Alignment(1.0, 0.0).
TOP_CENTERclass-attribute
TOP_CENTER: AlignmentPropertyRepresents the top center and is equivalent to Alignment(0.0, -1.0).
TOP_LEFTclass-attribute
TOP_LEFT: AlignmentPropertyRepresents the top left corner and is equivalent to Alignment(-1.0, -1.0).
TOP_RIGHTclass-attribute
TOP_RIGHT: AlignmentPropertyRepresents the top right corner and is equivalent to Alignment(1.0, -1.0).
Methods
Examples
Example 1
import flet as ft
def main(page: ft.Page):
page.title = "Containers with different alignments"
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Row(
controls=[
ft.Container(
bgcolor=ft.Colors.AMBER,
padding=15,
alignment=ft.Alignment.CENTER,
width=150,
height=150,
content=ft.Button("Center"),
),
ft.Container(
bgcolor=ft.Colors.AMBER,
padding=15,
alignment=ft.Alignment.TOP_LEFT,
width=150,
height=150,
content=ft.Button("Top left"),
),
ft.Container(
bgcolor=ft.Colors.AMBER,
padding=15,
alignment=ft.Alignment(-0.5, -0.5),
width=150,
height=150,
content=ft.Button("-0.5, -0.5"),
),
],
wrap=True,
)
]
)
)
)
if __name__ == "__main__":
ft.run(main)
