StaticCheckbox
StaticCheckbox is the headless base class for checkbox <input> components.
It adds the two attributes specific to checkboxes — Value (the value posted
when the box is checked) and Checked (an explicit override of the bool
model’s checked state).
Inside the component’s Razor template, bind the inner <input> via the
static-checkbox-for tag helper.
Namespace
Section titled “Namespace”TechGems.StaticComponents.Headlessusing TechGems.StaticComponents.Headless;
namespace YourAssembly.Views.Components;
public class PinesCheckbox : StaticCheckbox { }@* ~/Views/Components/PinesCheckbox.cshtml *@@model PinesCheckbox
<input static-checkbox-for="@Model.InputExpression" checked="@Model.Checked" disabled="@(Model.Disabled ? "disabled" : null)" class="…" />
@if (Model.ShowLabel){ <label static-for="@Model.InputExpression" class="…"></label>}@* consumer view *@<pines-checkbox asp-for="Form.AcceptsTerms"></pines-checkbox>Public Properties
Section titled “Public Properties”[HtmlAttributeName("value")]public string? Value { get; set; }The value posted when the checkbox is checked. Optional — the
static-checkbox-for tag helper unconditionally emits value="true" on the
inner <input> regardless of this property, but consumers can still author it
explicitly for clarity.
| Attribute | Value |
|---|---|
| HTML attribute | value |
| Required | No |
| Default | null |
Checked
Section titled “Checked”[HtmlAttributeName("checked")]public bool Checked { get; set; } = false;Lets a consumer mark the checkbox as checked regardless of the bound model value. Useful for visually-checked states driven by something other than the bound property.
| Attribute | Value |
|---|---|
| HTML attribute | checked |
| Required | No |
| Default | false |
Inherited Properties
Section titled “Inherited Properties”InputExpression(asp-for)ShowLabel(show-label)Disabled(disabled)
See StaticInputBase for the full descriptions.
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 StaticInputBase.ProcessAsync.
Related
Section titled “Related”- Headless Components — Feature guide.
- StaticInputBase
- StaticCheckboxTagHelper