StaticLabel
Abstract
Inherits: StaticComponent
Section titled “ProcessAsync(TagHelperContext context, TagHelperOutput output)”
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.
Namespace
Section titled “Namespace”TechGems.StaticComponents.Headlessusing 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.
Public Properties
Section titled “Public Properties”[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.
| Attribute | Value |
|---|---|
| HTML attribute | asp-for |
| Required | Yes |
| Default | none |
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.
Related
Section titled “Related”- Headless Components — Feature guide.
- StaticLabelTagHelper
- HeadlessUtils —
GetLabelContentresolves label text the same way.