AppCheckbox
A single true/false setting — or several independent ones the user ticks on their own.
<app-checkbox label="Send weekly digest" name="digest" />A checkbox captures a single yes/no answer — accept the terms, subscribe to a digest, enable a feature. Several checkboxes together capture independent yes/no answers: ticking one never changes another, which is exactly what sets a checkbox apart from a radio.
Its look comes entirely from the shared @webority/theme, so the Razor <app-checkbox> and the React <AppCheckbox> render identically — a checkbox is a checkbox on every Webority surface.
Playground
Every attribute, live. Each change re-renders the real tag helper on the server, so the markup underneath is the exact call that produced the checkbox above it.
indeterminate flag is a DOM property, not an HTML attribute, so it can't round-trip through a query-string playground or a server-rendered tag helper — it has to be set imperatively from your own page script after the checkbox renders. See Every option → state.Label and checked
A checkbox is its label plus its checked state. Bind checked / onChange for a controlled value; the label is what the user clicks.
Show code
<app-checkbox label="Send weekly digest" name="digest" />
Independent options
Stack several checkboxes when the choices don't exclude each other — the user can tick any combination, including none or all.
Show code
<div class="d-flex flex-column gap-2">
<app-checkbox label="Weekly digest" name="pref-digest" checked="true" />
<app-checkbox label="Product updates" name="pref-product" />
<app-checkbox label="Security alerts" name="pref-security" checked="true" />
</div>
Validation
Show a hint for guidance and an error when validation fails. They share one slot below the control — the error replaces the hint, matching app-input.
Show code
<app-checkbox label="Send weekly digest" name="digest" hint="Sent every Monday morning." /> <app-checkbox label="Accept terms" name="terms" required="true" error="You must accept the terms." />
When to use
Use it when
- You need one or more independent true/false settings — any combination is valid.
- The user opts in on a form that is saved later (terms, notification preferences).
- Several options apply at once and are not mutually exclusive.
Reach for something else when
- One on/off setting that takes effect immediately. → AppSwitch
- The user must pick exactly one of 2–5 options. → AppRadio
- The user picks many values from a long list. → AppMultiSelect
- It is a selectable filter or tag pill. → AppChoiceChip
Best practices
Every option
The whole surface of the component, one cell per value — including the states a normal example never shows: indeterminate, disabled combinations, and the label edge cases.
state
(default) — uncheckedchecked="true"indeterminate — no attribute; set el.indeterminate from your own script after renderdisabled="true"disabled="true" checked="true"required="true" — pass-through attribute, not a typed onelabel
(no label attribute) — no <label> renderedlabel="0" — falsy-but-not-nullish string, still renderschild content — markup label, e.g. an embedded linkvalidation
hinterror (replaces hint)required + errorAttributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| label | string | — | The clickable label beside the box, HTML-encoded. For markup (e.g. an embedded link), use child content instead — the React equivalent is a ReactNode label. |
| (content) | markup | — | Razor-only. Child content is used as the label verbatim (not encoded) when present, so it can carry markup like a link. Wins over label. |
| asp-for | ModelExpression | — | Razor-only. Binds name, id, checked state, label and validation message from the model, via IHtmlGenerator. |
| name | string | — | Field name for form submission; also derives the input id when id is not set. |
| id | string | — | Explicit input id — binds the label's for to it and overrides the name-derived id. Declared property, matching React's id. Auto-generated from name / asp-for when omitted. |
| value | string | — | Submitted value when checked. |
| checked | bool | false | Renders the box in the checked state. |
| required | bool | — | Not a typed attribute on the tag helper — an unclaimed author attribute like this passes through to the rendered <input> verbatim (the same mechanism as React's {...rest}). |
| error | string | — | Error message below the control. Turns aria-invalid true and replaces the hint. Wins over the model's own asp-for validation message. |
| hint | string | — | Helper text below the control. Hidden while an error (or a model validation message) is shown. |
| disabled | bool | false | Disables the control. Declared property, matching React's disabled. |
| shape | pill | round | circle | pill | Track shape for app-switch only — ignored on app-checkbox. See the AppSwitch page. |
| class | string | — | Extra class on the form-check wrapper. |