Checkbox
Toggle a boolean value on or off. Checkboxes support labels, descriptions, colors, sizes, indeterminate state, loading indicators, and custom icons.
Playground
Experiment with different props in real-time.
Basic Usage
Import and use the Checkbox component with bind:checked for two-way binding.
<script lang="ts">
import { Checkbox } from 'sv5ui';
let checked = $state(false);
</script>
<Checkbox bind:checked />With Label & Description
Add a label and optional description for context.
You agree to our Terms of Service and Privacy Policy.
<Checkbox
label="Accept terms"
description="You agree to our Terms of Service and Privacy Policy."
bind:checked
/>Sizes
5 sizes from extra small to extra large.
<Checkbox size="xs" label="Extra Small" />
<Checkbox size="sm" label="Small" />
<Checkbox size="md" label="Medium" />
<Checkbox size="lg" label="Large" />
<Checkbox size="xl" label="Extra Large" />Colors
8 semantic color schemes applied when the checkbox is checked.
<Checkbox color="primary" label="Primary" checked />
<Checkbox color="secondary" label="Secondary" checked />
<Checkbox color="tertiary" label="Tertiary" checked />
<Checkbox color="success" label="Success" checked />
<Checkbox color="warning" label="Warning" checked />
<Checkbox color="error" label="Error" checked />
<Checkbox color="info" label="Info" checked />
<Checkbox color="surface" label="Surface" checked />Indeterminate
Use the indeterminate prop for a partial-selection state, useful for "select all" patterns.
<script lang="ts">
import { Checkbox } from 'sv5ui';
let parentChecked = $state(false);
let indeterminate = $state(true);
</script>
<Checkbox
label="Select all"
bind:checked={parentChecked}
bind:indeterminate
/>Loading
Display a loading spinner while an async operation completes.
<Checkbox loading label="Loading" />
<Checkbox loading checked label="Loading checked" />Disabled
Prevent user interaction with the disabled prop.
<Checkbox disabled label="Disabled" />
<Checkbox disabled checked label="Disabled checked" />Custom Icon
Replace the default check icon with any Iconify icon using the icon prop.
<Checkbox
icon="lucide:heart"
indeterminateIcon="lucide:circle-help"
label="Favorite"
checked
/>
<Checkbox
icon="lucide:star"
label="Starred"
checked
/>UI Slots
Use the ui prop to override classes on specific internal elements of the Checkbox.
| Slot | Description |
|---|---|
root | Outermost wrapper element — controls overall layout and spacing |
base | Clickable checkbox area — controls focus ring, cursor, transitions |
container | Visual box that holds the indicator — controls border, background, rounding |
indicator | Inner element shown when checked — controls check/indeterminate styling |
icon | The icon inside the indicator — controls icon size and color |
wrapper | Wraps label and description text — controls text layout |
label | Primary text label — controls font size, weight, color |
description | Secondary helper text below label — controls font size and opacity |
Snippets
Use snippets to customize label and description rendering.
| Snippet | Args | Description |
|---|---|---|
labelSlot | { label } | Custom label rendering |
descriptionSlot | { description } | Custom description rendering |
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked | boolean | false | |
onCheckedChange | (checked: boolean) => void | - | |
indeterminate | boolean | false | |
onIndeterminateChange | (indeterminate: boolean) => void | - | |
color | Color | 'primary' | |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | |
loading | boolean | false | |
loadingIcon | string | icons.loading | |
icon | string | 'lucide:check' | |
indeterminateIcon | string | 'lucide:minus' | |
label | string | - | |
description | string | - | |
id | string | - | |
name | string | - | |
value | string | - | |
disabled | boolean | false | |
required | boolean | false | |
class | string | - | |
ui | Record<Slot, Class> | - |