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.
public sealed record FormWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<FormWidget>Inheritance
Object → Hex1bWidget → FormWidget
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:
Children(IReadOnlyList<Hex1bWidget>):
public FormWidget(IReadOnlyList<Hex1bWidget> Children)Properties
Children
Returns: IReadOnlyList<Hex1bWidget>
public IReadOnlyList<Hex1bWidget> Children { get; init; }LabelPlacement
The label placement mode for form fields. Defaults to .
Returns: LabelPlacement
public LabelPlacement LabelPlacement { get; init; }LabelWidth
The label width in columns when using . Defaults to 15.
Returns: Int32
public int LabelWidth { get; init; }Methods
WithLabelPlacement(LabelPlacement)
Sets the label placement mode for all fields in the form.
Parameters:
placement(LabelPlacement):
Returns: FormWidget
public FormWidget WithLabelPlacement(LabelPlacement placement)WithLabelWidth(int)
Sets the label width for inline label placement.
Parameters:
width(Int32):
Returns: FormWidget
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
ctx.Form(form =>
{
var name = form.TextField("Name").MinWidth(20);
var email = form.TextField("Email").EnableWhenValid(name);
return [name, email, form.SubmitButton("Save", e => { })];
})