Collapsible
A single panel that expands and collapses. The trigger shows a chevron that turns when the panel opens, and the content lines up with the trigger's label.
- collapsible-trigger.svelte
- collapsible-content.svelte
- manifest.ts
- +page.svelte
Installation
Copy the command below and run it in your terminal.
Usage
Bind open to read or set the state. It
starts as false. Set disabled on Root to disable the trigger.
Trigger renders its own chevron and fills the width of its container. Content is
indented to the trigger label and styled as supporting text, so pass plain text or your
own markup without adding padding. Root renders no element, so wrap it in a div when a list needs dividers or spacing between items.
Examples
Settings
FAQ list
Disabled
Anatomy
Collapsible.Root - Controls collapsible content state.
Collapsible.Trigger - Toggles the content.
Collapsible.Content - Contains collapsible content.
<script lang="ts"> import * as Collapsible from '@sivir-ui/svelte/components/collapsible'; const files = [ 'collapsible-trigger.svelte', 'collapsible-content.svelte', 'manifest.ts', '+page.svelte' ]; </script> <div class="w-full max-w-md"> <Collapsible.Root open> <Collapsible.Trigger>{files.length} files changed</Collapsible.Trigger> <Collapsible.Content> <ul class="m-0 flex list-none flex-col gap-1.5 p-0"> {#each files as file (file)} <li class="truncate font-mono text-[0.875em] text-foreground">{file}</li> {/each} </ul> </Collapsible.Content> </Collapsible.Root> </div>