Searching Open Sourcery

Type to search Open Sourcery.

Inputs & Controls

Collapsible Content

Height-animated disclosure with accordion grouping, custom easing, and real keyboard semantics.

v1.2.0@magic-spells/collapsible-content

$ npm i @magic-spells/collapsible-content

GitHubnpm

Live demo

The group allows one open item. Opening another closes the one that was open.

The package animates the height itself, so content of any size opens smoothly.

Each trigger is a real button with aria-expanded and aria-controls.

Accordion Group — opening one closes the last.

About

A lightweight, accessible Web Component for creating collapsible content sections. Perfect for FAQs, accordions, or any content that needs to be toggled.

Features

  • No dependencies
  • Lightweight
  • Accessible (ARIA attributes, keyboard support, focus management)
  • Smooth animations with prefers-reduced-motion support
  • Smooth mid-animation reversal on rapid clicks
  • Fully drivable from markup (open attribute, ``) or from JS

Usage

<collapsible-component>
	<button type="button">Product Information</button>
	<collapsible-content>
		<div class="content-wrapper">
			<h3>Details</h3>
			<p>This product is made with 100% organic materials.</p>
		</div>
	</collapsible-content>
</collapsible-component>

About, features, usage and options are taken from the package README.