base-ui-svelte

Checkbox

A control that allows the user to toggle between checked and not checked.

View as Markdown

API Reference

Props mirror Base UI React where applicable, adapted for Svelte 5. Native HTML attributes for the rendered element are also accepted unless noted.

Checkbox.Root

Extends button HTML attributes.

PropertyTypeDefaultDescription
checkedboolean | undefinedControlled checked state.
defaultCheckedbooleanUncontrolled initial checked state.
onCheckedChange((checked: boolean, event: Event) => void) | undefinedEvent handler called when the checked state changes.
disabledbooleanfalseWhether the control ignores user interaction.
requiredboolean
namestring | undefined
valuestring | undefinedControlled value.
childrenSnippet<[{ checked: boolean; disabled: boolean }]>Content rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-indeterminatePresent when the checkbox is indeterminate.
data-uncheckedPresent when the part is unchecked.

Checkbox.Indicator

Extends span HTML attributes.

PropertyTypeDefaultDescription
childrenSnippetContent rendered inside the part.
Data attributeDescription
data-checkedPresent when the part is checked.
data-disabledPresent when the part is disabled.
data-indeterminatePresent when the checkbox is indeterminate.
data-uncheckedPresent when the part is unchecked.