0.0.14 • Published 12 months ago

@ng-zi/extensions-accordion v0.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
12 months ago

MtxAccordion Component Overview

The mtx-accordion component is a versatile and customizable accordion component built on Angular Material. It provides a rich set of features, including support for nested accordions, custom templates, lazy loading, animations, event bindings, custom icons, and expand/collapse all functionality. It is designed to be flexible and powerful, making it a great choice for a wide range of use cases.

FeatureDescription
Multiple PanelsSupports multiple collapsible panels that can be expanded or collapsed independently or simultaneously.
Customizable TemplatesAllows customization of panel headers, content, and footers using Angular templates.
AccessibilityEnsures accessibility with appropriate ARIA roles and attributes for screen readers.
AnimationProvides smooth transitions for panel expand/collapse actions with optional animations.
Control Value AccessorIntegrates seamlessly with Angular forms using Control Value Accessor to manage panel states programmatically.
Custom IconsAllows customization of icons for indicating expand/collapse state.
StylingSupports custom CSS classes for flexible styling. CSS classes are prefixed with mtx- for easy integration and styling consistency.

Usage

Installation

  1. Import the MtxAccordionModule into your Angular module:

    import { MtxAccordionModule } from '@ng-zi/extensions/accordion';
    
    @NgModule({
      declarations: [
        // your components
      ],
      imports: [
        // other modules
        MtxAutocompleteModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

Basic Example

<mtx-accordion [accordionConfig]="accordionConfig"></mtx-accordion>
import { Component } from '@angular/core';

@Component({
  selector: 'app-accordion-demo',
  templateUrl: './accordion-demo.component.html'
})
export class AccordionDemoComponent {
  basicAccordionConfig = {
    panels: [
      { header: 'Panel 1', content: 'Content 1' },
      { header: 'Panel 2', content: 'Content 2' },
      { header: 'Panel 3', content: 'Content 3' },
    ],
    multi: true,
    animationsEnabled: true,
  };
}

Configuration

The MtxAccordion Component accepts a configuration object (MtxAccordionConfig) with the following properties:

PropertyTypeDescription
panelsMtxAccordionPanel[]An array of objects defining each panel's header, content, and optional footer.
multibooleanIndicates whether multiple panels can be expanded simultaneously.
customClassstring \| string[]Optional CSS class or array of classes to apply to the accordion component.
defaultExpandedbooleanIndicates whether panels should be expanded by default.
animationsEnabledbooleanEnables or disables animations for panel transitions.
hideTogglebooleanHides the toggle icon for expanding/collapsing panels.
expandAllOnInitbooleanExpands all panels on component initialization.
closeOthersOnOpenbooleanCloses other open panels when opening a new one.
disableRipplebooleanDisables the ripple effect on panel headers.

Events

The MtxAccordion Componentemits the following events:

Event NamePayloadDescription
panelOpenednumberEmitted when a panel is expanded.
panelClosednumberEmitted when a panel is collapsed.

Accessibility

Ensures accessibility by using appropriate ARIA roles and attributes to support navigation and interaction via screen readers.

Styling

Customize the appearance of MtxAccordion Component using CSS classes and styles. CSS classes are prefixed with mtx- for easy integration and styling consistency.


This structured overview.md provides a comprehensive overview of your MtxAccordion Component, highlighting its features, usage examples, configuration options, events, accessibility considerations, and styling guidelines in a clear and organized table format. Adjust the content and examples based on your specific implementation and design requirements.

Summary

The mtx-accordion component is a powerful and flexible solution for creating accordion interfaces in your Angular applications. With support for custom templates, lazy loading, animations, and more, it provides all the features you need to build a robust and user-friendly accordion component.