Kumo Svelte
  • Home
  • Installation
  • Colors
  • Accessibility
  • Changelog
  • Autocomplete
  • Badge
  • Banner
  • Breadcrumbs
  • Button
  • Checkbox
  • Clipboard Text
  • Cloudflare Logo
  • CodeHighlighted
  • Collapsible
  • Combobox
  • Command Palette
  • Date Picker
  • Dialog
  • Dropdown
  • Empty
  • Flow
  • Grid
  • Input
  • InputArea
  • InputGroup
  • Label
  • Layer Card
  • Link
  • Loader
  • MenuBar
  • Meter
  • Pagination
  • Popover
  • Radio
  • Select
  • Sensitive Input
  • Sidebar
  • Skeleton Line
  • Switch
  • Table
  • Table of Contents
  • Tabs
  • Text
  • Toast
  • Toolbar
  • Tooltip
  • Charts
  • Colors
  • Timeseries
  • Maps
  • Sankey
  • Custom Chart
  • Page Header
  • Resource List
  • Delete Resource
Checkbox
kumo-svelte

Checkbox

A control that allows the user to toggle between checked and not checked.

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
  let checked = $state(false);
</script>

<Checkbox label="Accept terms and conditions" bind:checked />

Import

Single checkbox:

import { Checkbox } from "kumo-svelte/components/checkbox";

Checkbox group:

import * as Checkbox from "kumo-svelte/components/checkbox";

Usage

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
</script>

<Checkbox label="Accept terms" />

Examples

Default

Checkbox with a built-in label. The component automatically displays it in a horizontal layout with the checkbox before the label.

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
  let checked = $state(false);
</script>

<Checkbox label="Enable notifications" bind:checked />

Checked

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
  let checked = $state(true);
</script>

<Checkbox label="I agree" bind:checked />

Indeterminate

Used for select-all patterns when some but not all items are selected.

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
  let indeterminate = $state(true);
</script>

<Checkbox label="Select all" bind:indeterminate />

Label First Layout

Use controlFirst={false} to place the label before the checkbox.

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
  let checked = $state(false);
</script>

<Checkbox label="Remember me" controlFirst={false} bind:checked />

Disabled

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
</script>

<Checkbox label="Disabled option" disabled />

Error

Error variant provides visual styling. For error messages, use Checkbox.Group.

<script lang="ts">
  import { Checkbox } from "kumo-svelte/components/checkbox";
</script>

<Checkbox label="Invalid option" variant="error" />

Checkbox Group

Group multiple checkboxes with a legend, description, and shared error messages. Use Checkbox.Group and Checkbox.Item.

Email preferences

Choose how you'd like to receive updates

<script lang="ts">
  import * as Checkbox from "kumo-svelte/components/checkbox";
  let preferences = $state(["email"]);
</script>

<Checkbox.Group
  legend="Email preferences"
  description="Choose how you'd like to receive updates"
  bind:value={preferences}
>
  <Checkbox.Item value="email" label="Email notifications" />
  <Checkbox.Item value="sms" label="SMS notifications" />
  <Checkbox.Item value="push" label="Push notifications" />
</Checkbox.Group>

Checkbox Group with Error

Show validation errors at the group level.

Required preferences

Please select at least one notification method

<script lang="ts">
  import * as Checkbox from "kumo-svelte/components/checkbox";
  let preferences = $state<string[]>([]);
</script>

<Checkbox.Group
  legend="Required preferences"
  error="Please select at least one notification method"
  bind:value={preferences}
>
  <Checkbox.Item value="email" label="Email" variant="error" />
  <Checkbox.Item value="sms" label="SMS" variant="error" />
</Checkbox.Group>

Visually Hidden Legend

Use Checkbox.Legend with class="sr-only" to keep the legend accessible to screen readers while hiding it visually. This is useful when the group is already labeled by a parent Field or heading.

Notification preferences
<script lang="ts">
  import * as Checkbox from "kumo-svelte/components/checkbox";
  let preferences = $state(["email"]);
</script>

<Checkbox.Group bind:value={preferences}>
  <Checkbox.Legend class="sr-only">Notification preferences</Checkbox.Legend>
  <Checkbox.Item value="email" label="Email notifications" />
  <Checkbox.Item value="sms" label="SMS notifications" />
  <Checkbox.Item value="push" label="Push notifications" />
</Checkbox.Group>

Custom Legend Styling

Checkbox.Legend accepts class for full control over legend presentation. Use it instead of the legend string prop when you need custom typography, colors, or layout.

Notification preferences
<script lang="ts">
  import * as Checkbox from "kumo-svelte/components/checkbox";
  let preferences = $state(["email"]);
</script>

<Checkbox.Group bind:value={preferences}>
  <Checkbox.Legend class="text-sm font-normal text-kumo-subtle">
    Notification preferences
  </Checkbox.Legend>
  <Checkbox.Item value="email" label="Email notifications" />
  <Checkbox.Item value="sms" label="SMS notifications" />
  <Checkbox.Item value="push" label="Push notifications" />
</Checkbox.Group>

API Reference

Checkbox

PropTypeDefault
variantCheckboxVariantKUMO_CHECKBOX_DEFAULT_VARIANTS.variant
labelSnippet | string—
labelTooltipSnippet—
controlFirstbooleantrue
checkedbooleanfalse
indeterminatebooleanfalse
disabledbooleanfalse
onCheckedChange(checked: boolean) => void—
namestring—
valuestring—
requiredboolean—
classstring—
idstring—
aria-labelstring—
aria-labelledbystring—

Checkbox.Group

PropTypeDefault
legendstring—
children*Snippet—
errorstring—
descriptionSnippet | string—
defaultValuestring[][]
valuestring[]defaultValue
onValueChange(value: string[]) => void—
allValuesstring[]—
disabledbooleanfalse
controlFirstbooleantrue
classstring—
namestring—
requiredboolean—
idstring—

Checkbox.Item

PropTypeDefault
variantCheckboxVariantKUMO_CHECKBOX_DEFAULT_VARIANTS.variant
label*Snippet | string—
valuestring—
classstring—
checkedbooleanfalse
indeterminatebooleanfalse
disabledbooleanfalse
onCheckedChange(checked: boolean) => void—
namestring—
idstring—
aria-labelstring—
aria-labelledbystring—

Checkbox.Legend

PropTypeDefault
children*Snippet—
classstring—

Accessibility

Label Requirement

Single checkboxes require a label prop or aria-label for accessibility.

Keyboard Navigation

Space toggles the checkbox. Tab moves focus between checkboxes.

Screen Readers

Checkbox.Group uses semantic <fieldset> and <legend> elements for proper grouping announcement.

On this page

  • Import
  • Usage
  • Examples
    • Default
    • Checked
    • Indeterminate
    • Label First Layout
    • Disabled
    • Error
    • Checkbox Group
    • Checkbox Group with Error
    • Visually Hidden Legend
    • Custom Legend Styling
  • API Reference
    • Checkbox
    • Checkbox.Group
    • Checkbox.Item
    • Checkbox.Legend
  • Accessibility
    • Label Requirement
    • Keyboard Navigation
    • Screen Readers