Skip to content

StaticButton

Inherits: StaticComponent

StaticButton is a headless base class for <button> components. Unlike the input headless classes, it does not bind to a model — buttons don’t have an asp-for analogue. It adds a validated type attribute and a Disabled flag, leaving styling and child content composition to your component template.

TechGems.StaticComponents.Headless
using TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public class PinesButton : StaticButton { }
@* ~/Views/Components/PinesButton.cshtml *@
@model PinesButton
<button type="@Model.Type"
disabled="@(Model.Disabled ? "disabled" : null)"
class="">
@Model.ChildContent
</button>
@* consumer view *@
<pines-button type="submit">Save changes</pines-button>
<pines-button type="button" disabled="true">Loading…</pines-button>
[HtmlAttributeName("type")]
public string Type { get; set; } = "button";

The HTML type attribute the rendered <button> should carry. Only "button", "submit" and "reset" are accepted — any other value throws ArgumentException at render time, so typos surface immediately instead of producing broken HTML.

AttributeValue
HTML attributetype
RequiredNo
Default"button"
Accepted values"button", "submit", "reset"
[HtmlAttributeName("disabled")]
public bool Disabled { get; set; } = false;

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

AttributeValue
HTML attributedisabled
RequiredNo
Defaultfalse

ProcessAsync(TagHelperContext context, TagHelperOutput output)

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

Validates that Type is one of the three accepted values and then delegates to StaticComponent.ProcessAsync.

ConditionException
Type is null, empty, or not one of "button" / "submit" / "reset"ArgumentException