Skip to content

Router that virtually distributes inference across connected devices in the home.

Go
2.6 KB
Raw Blame

Collapsible

A utility component that allows you to collapse and expand content.

Examples

Basic Collapsible

Use when content should be hidden by default to reduce visual noise but available on demand.

<Collapsible slotTrigger="Trigger content">Hidden content revealed on expand.</Collapsible>

Default Open Collapsible

<Collapsible defaultOpen slotTrigger="Hide details">
    Content visible by default.
</Collapsible>

With Icon In Trigger

<Collapsible
    slotTrigger={
        <span className="inline-flex items-center gap-2">
            <ChevronDown />
            Header
        </span>
    }
>
    Content
</Collapsible>

With Chevron Trigger

The AnimatedChevron component automatically reads the open/closed state from Collapsible.

<Collapsible
    slotTrigger={
        <>
            <AnimatedChevron /> Toggle content
        </>
    }
>
    Content
</Collapsible>

With Button Trigger

When using a Button in slotTrigger with asChild, render it as a non-interactive element like

or to avoid nested interactive elements, allowing the native element to handle the toggle behavior.

<Collapsible
    slotTrigger={
        <Button asChild kind="tertiary">
            <div>Toggle content</div>
        </Button>
    }
>
    Content
</Collapsible>

Composed

Use composed primitives when you want to render the trigger and content apart from each other.

<CollapsibleRoot defaultOpen>
    <CollapsibleTrigger>
        <Button asChild kind="tertiary">
            <div>
                Toggle content
                <AnimatedChevron />
            </div>
        </Button>
    </CollapsibleTrigger>
    <CollapsibleContent>Additional content - visible by default.</CollapsibleContent>
</CollapsibleRoot>

Props

Prop Type Default Description
children * ReactNode - The collapsible content
slotTrigger * ReactNode - The collapsible trigger
defaultOpen boolean -
disabled boolean -
onOpenChange (open: boolean) => void -
open boolean -

* = required prop