coss.com Svelte

Checkbox

A control allowing the user to toggle between checked and not checked.

API Reference
Loading p-checkbox-1 preview…

Installation

pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/checkbox.json

Usage

<script lang="ts">
  import { Checkbox } from "$lib/components/ui/checkbox/index.js";
</script>

<Checkbox aria-label="Accept terms" />

API Reference

Checkbox

Checkbox includes the COSS check and indeterminate indicators. Use checked for an initial value or bind:checked for controlled state. Native form props and onCheckedChange pass to the Shards root.

See the Shards Checkbox API for form, validation, and state props.

Examples

For accessible labelling and validation, prefer using the Field component to wrap checkboxes. See the related example: Checkbox field.

Disabled

Loading p-checkbox-2 preview…

With Description

Loading p-checkbox-3 preview…

Card Style

Loading p-checkbox-4 preview…

Form Integration

Field provides accessible labelling and validation primitives for form controls. Use it with Form to submit values.

Loading p-checkbox-5 preview…