Documentation Upgrade
Start here
CwSwitch is a checkbox-based on/off control. Treat it as a boolean field with optional helper text, then use `oninput` or `onchange` only when the parent needs side effects.
Copy-paste examples
These snippets intentionally show the full public API surface the live demo relies on.
Bound settings switch
This is the normal settings-page usage.
<script lang="ts">
let onlineOnly = $state(true);
</script>
<CwSwitch
label="Show only online devices"
description="Hide offline sensors from the dashboard"
name="onlineOnly"
bind:checked={onlineOnly}
/>
Input and change callbacks
Use callbacks when turning the switch should trigger side effects immediately.
<CwSwitch
id="sms-alerts"
label="SMS alerts"
oninput={(checked) => console.log('input', checked)}
onchange={(checked) => savePreference('smsAlerts', checked)}
/>