Component reference
Checkbox
A native checkbox with its label, including the mixed state.
Preview
Checkboxes and switches
Activate labels, toggle with the space bar and reset the form; a controlled switch leaves it to the caller to accept a change.
render: () => {
const checked = signal(true);
return (
<form onSubmit={(event: Event) => event.preventDefault()}>
<Stack>
<Checkbox label="Save this choice" name="remember" defaultChecked />
<Checkbox label="Required before submitting" name="confirm" required />
<Checkbox label="Currently unavailable" disabled />
<Checkbox label="Some children selected" indeterminate defaultChecked={false} />
<Switch label="Show tool process" name="tools" defaultChecked />
<Switch
label="Notifications (controlled)"
name="notifications"
checked={checked}
onChange={(event: Event) => {
checked.value = (event.currentTarget as HTMLInputElement).checked;
}}
/>
<Switch label="Always on (rejects changes)" checked={true} />
<Switch label="Unavailable" disabled />
<ActionRow>
<Button type="reset" variant="outline">
Reset
</Button>
<Button type="submit">Confirm</Button>
</ActionRow>
</Stack>
</form>
);
}Installation
bun add meowtail
Usage
Taken from the examples on this page.
import { Checkbox } from "meowtail";
<Checkbox label="Save this choice" name="remember" defaultChecked />API reference
Props
| Prop | Type | Default |
|---|---|---|
checked | MaybeSignal<boolean> | – |
defaultChecked | boolean | – |
indeterminateNative indeterminate property. Assistive technology reads aria-checked="mixed". | MaybeSignal<boolean> | – |
onChange | (event: Event) => void | – |
labelRequired | MaybeSignal<string> | – |
labelHiddenKeep the accessible name while hiding the visible label, for compact tables. | boolean | – |
Also takes className, children and the attributes and events of its root element.
DOM parts
rootinputlabel
Registry
The component is registered as checkbox in the meowtail component registry.