Accordion

A set of collapsible panels with headings and content.

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 { Accordion, AccordionContent, AccordionHeader, AccordionItem, AccordionTrigger } from "coss-svelte";

Anatomy

  • Accordion
  • AccordionContent
  • AccordionHeader
  • AccordionItem
  • AccordionTrigger

API Reference

Accordion

A set of collapsible panels with headings and content.

Signatures

{ type?: "single"; value?: string; onValueChange?: OnChangeFn<string> }{ type: "multiple"; value?: string[]; onValueChange?: OnChangeFn<string[]> }
PropTypeDefaultDescription
type"single" | "multiple""single"Behavior, selection, or HTML type passed to the underlying control.
bind:valuestring | string[]""Current value for the component. Bind with `bind:value` when supported.
itemsAccordionItem[][]Items rendered by the component's built-in fallback composition.
children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Accordion.Root.

AccordionContent

Wraps the primary content for the parent component.

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

Inherits from Bits UI Accordion.Content.

AccordionHeader

Groups heading content for the parent component.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Accordion.Header.

AccordionItem

Renders one selectable or repeated item.

children : Snippet<[]>bind:ref : HTMLElement | null

Inherits from Bits UI Accordion.Item.

AccordionTrigger

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 Accordion.Trigger.

Implementation Details

Status
Stable
Foundation
bits
Category
Layout & Navigation
Particles
4