Checkbox
A checkbox with a built-in label and an indeterminate state for "select all" boxes.
<arc-checkbox>Overview
Checkbox lets users pick any combination of options, where a radio group allows only one. It has a built-in label, a name and value for native form submission, and arc-change on every state change.
Besides checked and unchecked, it has an indeterminate state for a "select all" box whose group is only partly checked. Toggling an indeterminate checkbox makes it checked, as in file managers and data tables. Space toggles the focused checkbox, and clicking the label does too. disabled dims the box and blocks input.
There is no checkbox group component. Group related checkboxes yourself, for example in a Fieldset.
Guidelines
Do
- Give every checkbox a short label
- Use the indeterminate state on a "select all" box that controls a partly checked group
- Order the options alphabetically, by frequency or by importance
- Put related checkboxes under a visible heading or fieldset legend
- Pre-check recommended or common options
Don't
- Don't use checkboxes for mutually exclusive choices. Use a radio group
- Don't use a checkbox as an on/off switch that acts at once. Use a toggle
- Don't rely on color alone to show the checked state. The checkmark carries it
- Don't disable a checkbox without saying nearby why the option is unavailable
- Don't nest checkboxes more than one level deep
- Don't write negative labels like "Don't send emails". Say what checking it does
Features
- Indeterminate shows a dash in place of the checkmark
- Unchecked boxes submit nothing, and checked ones submit `value` (default "on"), as native checkboxes do
Preview
Usage
Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.
<script type="module" src="@arclux/arc-ui"></script>
<div style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm);">
<arc-checkbox label="Set up your profile" checked></arc-checkbox>
<arc-checkbox label="Connect a repository" checked></arc-checkbox>
<arc-checkbox label="Invite team members"></arc-checkbox>
<arc-checkbox label="Configure CI/CD"></arc-checkbox>
</div>import { Checkbox } from '@arclux/arc-ui-react';
export function OnboardingChecklist() {
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 'var(--space-sm)' }}>
<Checkbox label="Set up your profile" checked />
<Checkbox label="Connect a repository" checked />
<Checkbox label="Invite team members" />
<Checkbox label="Configure CI/CD" />
</div>
);
}<script setup>
import { Checkbox } from '@arclux/arc-ui-vue';
</script>
<template>
<div style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm);">
<Checkbox label="Set up your profile" checked />
<Checkbox label="Connect a repository" checked />
<Checkbox label="Invite team members" />
<Checkbox label="Configure CI/CD" />
</div>
</template><script>
import { Checkbox } from '@arclux/arc-ui-svelte';
</script>
<div style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm);">
<Checkbox label="Set up your profile" checked />
<Checkbox label="Connect a repository" checked />
<Checkbox label="Invite team members" />
<Checkbox label="Configure CI/CD" />
</div>import { Component } from '@angular/core';
import { Checkbox } from '@arclux/arc-ui-angular';
@Component({
imports: [Checkbox],
template: `
<div style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm);">
<arc-checkbox label="Set up your profile" checked></arc-checkbox>
<arc-checkbox label="Connect a repository" checked></arc-checkbox>
<arc-checkbox label="Invite team members"></arc-checkbox>
<arc-checkbox label="Configure CI/CD"></arc-checkbox>
</div>
`,
})
export class OnboardingChecklistComponent {}import { Checkbox } from '@arclux/arc-ui-solid';
export function OnboardingChecklist() {
return (
<div style={{ display: 'flex', 'flex-direction': 'column', 'align-items': 'flex-start', gap: 'var(--space-sm)' }}>
<Checkbox label="Set up your profile" checked />
<Checkbox label="Connect a repository" checked />
<Checkbox label="Invite team members" />
<Checkbox label="Configure CI/CD" />
</div>
);
}import { Checkbox } from '@arclux/arc-ui-preact';
export function OnboardingChecklist() {
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 'var(--space-sm)' }}>
<Checkbox label="Set up your profile" checked />
<Checkbox label="Connect a repository" checked />
<Checkbox label="Invite team members" />
<Checkbox label="Configure CI/CD" />
</div>
);
}<div style="display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-sm);">
<arc-checkbox label="Set up your profile" checked></arc-checkbox>
<arc-checkbox label="Connect a repository" checked></arc-checkbox>
<arc-checkbox label="Invite team members"></arc-checkbox>
<arc-checkbox label="Configure CI/CD"></arc-checkbox>
</div><!-- Auto-generated by @arclux/prism — do not edit manually -->
<!-- arc-checkbox — self-contained, no external CSS needed -->
<div class="arc-checkbox">
</div>API
disabledbooleanfalse- Prevents all pointer and keyboard interaction and applies a dimmed visual treatment. Use this for options that are unavailable due to unmet prerequisites. Pair with a tooltip or helper text to explain why the option is locked.
labelstring''- Visible text rendered beside the checkbox. Clicking the label toggles the checkbox, matching native HTML behavior. Keep labels short, affirmative, and action-oriented for the best readability.
namestring''- The form field name submitted when the checkbox lives inside a <form>. Required for native form submission and useful for serializing checkbox group values on the server.
valuestring''- The value sent with the form when the checkbox is checked. Defaults to "on" if omitted, matching native checkbox behavior. Set explicit values when multiple checkboxes share the same name to distinguish them in the submitted data.
checkedbooleanfalse- Controls whether the checkbox is in its checked (selected) state. When true, a checkmark icon is rendered inside the box. Bind to this property for two-way state management in frameworks that support it.
indeterminatebooleanfalse- When true, displays a horizontal dash instead of a checkmark, representing a mixed or partially-selected state. Commonly used on a parent "select all" checkbox when only some children are checked. Clicking an indeterminate checkbox resolves it to fully checked.
size'sm' | 'md' | 'lg''md'- Controls the checkbox size.
formAssociatedbooleantruepropertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }- Lit merges static properties up the prototype chain, so every consumer
gets these without declaring them.
requiredparticipates in constraint validation below;readonlyreflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state). autoValidatesbooleantrue- Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
formvalidityvalidationMessagerequiredbooleanfalsereadonlybooleanfalse
Methods
checkValidity()boolean- Whether the control currently satisfies its constraints, per the native
constraint-validation API. Fires
invalidon the element when it does not, and reports nothing to the user. reportValidity()boolean- As checkValidity(), but also shows the browser's validation message against the control when it fails.
Events
arc-changedetail:{ checked: boolean }- Fired when the checked state changes