Inputs
Checkbox
Binary or indeterminate selection control with full keyboard support.
<script>
import { Checkbox } from "@codeatlasdev/ui";
let accepted = $state(false);
</script>
<Checkbox label="I accept the terms" bind:checked={accepted} />
A checkbox rendered without label (for example in a table row) needs an aria-label. Space toggles it. Any other native attribute or handler (data-*, id, onclick, onkeydown, aria-describedby, value…) is forwarded to the native <input>, and ref gives you that input.
States
Unchecked, checked and indeterminate.
Reference #008 · Pick in the gallery
Code
Disabled
Reference #007 · Pick in the gallery
Code
Without label
Bare checkbox for table rows or custom layouts.
Reference #009 · Pick in the gallery
Code
Shift range selection
onclick is forwarded to the input and runs just before onchange, so shiftKey is readable. data-testid reaches the input.
0 selected. Shift+click extends the range.
Reference #387 · Pick in the gallery
Code
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | Bindable checked state. |
indeterminate | boolean | false | Renders the mixed state. |
disabled | boolean | false | Disables interaction. |
name | string | – | Native name, so the checkbox is in FormData on a plain form submit (value `on` when checked, absent when not). |
label | string | – | Visible label rendered beside the checkbox. |
aria-label | string | – | Accessible name used when no visible label is rendered. |
aria-labelledby | string | – | Id of an element that names the checkbox. Ignored when label is set. |
class | string | – | Extra classes on the wrapper. |
ref | HTMLInputElement | null | – | Bindable native input element. |
onchange | (checked: boolean, event: Event) => void | – | Called when the checked state changes, with the native change event. |