StaticInputBase
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.
Namespace
Section titled “Namespace”TechGems.StaticComponents.Headlessusing TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public abstract class MyInputBase : StaticInputBase { }Public Properties
Section titled “Public Properties”InputExpression
Section titled “InputExpression”[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.
| Attribute | Value |
|---|---|
| HTML attribute | asp-for |
| Required | No |
| Default | null |
ShowLabel
Section titled “ShowLabel”[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.
Disabled
Section titled “Disabled”[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.
AdditionalAttributes
Section titled “AdditionalAttributes”[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.
Methods
Section titled “Methods”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.
Related
Section titled “Related”- Headless Components — Feature guide.
- StaticInput
- StaticCheckbox
- StaticRadio
- StaticSelect
- StaticAttributeCollection — the type of
AdditionalAttributes. - StaticAttributesTagHelper — applies it in your template.