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; }

Label

The label text displayed for this field.

Returns: String

csharp
public string Label { 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)

Height(int)

Sets the height of the text input in lines.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Height(int lines)

InitialValue(string)

Sets the initial text value.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget InitialValue(string value)

LabelPlacement(LabelPlacement)

Overrides the label placement for this specific field.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget LabelPlacement(LabelPlacement placement)

MaxWidth(int)

Sets the maximum width of the text input.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget MaxWidth(int width)

MinWidth(int)

Sets the minimum width of the text input.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget MinWidth(int width)

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)

ValidateOn(ValidateOn)

Sets when validation should be triggered for this field.

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget ValidateOn(ValidateOn mode)

Width(int)

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

Parameters:

Returns: FormTextFieldWidget

csharp
public FormTextFieldWidget Width(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.