Forms Core Stable

Checkbox

A tri-look checkbox — unchecked, checked, indeterminate and disabled — built on a native checkbox input

Preview

Installation

pnpm add fancy-ui-svelte
import { Checkbox } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Checkbox } from 'fancy-ui-svelte';
</script>

<Checkbox />

Examples

Basic Usage

A single checkbox with a bound checked state.

States

Unchecked, checked, indeterminate and disabled, side by side.

Indeterminate

A parent checkbox reflecting a mixed selection of children.

With FormField

Wrapped in FormField — no id or invalid prop needed on Checkbox itself.

Props

PropTypeDefaultDescription
checked booleanfalseWhether the box is checked; bindable
indeterminate booleanfalseMixed/dash visual state; bindable
onCheckedChange (checked: boolean) => void-Called with the new checked value whenever the box is activated
disabled booleanfalseBlocks interaction; excluded from form submission
required booleanfalseNative required
invalid booleanfalseDrives the error border and aria-invalid
id string-Element id
name string-Native name, read on form submission
value string-Form value submitted while checked
label string-Accessible name, rendered as aria-label; skip it when children already supplies the visible label text
class string-Additional CSS classes, merged onto the wrapping label
ref HTMLInputElement | nullnullBindable element reference to the native input
sound booleanfalsePlays toggle-on or toggle-off on each change, once the user has enabled sound

Slots

SlotDescription
childrenVisible label text, rendered beside the box