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

@pmeig/ngb-collapse

v1.0.0

Published

A powerful Angular library that provides Bootstrap-styled collapse functionality with smooth animations and flexible control options.

Downloads

11

Readme

@pmeig/ngb-collapse

A powerful Angular library that provides Bootstrap-styled collapse functionality with smooth animations and flexible control options.

Installation

  npm install @pmeig/ngb-collapse

Features

  • 🎯 CollapseMaterial Directive - Smart collapse directive with animation support
  • 📦 Flexible Control - Toggle via boolean values or element references
  • 🔄 Animation Options - Vertical and horizontal collapse animations
  • Bootstrap Integration - Full Bootstrap 5.3.3 collapse behavior
  • 🎨 Bootstrap 5.3.3 compatible styling
  • 🚀 Angular 20.2.1 support with signals
  • 📱 Responsive design
  • ♿ Accessibility friendly with ARIA attributes
  • 🛠️ Programmatic and template-driven control

Usage

Import the Module

import { CollapseMaterial } from '@pmeig/ngb-collapse';
@Component({
  imports: [CollapseMaterial],
  // ...
})
export class MyComponent { }

Basic Collapse

<button class="btn btn-primary" type="button" #collapseBtn>
  Toggle Collapse
</button>
<div *collapse="collapseBtn" class="mt-2">
  <div class="card card-body">
    This content will collapse and expand with smooth animations.
  </div>
</div>

Boolean Control

<button class="btn btn-primary" (click)="isCollapsed = !isCollapsed">
  Toggle Collapse
</button>
<div *collapse="isCollapsed" class="mt-2">
  <div class="card card-body">
    This content is controlled by a boolean variable.
  </div>
</div>

Horizontal Collapse

<button class="btn btn-primary" type="button" #horizontalBtn>
  Toggle Horizontal
</button>
<div style="min-height: 120px;">
  <div *collapse="horizontalBtn; animation: 'horizontal'">
    <div class="card card-body" style="width: 300px;">
      This content collapses horizontally instead of vertically.
    </div>
  </div>
</div>

API Reference

Collapse Directive Options

| Property | Type | Default | Description | |----------|------|---------|-------------| | collapse | boolean \| Element | false | Controls collapse state - boolean for programmatic control, Element reference for click-based control | | collapseAnimation | 'vertical' \| 'horizontal' | 'vertical' | Animation direction for the collapse effect |

Control Methods

  • Boolean Control: Pass true/false to programmatically show/hide content
  • Element Reference: Pass button/trigger element reference for automatic click handling
  • Template Reference: Use template reference variables for easy element binding

How It Works

Animation Behavior

The collapse directive automatically:

  1. Manages CSS Classes: Applies Bootstrap collapse classes (collapse, collapsing, show)
  2. Handles Animations: Smooth transitions between collapsed and expanded states
  3. Calculates Dimensions: Dynamically measures content size for proper animations
  4. ARIA Support: Automatically manages aria-expanded and aria-controls attributes

State Management

  • Collapsed State: Content is hidden with display: none equivalent
  • Collapsing State: Transition animation is active with collapsing class
  • Expanded State: Content is fully visible with collapse show classes

Bootstrap Classes Support

This library generates and works with standard Bootstrap 5 collapse classes:

  • collapse - Base collapse styling
  • collapsing - Applied during transition animations
  • show - Indicates expanded state
  • collapse-horizontal - Applied for horizontal collapse animations
  • collapsed - Applied to trigger elements when content is collapsed

Integration with Other Modules

The collapse module works seamlessly with:

// Often used together
import { AccordionMaterial } from '@pmeig/ngb-accordion';
import { OffcanvasMaterial } from '@pmeig/ngb-offcanvas';

Dependencies

  • Angular: ^20.2.1
  • @angular/common: ^20.2.1
  • @pmeig/ngb-core: ^0.0.1
  • tslib: ^2.3.0

Compatibility

  • Angular: 20.2.1+
  • Bootstrap: 5.3.3+
  • TypeScript: 5.8.3+
  • Modern browsers (Chrome, Firefox, Safari, Edge)

Best Practices

1. Use Semantic Controls

<!-- Good: Clear trigger button -->
<button class="btn btn-outline-primary" 
        type="button" 
        aria-label="Toggle navigation menu"
        #menuToggle>
  Menu
</button>
<nav *collapse="menuToggle">
  <!-- Navigation content -->
</nav>

Troubleshooting

Common Issues

Animation not working

  • Check that the element has measurable content for size calculations

ARIA attributes not updating

  • Verify that trigger elements are properly referenced
  • Check that the directive is applied to the collapsible content, not the trigger

Horizontal collapse not working

  • Set explicit width on content for proper measurements

License

This project is licensed under the MIT License.

Support

For issues and questions, please open an issue on the GitHub repository.