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.
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.
<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 variant (default) -->
<CheckboxGroup variant="list" legend="List" {items} />
<!-- Card variant -->
<CheckboxGroup variant="card" legend="Card" {items} />Indicator Position
Control where the checkbox indicator appears.
<CheckboxGroup indicator="start" legend="Start" {items} />
<CheckboxGroup indicator="end" legend="End" {items} />
<CheckboxGroup indicator="hidden" legend="Hidden" {items} />Orientation
Vertical or horizontal layout.
<!-- Vertical (default) -->
<CheckboxGroup orientation="vertical" {items} />
<!-- Horizontal -->
<CheckboxGroup orientation="horizontal" {items} />Sizes
5 sizes.
<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.
<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.
<!-- 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.
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.
<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.
| Slot | Description |
|---|---|
root | Outermost wrapper |
fieldset | Main container for all items |
legend | Legend text above the group |
item | Each individual checkbox item container |
base | The checkbox box itself |
container | Visual box holding the indicator |
indicator | Inner element shown when checked |
icon | Icon inside the indicator |
wrapper | Wraps label and description text |
label | Primary text label |
description | Secondary helper text |
Snippets
| Snippet | Description |
|---|---|
legendSlot | Custom legend rendering |
labelSlot | Custom label for each item |
descriptionSlot | Custom description for each item |
Props
| Prop | Type | Default |
|---|---|---|
items | CheckboxGroupItem[] | - |
value | string[] | [] |
onValueChange | (value) => void | - |
variant | 'list' | 'card' | 'list' |
indicator | 'start' | 'end' | 'hidden' | 'start' |
orientation | 'vertical' | 'horizontal' | 'vertical' |
color | ColorType | 'primary' |
size | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
legend | string | - |
icon | string | 'lucide:check' |
loading | boolean | false |
loadingIcon | string | icons.loading |
disabled | boolean | false |
required | boolean | false |
name | string | - |
id | string | - |
ref | HTMLElement | null | null |
class | string | - |
ui | Record<Slot, Class> | - |
Item Props
| Prop | Type | Default |
|---|---|---|
value | string | - |
label | string | - |
description | string | - |
disabled | boolean | false |