For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/v0.4.1/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/v0.4.1/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/v0.4.1/en/components/checkbox.md.
Checkbox lets people select zero, one, or several non-exclusive options. Use it for choices that are submitted with a form; use Switch for a binary setting that takes effect immediately.
For component-level loading, import the base styles, Checkbox structure, Field structure, and the A3S visual style in that order. See Installation for CDN and other integrations.
Unchecked and checked are the normal interactive states. Disabled choices must explain why they are unavailable. Show invalid state only after submission or field departure so the page does not open with premature errors.
indeterminate is a DOM property commonly used by a “select all” control. Form submission still follows checked, so applications must maintain both values explicitly.
Group related options with fieldset and legend. A label answers what the option is; supporting copy explains its consequence or constraint. Do not place an entire description inside the label.
Export content
<fieldset class="fieldset">
<legend data-variant="legend">Choose content to export</legend>
<p>Select at least one item before starting the export.</p>
<div class="grid gap-3">
<div class="field" data-orientation="horizontal">
<input class="input" type="checkbox" id="export-documents-en" name="export-content" value="documents" defaultChecked />
<label for="export-documents-en">Documents</label>
</div>
<div class="field" data-orientation="horizontal">
<input class="input" type="checkbox" id="export-comments-en" name="export-content" value="comments" defaultChecked />
<label for="export-comments-en">Comments and annotations</label>
</div>
<div class="field" data-orientation="horizontal">
<input class="input" type="checkbox" id="export-history-en" name="export-content" value="history" />
<label for="export-history-en">Version history</label>
</div>
</div>
</fieldset>
Export confirmation
<form
class="grid gap-3"
data-checkbox-validation-demo="en"
novalidate
onsubmit="event.preventDefault(); const confirm = this.querySelector('#export-confirm-en'); const error = this.querySelector('#export-confirm-error-en'); const status = this.querySelector('[data-checkbox-status]'); const field = confirm.closest('.field'); if (this.getAttribute('aria-busy') === 'true') return; field.removeAttribute('data-invalid'); confirm.removeAttribute('aria-invalid'); error.hidden = true; if (!confirm.checked) { field.dataset.invalid = 'true'; confirm.setAttribute('aria-invalid', 'true'); error.hidden = false; status.textContent = 'Fix confirmation before exporting.'; return; } status.textContent = 'Export confirmed.'; this.dataset.exportState = 'confirmed';"
onreset="const confirm = this.querySelector('#export-confirm-en'); const error = this.querySelector('#export-confirm-error-en'); const status = this.querySelector('[data-checkbox-status]'); const field = confirm.closest('.field'); field.removeAttribute('data-invalid'); confirm.removeAttribute('aria-invalid'); error.hidden = true; status.textContent = 'Ready to confirm export.'; this.removeAttribute('data-export-state');"
>
<div class="field" data-orientation="horizontal">
<input class="input" type="checkbox" id="export-confirm-en" name="export-confirm" required aria-describedby="export-confirm-help-en" />
<section>
<label for="export-confirm-en">I removed sensitive data from this export</label>
<p id="export-confirm-help-en" data-field-description>Required before the archive leaves the workspace.</p>
<p id="export-confirm-error-en" role="alert" hidden>Confirmation is required before export.</p>
</section>
</div>
<p data-checkbox-status aria-live="polite">Ready to confirm export.</p>
<div class="flex flex-wrap gap-2">
<button class="btn" type="submit">Export archive</button>
<button class="btn" type="reset">Reset</button>
</div>
</form>
Row selection inside a table belongs to the complete interaction model of Table or Data Grid. Its “select all” control must synchronize visible rows, cross-page scope, and indeterminate state; do not present an inert table gallery in Checkbox documentation.
Every checkbox needs an accessible name, preferably a visible label paired through id.
Group related options with fieldset and legend; do not add redundant role="group" to an ordinary .field.
Space toggles a focused native checkbox. Do not replace browser behavior with a custom click handler or block label activation.
Associate help and error copy with aria-describedby; set aria-invalid="true" when validation fails.
Keep the label and unavailability reason visible for disabled options. If users still need to understand or copy the content, disable only the control rather than hiding the row.
indeterminate communicates partial selection visually and semantically; form submission still follows checked.