Skip to content

StaticLabel

Abstract Inherits: StaticComponent

StaticLabel is the headless base class for standalone <label> components. Use it when your UI kit needs a label that can sit next to any input rather than living inside an input component’s template.

Note that StaticLabel inherits from StaticComponent (not StaticInputBase) and exposes the bound expression as For instead of InputExpression — but the consumer-facing attribute is still asp-for.

TechGems.StaticComponents.Headless
using TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public class PinesLabel : StaticLabel { }
@* ~/Views/Components/PinesLabel.cshtml *@
@model PinesLabel
<label static-for="@Model.For" class=""></label>
@* consumer view *@
<pines-label asp-for="Form.FullName"></pines-label>

The rendered label content comes from the property’s [DisplayName] if present, otherwise the property name itself.

[HtmlAttributeName("asp-for")]
public ModelExpression For { get; set; } = default!;

The ModelExpression resolved from the consumer-facing asp-for attribute. Pass this to the inner <label> via static-for.

AttributeValue
HTML attributeasp-for
RequiredYes
Defaultnone

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.