Collapsible
A single section that expands to reveal content.
import { Collapsible } from '@elluzion/iv-ui'; 01 Preview
Basic
A titled section that starts closed.
Source· svelte Show Hide
<script lang="ts">
import { Collapsible } from '@elluzion/iv-ui';
</script>
<Collapsible title="Request headers">
<pre class="code">accept: application/json
x-request-id: 8f2c1a</pre>
</Collapsible>
<style>
.code {
margin: 0;
font-family: var(--iv_font-mono);
font-size: var(--iv_text-sm);
color: var(--iv_foreground-dim);
}
</style>02 Usage
- Use for one-off disclosure; use
Accordionwhen sections form a set. openis bindable;defaultOpensets the uncontrolled initial state.triggerreplaces the default title and chevron content.
03 Examples
Controlled
Bind open and drive it from outside the component.
Source· svelte Show Hide
<script lang="ts">
import { Button, Collapsible } from '@elluzion/iv-ui';
let open = $state(false);
</script>
<div class="stack">
<Collapsible title="Advanced options" bind:open>
<p>Timeout, retry budget, and the cache policy for this route.</p>
</Collapsible>
<div class="row">
<Button size="sm" variant="outline" onclick={() => (open = true)}>Open</Button>
<Button size="sm" variant="ghost" onclick={() => (open = false)}>Close</Button>
</div>
</div>
<style>
.stack {
display: flex;
flex-direction: column;
gap: var(--iv_spacing-md);
}
.row {
display: flex;
gap: var(--iv_spacing-sm);
}
</style>Custom trigger
The trigger snippet replaces the title with custom content.
Open the command palette with the shortcut shown above.
Source· svelte Show Hide
<script lang="ts">
import { IconTerminal2 } from '@tabler/icons-svelte';
import { Collapsible, Shortcut } from '@elluzion/iv-ui';
</script>
<Collapsible defaultOpen>
{#snippet trigger()}
<span class="trigger">
<IconTerminal2 size={14} />
Console
<Shortcut keys={['⌘', 'K']} />
</span>
{/snippet}
<p>Open the command palette with the shortcut shown above.</p>
</Collapsible>
<style>
.trigger {
display: inline-flex;
align-items: center;
gap: var(--iv_spacing-sm);
}
</style>04 API
import { Collapsible } from '@elluzion/iv-ui';Props
5 props · 1 events · 2 snippets| Prop | Type | Default | Description |
|---|---|---|---|
| title | string | '' | Trigger text. |
| open bindable | boolean | — | Open state. Bind with bind:open. |
| defaultOpen | boolean | false | Open on first render when uncontrolled. |
| disabled | boolean | false | Disables interaction and applies the disabled treatment. |
| className | string | '' | Extra classes merged onto the root element. |
class, id, style, aria-*, and data-* are forwarded through rest props.
Events
| Event | Handler type | Description |
|---|---|---|
| onchange | (e: CustomEvent<{ open: boolean }>) => void | Called with { open } after the panel toggles. |
The legacy on:name form is accepted for every event.
Snippets
| Snippet | Type | Description |
|---|---|---|
| trigger | Snippet | Custom trigger content. |
| children | Snippet | Content rendered inside the component. |
05 Accessibility
| Keys | Action |
|---|---|
| Tab | Moves focus to the trigger. |
| Enter / Space | Opens or closes the section. |
- The trigger is a native button with
aria-expandedandaria-controls. - The panel uses
role="region"and is labelled by the trigger. - Animation is skipped when reduced motion is requested.
06 Tokens & CSS hooks
Tokens used
Class hooks
.iv-chevron.iv-collapsible.iv-open.iv-panel.iv-trigger.iv-trigger-label