Forms

CheckboxGroup

A group of checkboxes for multi-select. Supports list/card variants, horizontal/vertical orientation, legend, descriptions, and controlled state with bind:value.

Playground

Experiment with different props in real-time.

Choose fruits

Selected: none

Basic Usage

Pass an array of items and use bind:value for the selected values.

<script lang="ts">
  import { CheckboxGroup } from 'sv5ui';

  let value = $state<string[]>([]);

  const items = [
    { value: 'apple', label: 'Apple' },
    { value: 'banana', label: 'Banana' },
    { value: 'orange', label: 'Orange' }
  ];
</script>

<CheckboxGroup {items} bind:value />

With Legend & Description

Add a legend and per-item description.

Notification preferences

Receive notifications via email

Receive notifications via text message

Receive push notifications on your device

<CheckboxGroup
  legend="Notification preferences"
  items={[
    { value: 'email', label: 'Email', description: 'Receive notifications via email' },
    { value: 'sms', label: 'SMS', description: 'Receive notifications via text message' },
    { value: 'push', label: 'Push', description: 'Receive push notifications on your device' }
  ]}
  bind:value
/>

Variants

2 visual styles.

List
Card
Apple
Banana
Orange
<!-- List variant (default) -->
<CheckboxGroup variant="list" legend="List" {items} />

<!-- Card variant -->
<CheckboxGroup variant="card" legend="Card" {items} />

Indicator Position

Control where the checkbox indicator appears.

Start
End
Hidden
<CheckboxGroup indicator="start" legend="Start" {items} />
<CheckboxGroup indicator="end" legend="End" {items} />
<CheckboxGroup indicator="hidden" legend="Hidden" {items} />

Orientation

Vertical or horizontal layout.

Vertical
Horizontal
<!-- Vertical (default) -->
<CheckboxGroup orientation="vertical" {items} />

<!-- Horizontal -->
<CheckboxGroup orientation="horizontal" {items} />

Sizes

5 sizes.

XS
SM
MD
LG
XL
<CheckboxGroup size="xs" legend="Extra Small" {items} />
<CheckboxGroup size="sm" legend="Small" {items} />
<CheckboxGroup size="md" legend="Medium" {items} />
<CheckboxGroup size="lg" legend="Large" {items} />
<CheckboxGroup size="xl" legend="Extra Large" {items} />

Colors

8 semantic color schemes.

Primary
Success
Warning
Error
<CheckboxGroup color="primary" {items} value={['apple']} />
<CheckboxGroup color="success" {items} value={['apple']} />
<CheckboxGroup color="warning" {items} value={['apple']} />
<CheckboxGroup color="error" {items} value={['apple']} />

Disabled

Disable the entire group or individual items.

All disabled
Individual disabled
<!-- Disable entire group -->
<CheckboxGroup disabled {items} />

<!-- Disable individual items -->
<CheckboxGroup items={[
  { value: 'active', label: 'Active option' },
  { value: 'disabled', label: 'Disabled option', disabled: true },
  { value: 'another', label: 'Another active option' }
]} />

Loading

Show spinner and disable interaction.

<CheckboxGroup loading {items} />

Custom Icon

Replace the default check icon.

<CheckboxGroup icon="lucide:heart" color="error" {items} value={['apple', 'banana']} />

Controlled

Use bind:value for two-way binding.

Receive notifications via email

Receive notifications via text message

Receive push notifications on your device

Selected: email

<script lang="ts">
  import { CheckboxGroup } from 'sv5ui';

  let value = $state(['email']);

  const items = [
    { value: 'email', label: 'Email' },
    { value: 'sms', label: 'SMS' },
    { value: 'push', label: 'Push' }
  ];
</script>

<CheckboxGroup {items} bind:value />
<p>Selected: {value.join(', ') || 'none'}</p>

Card Grid

Combine card variant with horizontal orientation for a grid selection layout.

Choose your plan
Free

5GB storage

Pro

50GB storage

Team

Unlimited

<CheckboxGroup
  variant="card"
  orientation="horizontal"
  legend="Choose your plan"
  items={[
    { value: 'free', label: 'Free', description: '5GB storage' },
    { value: 'pro', label: 'Pro', description: '50GB storage' },
    { value: 'team', label: 'Team', description: 'Unlimited' }
  ]}
  bind:value
/>

UI Slots

Use the ui prop to override classes on internal elements.

SlotDescription
rootOutermost wrapper
fieldsetMain container for all items
legendLegend text above the group
itemEach individual checkbox item container
baseThe checkbox box itself
containerVisual box holding the indicator
indicatorInner element shown when checked
iconIcon inside the indicator
wrapperWraps label and description text
labelPrimary text label
descriptionSecondary helper text

Snippets

SnippetDescription
legendSlotCustom legend rendering
labelSlotCustom label for each item
descriptionSlotCustom description for each item

Props

PropTypeDefault
itemsCheckboxGroupItem[]-
valuestring[][]
onValueChange(value) => void-
variant'list' | 'card''list'
indicator'start' | 'end' | 'hidden''start'
orientation'vertical' | 'horizontal''vertical'
colorColorType'primary'
size'xs' | 'sm' | 'md' | 'lg' | 'xl''md'
legendstring-
iconstring'lucide:check'
loadingbooleanfalse
loadingIconstringicons.loading
disabledbooleanfalse
requiredbooleanfalse
namestring-
idstring-
refHTMLElement | nullnull
classstring-
uiRecord<Slot, Class>-

Item Props

PropTypeDefault
valuestring-
labelstring-
descriptionstring-
disabledbooleanfalse