{"id":17382054,"url":"https://github.com/michu2k/Accordion","last_synced_at":"2025-02-27T10:31:00.448Z","repository":{"id":20441528,"uuid":"87917038","full_name":"michu2k/Accordion","owner":"michu2k","description":"Accordion module created in pure javascript \u0026 CSS. Very useful to create FAQ lists on your website.","archived":false,"fork":false,"pushed_at":"2024-08-30T12:05:22.000Z","size":2100,"stargazers_count":350,"open_issues_count":2,"forks_count":74,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-19T09:47:59.104Z","etag":null,"topics":["a11y","accessibility","accordion","aria","es6","javascript","javascript-library"],"latest_commit_sha":null,"homepage":"https://michu2k.github.io/Accordion/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michu2k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-04-11T09:43:20.000Z","updated_at":"2024-09-10T15:00:27.000Z","dependencies_parsed_at":"2024-01-10T08:43:31.042Z","dependency_job_id":"e86a7dc5-e845-48a9-bbbb-7c4f9a0b2c36","html_url":"https://github.com/michu2k/Accordion","commit_stats":{"total_commits":161,"total_committers":7,"mean_commits":23.0,"dds":0.5093167701863355,"last_synced_commit":"5eac06e3679d52e2740c8d6dcd1a48a7412a26c2"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michu2k%2FAccordion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michu2k%2FAccordion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michu2k%2FAccordion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michu2k%2FAccordion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michu2k","download_url":"https://codeload.github.com/michu2k/Accordion/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219842872,"owners_count":16556565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a11y","accessibility","accordion","aria","es6","javascript","javascript-library"],"created_at":"2024-10-16T07:05:16.676Z","updated_at":"2025-02-27T10:31:00.435Z","avatar_url":"https://github.com/michu2k.png","language":"JavaScript","funding_links":[],"categories":["UI Components"],"sub_categories":["Accordion"],"readme":"# Accordion\n\nLightweight and accessible accordion module with an extensible API. With the module you can create accordion on your website, useful especially for creating FAQ lists.\n\n## Version\n\n3.4.0\n\n## Installation\n\n###### npm\n\nInstall the package \u0026 import files\n\n```\nnpm install accordion-js\n```\n\n```javascript\nimport Accordion from \"accordion-js\";\nimport \"accordion-js/dist/accordion.min.css\";\n```\n\n###### CDN\n\nInclude files using CDN.\n\n```\nhttps://unpkg.com/accordion-js@3.4.0/dist/accordion.min.css\nhttps://unpkg.com/accordion-js@3.4.0/dist/accordion.min.js\n```\n\n```html\n\u003clink rel=\"stylesheet\" href=\"[CDN CSS URL]\" /\u003e\n\u003cscript src=\"[CDN JS URL]\"\u003e\u003c/script\u003e\n```\n\n###### Github\n\nYou can also download files from Github and attach them manually to your project. \u003cbr\u003e\nNote: On production use files (JS and CSS) only from **dist/** folder.\n\n## Usage\n\n###### Include files\n\nSee the section above.\n\n###### Create HTML layout\n\nThis is just an example of a layout. You can create your own HTML structure.\n\n```html\n\u003cdiv class=\"accordion-container\"\u003e\n  \u003cdiv class=\"ac\"\u003e\n    \u003ch2 class=\"ac-header\"\u003e\n      \u003cbutton type=\"button\" class=\"ac-trigger\"\u003eLorem ipsum dolor sit amet.\u003c/button\u003e\n    \u003c/h2\u003e\n    \u003cdiv class=\"ac-panel\"\u003e\n      \u003cp class=\"ac-text\"\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit.\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\n  \u003cdiv class=\"ac\"\u003e\n    \u003ch2 class=\"ac-header\"\u003e\n      \u003cbutton type=\"button\" class=\"ac-trigger\"\u003eLorem ipsum dolor sit amet.\u003c/button\u003e\n    \u003c/h2\u003e\n    \u003cdiv class=\"ac-panel\"\u003e\n      \u003cp class=\"ac-text\"\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit.\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\n  \u003cdiv class=\"ac\"\u003e\n    \u003ch2 class=\"ac-header\"\u003e\n      \u003cbutton type=\"button\" class=\"ac-trigger\"\u003eLorem ipsum dolor sit amet.\u003c/button\u003e\n    \u003c/h2\u003e\n    \u003cdiv class=\"ac-panel\"\u003e\n      \u003cp class=\"ac-text\"\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit.\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n###### Initialize the module\n\n```html\n\u003cscript\u003e\n  new Accordion(\".accordion-container\");\n\u003c/script\u003e\n```\n\n## API\n\n###### Examples\n\nnew Accordion(container, options)\n\n- `container` - string | HTMLElement (required), selector of accordion container\n- `options` - object (optional), accordion options\n\n```javascript\n// Default options\nnew Accordion(\".container-first\");\n\n// User options\nnew Accordion(\".container-second\", {\n  duration: 400,\n  showMultiple: true,\n  onOpen: function (currentElement) {\n    console.log(currentElement);\n  }\n});\n\n// Define several accordions with the same options (pass an array with selectors)\nnew Accordion([\".container-first\", \".container-second\"], {});\n\n// or pass an array with HTMLElements\nconst accordions = Array.from(document.querySelectorAll(\".accordion-container\"));\nnew Accordion(accordions, {});\n\n// Detach events\nconst accordion = new Accordion(\".container-first\");\naccordion.detachEvents();\n```\n\n###### Options\n\n| Option         | Type     | Default value | Description                                                                                                                               |\n| -------------- | -------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |\n| duration       | number   | 500           | Animation duration in ms                                                                                                                  |\n| ariaEnabled    | boolean  | true          | Add ARIA elements to the HTML structure                                                                                                   |\n| collapse       | boolean  | true          | Allow collapse expanded panel                                                                                                             |\n| showMultiple   | boolean  | false         | Show multiple elements at the same time                                                                                                   |\n| onlyChildNodes | boolean  | true          | Disabling this option will find all items in the container. Warning: Setting to `false` will break the functionality of nested accordions |\n| openOnInit     | array    | []            | Show accordion elements during initialization                                                                                             |\n| elementClass   | string   | \"ac\"          | Element class                                                                                                                             |\n| triggerClass   | string   | \"ac-trigger\"  | Trigger class                                                                                                                             |\n| panelClass     | string   | \"ac-panel\"    | Panel class                                                                                                                               |\n| activeClass    | string   | \"is-active\"   | Active element class                                                                                                                      |\n| beforeOpen     | function | -             | Calls before the item is opened. \u003cbr\u003e `beforeOpen: (currElement) =\u003e {}`                                                                   |\n| onOpen         | function | -             | Calls when the item is opened. \u003cbr\u003e `onOpen: (currElement) =\u003e {}`                                                                         |\n| beforeClose    | function | -             | Calls before the item is closed. \u003cbr\u003e `beforeClose: (currElement) =\u003e {}`                                                                  |\n| onClose        | function | -             | Calls when the item is closed. \u003cbr\u003e `onClose: (currElement) =\u003e {}`                                                                        |\n\n###### Methods\n\n| Option         | Description                                                                                | Arguments             |\n| -------------- | ------------------------------------------------------------------------------------------ | --------------------- |\n| attachEvents() | Attach events                                                                              | -                     |\n| detachEvents() | Detach events                                                                              | -                     |\n| open()         | Open the accordion element with the given idx \u003cbr\u003e E.g. `acc.open(1)`                      | `idx` - element index |\n| close()        | Close the accordion element with the given idx \u003cbr\u003e E.g. `acc.close(1)`                    | `idx` - element index |\n| toggle()       | Toggle the accordion element with the given idx \u003cbr\u003e E.g. `acc.toggle(1)`                  | `idx` - element index |\n| openAll()      | Open all accordion elements (without animation)                                            | -                     |\n| closeAll()     | Close all accordion elements (without animation)                                           | -                     |\n| update()       | If there are new items added by lazy load, you can run this method to update the Accordion | -                     |\n| destroy()      | Destroy accordion instance: \u003cbr\u003e Open elements, remove events, IDs \u0026 ARIA                  | -                     |\n\n## v3 Release Info\n\nThere have been a lot of changes to the API in version `3.0.0`, so if you are using previous versions of the accordion (`2.8.0` and below), I recommend updating the package to the latest version with new structure and options.\n\n## License\n\nThis project is under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichu2k%2FAccordion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichu2k%2FAccordion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichu2k%2FAccordion/lists"}