Skip to content

StaticInputBase

Abstract Inherits: StaticComponent

StaticInputBase is the root abstract class for every headless input-like component (text inputs, checkboxes, radios, selects). It exposes the bound ModelExpression, plus the two switches every input needs (ShowLabel and Disabled).

You usually don’t inherit from StaticInputBase directly — pick the more specific StaticInput, StaticCheckbox, StaticRadio or StaticSelect for the element you’re building.

TechGems.StaticComponents.Headless
using TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public abstract class MyInputBase : StaticInputBase { }
[HtmlAttributeName("asp-for")]
public ModelExpression? InputExpression { get; set; }

The ModelExpression resolved from the consumer-facing asp-for attribute. In the component’s Razor template you pass this to the inner element via a static-* tag helper so the original property metadata can be recovered through the doubly-wrapped expression.

AttributeValue
HTML attributeasp-for
RequiredNo
Defaultnull
[HtmlAttributeName("show-label")]
public bool ShowLabel { get; set; } = true;

Lets consumers opt-out of the inline label rendered by your component template. Default is true.

[HtmlAttributeName("disabled")]
public bool Disabled { get; set; }

A boolean that maps to the consumer-facing disabled HTML attribute, surfaced as a C# bool so your template can branch on it without having to parse strings.

[HtmlAttributeNotBound]
public StaticAttributeCollection AdditionalAttributes { get; private set; }

Every HTML attribute the consumer wrote on your component that wasn’t bound to one of its C# properties. Apply it to an element in your template with the static-attributes tag helper so end users can pass arbitrary markup — placeholder, data-*, aria-*, Alpine and HTMX bindings — through to the rendered element:

<input static-for="@Model.InputExpression"
static-attributes="@Model.AdditionalAttributes"
class="block w-full rounded-md border px-3 py-2" />

Nothing is passed through until you add static-attributes to your template, so adding this to an existing component is opt-in. See StaticAttributeCollection for the filtering methods that let you route different attributes to different elements.

ProcessAsync(TagHelperContext context, TagHelperOutput output)

Section titled “ProcessAsync(TagHelperContext context, TagHelperOutput output)”
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)

Delegates to StaticComponent.ProcessAsync, which renders the Razor partial view associated with the component.