Table of Contents

Class TwBlazorInputComponentBase

Namespace
TwBlazor
Assembly
TwBlazor.dll
public class TwBlazorInputComponentBase : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, ITwInputComponent
Inheritance
TwBlazorInputComponentBase
Implements
Derived
Inherited Members

Constructors

TwBlazorInputComponentBase()

public TwBlazorInputComponentBase()

Properties

Disabled

Gets or sets whether the input component is disabled.

[Parameter]
public bool Disabled { get; set; }

Property Value

bool

Remarks

When true, the component is visually dimmed and cannot be interacted with.

ErrorMessage

Gets or sets the validation error message to display and associate with the input.

[Parameter]
public string ErrorMessage { get; set; }

Property Value

string

Remarks

Only rendered and referenced by aria-describedby when Invalid is true.

Invalid

Gets or sets whether the input component currently fails validation.

[Parameter]
public bool Invalid { get; set; }

Property Value

bool

Remarks

When true (and ErrorMessage is set), the control is marked aria-invalid and programmatically associated with the rendered error text via aria-describedby, so assistive tech announces the error alongside the field instead of leaving it undiscoverable.

Label

Gets or sets the text label associated with the component.

[Parameter]
public string Label { get; set; }

Property Value

string

LabelAttributes

Gets or sets a collection of additional attributes to apply to the label element.

[Parameter]
public Dictionary<string, object> LabelAttributes { get; set; }

Property Value

Dictionary<string, object>

Remarks

Use this property to add arbitrary HTML attributes to the rendered label, such as custom data attributes, CSS classes, or ARIA attributes. Existing attributes with the same name may be overwritten.

LabelClass

Gets or sets the classes for the label.

[Parameter]
public string LabelClass { get; set; }

Property Value

string

LabelClasses

Gets the CSS classes applied to the label element.

public string LabelClasses { get; }

Property Value

string

Remarks

Combines the default label styling (block display, margin, font size, and weight) with any custom classes specified in LabelClass.

LabelId

Gets or sets the unique identifier for the associated label element.

[Parameter]
public string LabelId { get; set; }

Property Value

string

Remarks

Use this property to specify the ID of a label element that is associated with the component for accessibility purposes. Setting this value enables assistive technologies to correctly identify and describe the component.

ReadOnly

Gets or sets whether the input component is readonly.

[Parameter]
public bool ReadOnly { get; set; }

Property Value

bool

Remarks

When true, the component cannot be edited by the user but will still display its current value.

RootAttributes

Gets or sets the additional attributed applied to the root element of the component.

[Parameter]
public Dictionary<string, object> RootAttributes { get; set; }

Property Value

Dictionary<string, object>

RootClass

Gets or sets the CSS class name applied to the root element of the component.

[Parameter]
public string RootClass { get; set; }

Property Value

string

RootId

Gets or sets the unique identifier for the root element.

[Parameter]
public string RootId { get; set; }

Property Value

string

errorId

Gets the id of the rendered error message element when the field is invalid, or null otherwise. Leaf components use this both to render the error text (via TwInputRoot) and to reference it from the control's aria-describedby, so assistive tech announces the error alongside the field.

protected string? errorId { get; }

Property Value

string

Methods

Close()

Closes the component's picker dialog. Override in picker components to handle close logic.

[JSInvokable("Close")]
public virtual Task Close()

Returns

Task

OnParametersSet()

Invoked when the component's parameters have been set. Ensures that the component has a unique identifier by generating one if none is provided.

protected override void OnParametersSet()

Remarks

If the component's identifier is not set, a unique ID is generated based on the component's type name (with a 'Tw' prefix removed if present) and a GUID. This helps ensure that each component instance can be uniquely identified, which is useful for scenarios such as associating labels with form elements or targeting elements in client-side scripts.