Checkbox
An accessible checkbox with label, description, error, and indeterminate state.
Rendering Checkbox…
Installation
Copy the source into your project with the CLI. It lands under @/components/ui and is yours to edit.
npx mlola-ui add checkboxUsage
import { Checkbox } from "@/components/ui/checkbox";
export default function Example() {
return <Checkbox label="Email me about releases" description="At most once a month." defaultChecked />;
}Styling comes from the engine stylesheet and the nearest theme. Set it once at the root:
<html data-theme="graphite" data-mode="light">HTML
The markup the example above renders, exactly. It needs no script: write it from any language or template.
<div class="ml-checkbox-field" data-state="checked">
<label class="ml-checkbox-control" data-hit="expand"><input class="ml-checkbox-input" id="checkbox-1" type="checkbox" aria-checked="true" aria-describedby="checkbox-1-description" checked=""/><span class="ml-checkbox-indicator" aria-hidden="true"><svg class="mlola-glyph" width="0.75em" height="0.75em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--mlola-glyph-stroke, var(--ml-icon-stroke, 1.75))" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true" data-optical-size="default" style="color:var(--mlola-glyph-color, currentColor);scale:var(--mlola-glyph-optical-scale, 1);transform-origin:center"><polyline points="20 6 9 17 4 12" pathLength="1"></polyline></svg></span></label>
<span class="ml-checkbox-copy"><label class="ml-checkbox-label" for="checkbox-1"><span class="ml-checkbox-text">Email me about releases</span></label><span class="ml-checkbox-description" id="checkbox-1-description">At most once a month.</span></span>
</div>Classes and attributes
A class names each element; data-* and aria-* attributes carry its variant and state. The values listed are the ones the stylesheet draws; the default needs no attribute.
| Class | Attributes |
|---|---|
ml-checkbox-field | data-state="checked | indeterminate" |
ml-checkbox-control | — |
ml-checkbox-input | — |
ml-checkbox-indicator | — |
ml-checkbox-label | — |
ml-checkbox-text | — |
ml-checkbox-copy | — |
ml-checkbox-description | — |
ml-checkbox-error | — |
Accessibility and theming
- Semantic elements, accessible names and state relationships are part of the contract.
- Keyboard, pointer and touch paths are operable; focus stays visible in every theme.
- Light and dark modes pass WCAG AA contrast in all 5 canonical themes.
- Reduced motion and forced colors keep meaning and operation.
Dependencies
Installed alongside this component. No third-party UI runtime is ever added.
@mlola-ui/icons