Class TwInputGroup
- Namespace
- TwBlazor.Components
- Assembly
- TwBlazor.dll
Wraps an input with addons - text, icons or buttons - before, after, above or below it, drawn as one field.
public class TwInputGroup : TwBlazorComponentBase, IComponent, IHandleEvent, IHandleAfterRender, ITwComponent, IDisposable
- Inheritance
-
TwInputGroup
- Implements
- Inherited Members
Remarks
Place one input (TwTextfield<T>, TwNumeric<T>, TwMaskedInput, TwSelect<T>, TwAutocomplete<T> or a picker built on a text field) and any number of TwInputGroupAddons inside. The group draws the border, background, rounding, focus ring and invalid state for the input's Variant, and the input inside it drops its own, so the addons sit inside the field. Addons are placed by their Align, whatever their order in the markup, and follow the layout direction, so a start addon moves to the right in a right to left layout.
The group is rendered with role="group", named by Label, AriaLabel
or AriaLabelledBy. A TwInputGroupText is added to the input's
aria-describedby, so a screen reader reads a prefix or unit such as "https://" or "kg" with the field.
The input's validation message is shown below the group instead of inside it.
Constructors
TwInputGroup()
public TwInputGroup()
Properties
ChildContent
Gets or sets the input and addons inside the group.
[Parameter]
public RenderFragment? ChildContent { get; set; }
Property Value
Dense
Gets or sets whether the group, and the input and buttons inside it, use the compact height and text size.
[Parameter]
public bool Dense { get; set; }
Property Value
For
Gets or sets the id of the input that Label labels.
[Parameter]
public string? For { get; set; }
Property Value
Label
Gets or sets the label shown above the group, which also names the group for screen readers.
[Parameter]
public string? Label { get; set; }
Property Value
Remarks
Set For to the input's Id so clicking the label focuses the input and the input takes its
name from the label. Otherwise, give the input its own AriaLabel.
LabelClass
Gets or sets additional classes for the label.
[Parameter]
public string LabelClass { get; set; }
Property Value
RootClass
Gets or sets additional classes for the outer element that holds the label, the group and its validation messages. Class styles the group itself.
[Parameter]
public string RootClass { get; set; }
Property Value
Variant
Gets or sets the visual variant of the group (Default, Outlined, Filled).
[Parameter]
public InputVariant? Variant { get; set; }
Property Value
Remarks
If not set, uses the global default from DefaultInputVariant, the same as the inputs.
The input inside the group takes its look from the group, so its own Variant has no effect on its border.
Methods
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder
Dispose()
public void Dispose()
Dispose(bool)
Releases the group's managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposingbool
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.