SpecOS SpecOS icon Styleguide

Collapsible

A vertically collapsible component that expands downward.

Import

import Collapsible from "$lib/components/Collapsible.svelte";

Basic Example

Repositories

<Collapsible title="Repositories">
    <div class="rounded-md bg-background-alt p-4">
        Repository 1
    </div>
    <div class="rounded-md bg-background-alt p-4">
        Repository 2
    </div>
</Collapsible>

Styled Example

Custom Styled Collapsible

<Collapsible 
    title="Custom Styled Collapsible" 
    trigger_class="bg-texas-rose-500 text-white hover:bg-texas-rose-600"
    content_class="bg-background-alt rounded-md p-4"
>
    <div class="space-y-2">
        <p>Custom content here</p>
        <p>More content here</p>
    </div>
</Collapsible>

Clickable Items Example

Clickable Items

<Collapsible title="Clickable Items">
    <div 
        class="rounded-md bg-background-alt p-4 cursor-pointer transition-colors hover:bg-background-hover"
        on:click={() => alert('Clicked Repository 1')}
    >
        Repository 1
    </div>
    <div 
        class="rounded-md bg-background-alt p-4 cursor-pointer transition-colors hover:bg-background-hover"
        on:click={() => alert('Clicked Repository 2')}
    >
        Repository 2
    </div>
</Collapsible>

Properties

title
Type
string
Default: undefined
The title text shown in the header.
class_name
Type
string
Default: ""
Additional classes for the root element.
trigger_class
Type
string
Default: ""
Additional classes for the trigger button.
content_class
Type
string
Default: ""
Additional classes for the content container.