Skip to content

FormWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A container widget for building structured forms with text fields, validation, and conditional enablement. FormWidget acts as a panel that lays out its children vertically, with optional label placement configuration.

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

Inheritance

ObjectHex1bWidgetFormWidget

Implements

Constructors

FormWidget(IReadOnlyList<Hex1bWidget>)

A container widget for building structured forms with text fields, validation, and conditional enablement. FormWidget acts as a panel that lays out its children vertically, with optional label placement configuration.

Parameters:

csharp
public FormWidget(IReadOnlyList<Hex1bWidget> Children)

Properties

Children

Returns: IReadOnlyList<Hex1bWidget>

csharp
public IReadOnlyList<Hex1bWidget> Children { get; init; }

LabelPlacement

The label placement mode for form fields. Defaults to .

Returns: LabelPlacement

csharp
public LabelPlacement LabelPlacement { get; init; }

LabelWidth

The label width in columns when using . Defaults to 15.

Returns: Int32

csharp
public int LabelWidth { get; init; }

Methods

WithLabelPlacement(LabelPlacement)

Sets the label placement mode for all fields in the form.

Parameters:

Returns: FormWidget

csharp
public FormWidget WithLabelPlacement(LabelPlacement placement)

WithLabelWidth(int)

Sets the label width for inline label placement.

Parameters:

Returns: FormWidget

csharp
public FormWidget WithLabelWidth(int width)

Remarks

Use the ctx.Form(...) extension method to create a form. The builder callback receives a which provides form-specific extensions like form.TextField(...) alongside standard widget methods.

Internally, FormWidget builds a VStack or Grid layout depending on the label placement mode and reconciles it as a single content child on the FormNode.

Examples

csharp
ctx.Form(form =>
{
    var name = form.TextField("Name").MinWidth(20);
    var email = form.TextField("Email").EnableWhenValid(name);
    return [name, email, form.SubmitButton("Save", e => { })];
})

Released under the MIT License.