Skip to content

AlignWidget ​

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that aligns its child within the available space.

csharp
public sealed record AlignWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<AlignWidget>

Inheritance ​

Object → Hex1bWidget → AlignWidget

Implements ​

Constructors ​

AlignWidget(Hex1bWidget, Alignment) ​

A widget that aligns its child within the available space.

Parameters:

  • Child (Hex1bWidget): The child widget to align.
  • Alignment (Alignment): The alignment flags specifying horizontal and/or vertical alignment.
csharp
public AlignWidget(Hex1bWidget Child, Alignment Alignment)

Properties ​

Alignment ​

The alignment flags specifying horizontal and/or vertical alignment.

Returns: Alignment

csharp
public Alignment Alignment { get; init; }

Child ​

The child widget to align.

Returns: Hex1bWidget

csharp
public Hex1bWidget Child { get; init; }

Remarks ​

AlignWidget expands to fill its parent container and positions the child based on the specified alignment flags. This is useful for centering content, positioning status bars at the bottom, or right-aligning buttons.

The alignment can combine horizontal (Left, HCenter, Right) and vertical (Top, VCenter, Bottom) flags. Convenience combinations like Center, TopRight, and BottomLeft are provided.

Examples ​

Center a text widget:

csharp
ctx.Align(Alignment.Center, ctx.Text("Hello!"))

Or use the convenience method:

csharp
ctx.Center(ctx.Text("Hello!"))

Released under the MIT License.