Forms

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.

SlotDescription
rootOutermost wrapper element — controls overall layout and spacing
baseClickable checkbox area — controls focus ring, cursor, transitions
containerVisual box that holds the indicator — controls border, background, rounding
indicatorInner element shown when checked — controls check/indeterminate styling
iconThe icon inside the indicator — controls icon size and color
wrapperWraps label and description text — controls text layout
labelPrimary text label — controls font size, weight, color
descriptionSecondary helper text below label — controls font size and opacity

Snippets

Use snippets to customize label and description rendering.

SnippetArgsDescription
labelSlot{ label }Custom label rendering
descriptionSlot{ description }Custom description rendering

Props

PropTypeDefault
checkedbooleanfalse
onCheckedChange(checked: boolean) => void-
indeterminatebooleanfalse
onIndeterminateChange(indeterminate: boolean) => void-
colorColor'primary'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
loadingbooleanfalse
loadingIconstringicons.loading
iconstring'lucide:check'
indeterminateIconstring'lucide:minus'
labelstring-
descriptionstring-
idstring-
namestring-
valuestring-
disabledbooleanfalse
requiredbooleanfalse
classstring-
uiRecord<Slot, Class>-