Collapsible

A component that toggles visibility of content sections.

Installation

Install the component package, shared coss-svelte theme, and Bits UI peer.

npm install coss-svelte @coss-svelte/theme bits-ui

Usage

Import the Svelte component exports directly from the package.

import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "coss-svelte";

Anatomy

  • Collapsible
  • CollapsibleContent
  • CollapsibleTrigger

API Reference

Collapsible

A component that toggles visibility of content sections.

PropTypeDefaultDescription
bind:openbooleanfalseOpen state for the popup or disclosure. Bind with `bind:open`.
titlestring""Title text rendered by the component's built-in fallback layout.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Collapsible.Root.

CollapsibleContent

Wraps the primary content for the parent component.

PropTypeDescription
forceMountbooleanKeeps content mounted while closed so transitions can complete.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Collapsible.Content.

CollapsibleTrigger

Renders the control that opens, closes, or selects related content.

children : Snippet<[]>child : Snippet<[{ props: Record<string, unknown> }]>bind:ref : HTMLElement | null

Inherits from Bits UI Collapsible.Trigger.

Implementation Details

Status
Stable
Foundation
bits
Category
Layout & Navigation
Particles
1