Skip to content

Alignment ​

The Alignment element controls the positioning of its child content within the available space. It offers both horizontal and vertical options that can be used independently or combined.

API ​

Horizontal ​

MethodDescription
AlignLeftAligns content horizontally to the left side.
AlignCenterAligns content horizontally to the center, ensuring equal space on both left and right sides.
AlignRightAligns its content horizontally to the right side.

Vertical ​

MethodDescription
AlignTopAligns content vertically to the upper side.
AlignMiddleAligns content vertically to the center, ensuring equal space above and below.
AlignBottomAligns content vertically to the bottom side.

Example ​

csharp
container
    .Width(300)
    .Height(300)
    .AlignBottom()
    .AlignCenter()
    .Background(Colors.Grey.Lighten2)
    .Padding(10)
    .Text("Test");

example