npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@magic-spells/collapsible-content

v0.2.0

Published

Collapsible content web component

Readme

Collapsible Content Web Component

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

Live Demo

Features

  • No dependencies
  • Lightweight
  • Follows accessibility best practices
  • Smooth open/close animations
  • Uses proper ARIA attributes
  • Keyboard accessible

Installation

npm install @magic-spells/collapsible-content
// Add to your JavaScript file
import '@magic-spells/collapsible-content';

Or include directly in your HTML:

<script src="https://unpkg.com/@magic-spells/collapsible-content"></script>

Usage

<collapsible-component>
  <button aria-expanded="false">Product Information</button>
  <collapsible-content>
    <div class="content-wrapper">
      <h3>Details</h3>
      <p>
        This product is made with 100% organic materials. It's durable, eco-friendly, and
        stylish.
      </p>
    </div>
  </collapsible-content>
</collapsible-component>

How It Works

  • The collapsible content is initially hidden (unless aria-expanded="true" is set on the button)
  • Clicking the button toggles the visibility of the content
  • The component handles all the ARIA attributes for accessibility
  • Smooth animations are provided for opening and closing

Customization

Styling

You can style the collapsible component using CSS custom properties:

:root {
  /* Layout */
  --cc-component-display: block;
  --cc-button-width: 100%;
  --cc-button-text-align: left;
  
  /* Appearance */
  --cc-button-background: none;
  --cc-button-border: none;
  --cc-button-cursor: pointer;
  
  /* Animation */
  --cc-content-padding: 10px;
  --cc-transition-duration: 0.5s;
  --cc-transition-timing: ease-in-out;
}

SCSS Integration

For more advanced customization, you can import the SCSS directly:

// Option 1: Import the compiled CSS
@import '@magic-spells/collapsible-content/css';

// Option 2: Import the SCSS and override variables
@use '@magic-spells/collapsible-content/scss' with (
  $transition-duration: 0.5s,
  $transition-timing: ease-in-out,
  $content-padding: 10px
);

// Option 3: Import specific parts
@use '@magic-spells/collapsible-content/scss/variables' with (
  $button-text-align: center
);
@use '@magic-spells/collapsible-content/scss/collapsible-content';

Accessibility

This component follows WCAG guidelines for accessible accordions:

  • Uses proper aria-expanded and aria-controls attributes
  • Content regions have proper role="region" and aria-labelledby attributes
  • Keyboard accessible (toggle with Space or Enter key)
  • Focus management for keyboard users

Browser Support

This component works in all modern browsers that support Web Components.

License

MIT