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
Represents the checkbox itself. Renders a <span> element and a hidden <input> beside.
Props
checked boolean undefined
- Name
checked- Description
Controlled checked state.
- Type
boolean | undefined- Default
undefined
defaultChecked boolean false
- Name
defaultChecked- Description
Uncontrolled initial checked state.
- Type
boolean- Default
false
onCheckedChange function —
- Name
onCheckedChange- Description
Event handler called when the checked state changes.
- Type
((checked: boolean, event: Event) => void) | undefined
disabled boolean false
- Name
disabled- Description
Whether the control ignores user interaction.
- Type
boolean- Default
false
required boolean false
- Name
required- Description
Whether the user must tick the checkbox before submitting a form.
- Type
boolean- Default
false
readOnly boolean false
- Name
readOnly- Description
Whether the user should be unable to tick or untick the checkbox.
- Type
boolean- Default
false
name string undefined
- Name
name- Description
Identifies the field when a form is submitted.
- Type
string | undefined- Default
undefined
uncheckedValue string —
- Name
uncheckedValue- Description
Submitted when the checkbox is unchecked (native form pattern).
- Type
string | undefined
form string —
- Name
form- Description
Form id association for the hidden input.
- Type
string | undefined
indeterminate boolean false
- Name
indeterminate- Description
Whether the checkbox is in a mixed state: neither ticked, nor unticked.
- Type
boolean- Default
false
Data attributes
| Attribute | Description |
|---|---|
data-checked | Present when the checkbox is checked. |
data-disabled | Present when the checkbox is disabled. |
data-indeterminate | Present when the checkbox is in an indeterminate state. |
data-readonly | Present when the checkbox is readonly. |
data-unchecked | Present when the checkbox is not checked. |
Checkbox.Indicator
Indicates whether the checkbox is ticked. Renders a <span> element.
Props
keepMounted boolean false
- Name
keepMounted- Description
Whether to keep the element in the DOM when the checkbox is not checked.
- Type
boolean- Default
false
Data attributes
| Attribute | Description |
|---|---|
data-checked | Present when the checkbox is checked. |
data-disabled | Present when the checkbox is disabled. |
data-indeterminate | Present when the checkbox is in an indeterminate state. |
data-unchecked | Present when the checkbox is not checked. |