Skip to content

FormTextFieldWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A form text field widget that renders as a label + text input + error indicator. Also serves as a field handle for cross-field references (validation, enablement).

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

Inheritance

ObjectHex1bWidgetFormTextFieldWidget

Implements

Constructors

FormTextFieldWidget(string, string)

Parameters:

csharp
public FormTextFieldWidget(string fieldId, string label)

Properties

FieldId

Unique identifier for this field within the form. Preserved across fluent method calls.

Returns: String

csharp
public string FieldId { get; }

InitialValue

Initial text value for the field.

Returns: String

csharp
public string? InitialValue { get; init; }

Label

The label text displayed for this field.

Returns: String

csharp
public string Label { get; init; }

MaxWidth

Maximum width of the text input in columns. Defaults to MinWidth if not explicitly set.

Returns: Nullable<Int32>

csharp
public int? MaxWidth { get; init; }

MinWidth

Minimum width of the text input in columns.

Returns: Nullable<Int32>

csharp
public int? MinWidth { get; init; }

ValidateOn

When validation should be triggered.

Returns: ValidateOn

csharp
public ValidateOn ValidateOn { get; init; }

Methods

Adornment(Func<string, CancellationToken, Task<bool>>, Func<Hex1bWidget>)

Adds an adornment with an async predicate and widget builder. The adornment is displayed next to the field when the predicate resolves to true. When the field value changes, the predicate is re-evaluated (cancelling any in-flight evaluation).

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Adornment(Func<string, CancellationToken, Task<bool>> predicate, Func<Hex1bWidget> builder)

Adornment(Func<string, Task<bool>>, Func<Hex1bWidget>)

Adds an adornment with an async predicate (no cancellation token) and widget builder.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Adornment(Func<string, Task<bool>> predicate, Func<Hex1bWidget> builder)

EnableWhen(Func<bool>)

Enables this field only when the predicate returns true.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget EnableWhen(Func<bool> predicate)

EnableWhenValid(params FormTextFieldWidget[])

Enables this field only when all specified fields are valid.

Parameters:

  • fields (FormTextFieldWidget[]):

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget EnableWhenValid(params FormTextFieldWidget[] fields)

Multiline()

Enables multi-line text editing for this form field.

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Multiline()

Multiline(int)

Enables multi-line text editing with a maximum number of lines. Once the limit is reached, no more newlines can be inserted.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Multiline(int maxLines)

OnTextChanged(Action<TextChangedEventArgs>)

Sets a handler for text change events.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget OnTextChanged(Action<TextChangedEventArgs> handler)

OnTextChanged(Func<TextChangedEventArgs, Task>)

Sets an async handler for text change events.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget OnTextChanged(Func<TextChangedEventArgs, Task> handler)

Validate(Func<string, ValidationResult>)

Adds a validator to this field.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Validate(Func<string, ValidationResult> validator)

WithHeight(int)

Sets the height of the text input in lines.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithHeight(int lines)

WithInitialValue(string)

Sets the initial text value.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithInitialValue(string value)

WithLabelPlacement(LabelPlacement)

Overrides the label placement for this specific field.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithLabelPlacement(LabelPlacement placement)

WithMaxWidth(int)

Sets the maximum width of the text input.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithMaxWidth(int width)

WithMinWidth(int)

Sets the minimum width of the text input.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithMinWidth(int width)

WithValidateOn(ValidateOn)

Sets when validation should be triggered for this field.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithValidateOn(ValidateOn mode)

WithWidth(int)

Sets an exact fixed width for the text input (sets both MinWidth and MaxWidth).

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WithWidth(int width)

WordWrap()

Enables word wrapping for this multi-line form field.

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget WordWrap()

Remarks

FormTextFieldWidget is created via form.TextField("Label") inside a Form builder. It composes a label (TextBlockWidget), a text input (TextBoxWidget), and an optional error indicator into a single self-contained field.

The widget also acts as a field handle: the uniquely identifies this field within the form, enabling cross-field features like .

Released under the MIT License.