Collapsible

An interactive component that expands and collapses content sections.

Anatomy

<script>
  import {
    Collapsible,
    CollapsibleTrigger,
    CollapsibleContent,
    CollapsibleIndicator,
  } from "@saas-ui/svelte/components/collapsible";
</script>

<Collapsible.Root>
  <Collapsible.Trigger>
    Toggle Content
    <Collapsible.Indicator />
  </Collapsible.Trigger>
  <Collapsible.Content>
    Collapsible content goes here...
  </Collapsible.Content>
</Collapsible.Root>

Examples

Basic Accessibility

Basic collapsible with default styling.

Lazy Mounted Accessibility

Collapsible with lazyMount and unmountOnExit enabled to unmount content when collapsed.

Props

Prop Type Default Description
defaultOpen boolean - Whether the collapsible is open by default.
disabled boolean - Whether the collapsible is disabled.
lazyMount boolean false Whether to enable lazy mounting of content.
unmountOnExit boolean false Whether to unmount the content when collapsed.
onPrefetch any - Callback invoked when hovering over the trigger. Similar to Astro's link prefetching, this allows preloading data before expanding.
class text - Additional CSS classes to apply.