Accordion
Collapsible panels for organizing content into expandable sections. By default, only one panel can be open at a time (true accordion behavior). Supports animated carets, multiple open panels, and compact/borderless variants. Fully keyboard-navigable with ARIA roles.
Basic Accordion (Single Open)
By default, opening a panel automatically closes any other open panels. Default: first panel open.
Configure general application settings here.
Allow Multiple Panels Open
Use ->allowMultiple() to allow multiple panels to be open simultaneously.
Non-Animated
Omit ->animated() for instant expand/collapse with a static caret icon. Default: non-animated.
- Founded: 2024
- Headquarters: Wellington
- Employees: 50+
Compact Style
Use ->addClass('m-accordion--compact') for smaller padding on headers and content.
Borderless Style
Use ->addClass('m-accordion--borderless') to remove borders between panels.
PHP PHP Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->accordion($id) | string | Create an accordion component. |
->panel($title, $content, ?$icon) | string, string, ?string | Add a panel with title, HTML content, and optional icon. Returns self for chaining. |
->animated() | | Enable animated caret rotation and smooth height transitions. Default: false. |
->allowMultiple() | | Allow multiple panels to be open simultaneously. Default: false (only one panel open). |
->defaultOpen($index) | int | Set which panel is open by default (0-based index). Default: none open. |
->addClass($class) | string | Add CSS classes. Use m-accordion--compact or m-accordion--borderless for variants. |
->attr($name, $value) | string, string | Add custom HTML attributes to the accordion container. |
JS JS Methods
| Method / Property | Parameters | Description |
|---|---|---|
m.accordion(id) | string | Get the accordion API for the given element ID. |
open(index) | int | Open a panel by index (0-based). If allowMultiple is false, closes other panels. |
close(index) | int | Close a panel by index (0-based). |
toggle(index) | int | Toggle a panel's open/closed state. |
getOpen() | | Returns an array of currently open panel indices. |
EVENT Events
| Event Name | Detail | Description |
|---|---|---|
m:accordion:opened | {index, panel, header, content} | Fired when a panel is opened. index is the 0-based panel index. |
m:accordion:closed | {index, panel, header, content} | Fired when a panel is closed. index is the 0-based panel index. |