Skip to content

StaticInput

Abstract Inherits: StaticInputBase

StaticInput is the headless base class for free-text <input> and <textarea> components — text, number, date, email, password, etc. It adds no new properties over StaticInputBase; its purpose is to be a clear inheritance target so a UI kit can name and style text-style inputs distinctly from checkboxes, radios and selects.

In the component’s Razor template, bind the inner <input> (or <textarea>) via the static-for tag helper.

TechGems.StaticComponents.Headless
using Microsoft.AspNetCore.Razor.TagHelpers;
using TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public class PinesInput : StaticInput
{
//static-for owns the type attribute, so declare a property for it to let consumers set it.
[HtmlAttributeName("type")]
public string? Type { get; set; }
}
@* ~/Views/Components/PinesInput.cshtml *@
@model PinesInput
@if (Model.ShowLabel)
{
<label static-for="@Model.InputExpression" class="…"></label>
}
<input static-for="@Model.InputExpression"
static-attributes="@Model.AdditionalAttributes"
type="@Model.Type"
disabled="@(Model.Disabled ? "disabled" : null)"
class="…" />
@* consumer view *@
<pines-input asp-for="Form.FullName"></pines-input>
<pines-input asp-for="Form.SignupEmail"></pines-input> @* type inferred from [DataType] *@
<pines-input asp-for="Form.Password" type="password"></pines-input>
<pines-input asp-for="Form.Nickname" placeholder="Optional" autocomplete="off"></pines-input>
  • InputExpression (asp-for)
  • ShowLabel (show-label)
  • Disabled (disabled)
  • AdditionalAttributes (everything else the consumer wrote)

See StaticInputBase for the full descriptions.

ProcessAsync(TagHelperContext context, TagHelperOutput output)

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

Delegates to StaticInputBase.ProcessAsync.