Checkbox
A customizable checkbox component that supports different states, sizes, and styles.
Import
import Checkbox from "$lib/components/Checkbox.svelte"; Basic Checkbox
Value: false
let isChecked = false;
<Checkbox
bind:checked={isChecked}
label="Accept terms and conditions"
/>
<p>Value: {isChecked}</p>Custom Style
<Checkbox label="Custom Style" class_name="rounded-full bg-texas-rose-500" size="size-8" />
Indeterminate State
<Checkbox checked="indeterminate" label="Indeterminate State" />
Disabled State
<Checkbox disabled label="Disabled Checkbox" />
Properties
Name
Type
Description
checked
Type
boolean | "indeterminate"
Default: false
The checked state of the checkbox. Can be bound using bind:checked.
disabled
Type
boolean
Default: false
Whether the checkbox is disabled.
label
Type
string
Default: undefined
Optional label text for the checkbox.
class_name
Type
string
Default: ""
Classes to apply to the checkbox root.
label_class
Type
string
Default: ""
Classes to apply to the label.
size
Type
string
Default: "size-[25px]"
Size class for the checkbox.
icon_size
Type
string
Default: "size-[15px]"
Size class for the checkbox icon.