skip section navigation

Checklist

Checklist turns independent choices into native checkboxes with one legend. use it for a packing list, ingredients or the small tasks before publishing a reading collection.

Before you share the collection 0 / 3

usage

svelte
<script>
	import { Checklist } from '@ciabi/loafkit-ui';
	let done = $state([]);
	const items = [
		{ id: 'titles', label: 'Check the article titles' },
		{ id: 'links', label: 'Open each saved link', description: 'Catch moved pages before you share.' },
		{ id: 'intro', label: 'Add a short introduction' }
	];
</script>

<Checklist legend="Before you share the collection" {items} bind:value={done} summary name="ready" />

composition

  • Checklist
    • items
      • content()(optional)

data and value

keep extra item content passive because it is rendered inside the checkbox label.

name is shared by the checkbox inputs, so native FormData contains one entry per checked ID. an item’s required means that particular checkbox must be checked, not that the group needs at least one choice. implement a group rule in your form logic if that’s the task.

submit the checked item IDs

review before sharing 0 / 3
svelte
<script lang="ts">
import { Checklist } from '@ciabi/loafkit-ui';
let reviewChecks = $state<string[]>([]);
let reviewSubmitted = $state('');
</script>

{#snippet reviewHint()}<small>check the original page, not just its saved title.</small>{/snippet}
<form onsubmit={event => {
	event.preventDefault();
	reviewSubmitted = new FormData(event.currentTarget).getAll('review').join(', ') || 'none';
}}>
	<Checklist legend="review before sharing" name="review" bind:value={reviewChecks} summary items={[
		{id:'links',label:'open every link',required:true,content:reviewHint},
		{id:'intro',label:'add an introduction'},
		{id:'publish',label:'publish after review',disabled:true}
	]} />
	<button type="submit">check submission</button>
</form>
{#if reviewSubmitted}<p role="status">submitted review IDs: {reviewSubmitted}</p>{/if}

API reference

Checklist

Component
items

the checkbox definitions.

value
Default: []

selected item IDs.

name

shared checkbox name; each checked input submits its item ID.

legend

the fieldset’s visible group name.

summary
Default: false

shows a live count of completed items.

onValueChange

called with the updated value.

style

inline styles on the fieldset.

class
Default: ''

extra classes on the fieldset.

ChecklistItem

Type

one item in Checklist.items.

id

unique item ID, also used as its submitted value.

label

the checkbox label.

description

supporting text within the label.

disabled

makes this checkbox unavailable.

required

requires this specific checkbox, not one choice from the group.

content

extra passive content inside the label.