Simple expandable section
Use this for FAQs, advanced settings, and details panels.
<CwExpandPanel title="Sensor configuration" open>
<p>Configure thresholds, calibration offsets, and reporting intervals.</p>
</CwExpandPanel>Collapsible panel with animated expand / collapse. Supports custom headers, bindable state, and disabled mode.
<CwExpandPanel title="Sensor Configuration" open>
<p>Configure thresholds and reporting intervals.</p>
</CwExpandPanel>Panel is open —
Last toggle: —
CwExpandPanel is a collapsible section for settings, troubleshooting details, and optional content. Use the built-in title for simple cases and the `header` snippet when the trigger needs richer status UI.
| API | Type | Details |
|---|---|---|
title Default: | string | Simple header text. |
open Default: | boolean | Expanded or collapsed state. |
disabled Default: | boolean | Prevents toggling. |
header | Snippet<[boolean]> | Custom header snippet receiving the current `open` state. |
children | Snippet | Panel body content. |
onToggle | (open: boolean) => void | Runs after the panel is toggled. |
These snippets intentionally show the full public API surface the live demo relies on.
Use this for FAQs, advanced settings, and details panels.
<CwExpandPanel title="Sensor configuration" open>
<p>Configure thresholds, calibration offsets, and reporting intervals.</p>
</CwExpandPanel>Bind the state when other controls need to open or close the panel.
<script lang="ts">
let expanded = $state(false);
let lastToggle = $state('Never');
</script>
<CwButton variant="secondary" onclick={() => (expanded = !expanded)}>
Toggle panel externally
</CwButton>
<CwExpandPanel bind:open={expanded} onToggle={(open) => (lastToggle = open ? 'Opened' : 'Closed')}>
{#snippet header(open)}
<div style="display:flex;gap:0.5rem;align-items:center">
<strong>Irrigation controller</strong>
<span>{open ? 'Expanded' : 'Collapsed'}</span>
</div>
{/snippet}
<p>Last toggle: {lastToggle}</p>
</CwExpandPanel>