{"id":26316887,"url":"https://github.com/liranh85/js-tabs","last_synced_at":"2025-03-15T13:17:16.211Z","repository":{"id":57283701,"uuid":"146303939","full_name":"liranh85/js-tabs","owner":"liranh85","description":"Transforms tabs markup to a simple but beautiful tabs system","archived":false,"fork":false,"pushed_at":"2018-11-10T23:04:50.000Z","size":118,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T16:52:17.042Z","etag":null,"topics":["tab","tabbable","tabs"],"latest_commit_sha":null,"homepage":"","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/liranh85.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}},"created_at":"2018-08-27T13:48:53.000Z","updated_at":"2021-12-29T07:56:20.000Z","dependencies_parsed_at":"2022-09-09T00:41:31.690Z","dependency_job_id":null,"html_url":"https://github.com/liranh85/js-tabs","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liranh85%2Fjs-tabs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liranh85%2Fjs-tabs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liranh85%2Fjs-tabs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liranh85%2Fjs-tabs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liranh85","download_url":"https://codeload.github.com/liranh85/js-tabs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243732218,"owners_count":20338839,"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":["tab","tabbable","tabs"],"created_at":"2025-03-15T13:17:15.493Z","updated_at":"2025-03-15T13:17:16.203Z","avatar_url":"https://github.com/liranh85.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JS Tabs\n\nTransforms tabs markup to a simple but beautiful tabs system: showing the corresponding content when clicking on a tab.\n\n## Live example\n\nhttp://www.liran.co.uk/js-tabs\n\n## Features\n\n  - Supports multiple JS Tabs components on one page\n  - Supports nesting JS Tabs inside one another\n  - Has a tab marker out of the box, which also:\n    - is animated\n    - changes color based on the color of each tab\n    - resizes on window resize\n  - Exposes a destroy method to remove all js-tabs event listeners\n\n## Installation\n\n```\nnpm install js-tabs\n```\n\n## Usage\n\n### HTML\n```html\n\u003cdiv id=\"my-js-tabs\"\u003e\n  \u003cnav class=\"js-tabs__nav\"\u003e\n    \u003cul class=\"js-tabs__tabs-container\"\u003e\n      \u003cli class=\"js-tabs__tab active\"\u003eTab 1\u003c/li\u003e\n      \u003cli class=\"js-tabs__tab\"\u003eTab 2\u003c/li\u003e\n      \u003cli class=\"js-tabs__tab\"\u003eTab 3\u003c/li\u003e\n      \u003cli class=\"js-tabs__tab\"\u003eTab 4\u003c/li\u003e\n    \u003c/ul\u003e\n    \u003cdiv class=\"js-tabs__marker\"\u003e\u003c/div\u003e\n  \u003c/nav\u003e\n\n  \u003cul class=\"js-tabs__content-container\"\u003e\n    \u003cli class=\"js-tabs__content active\"\u003e\n      \u003cp\u003eContent 1\u003c/p\u003e\n    \u003c/li\u003e\n    \u003cli class=\"js-tabs__content\"\u003e\n      \u003cp\u003eContent 2\u003c/p\u003e\n    \u003c/li\u003e\n    \u003cli class=\"js-tabs__content\"\u003e\n      \u003cp\u003eContent 3\u003c/p\u003e\n    \u003c/li\u003e\n    \u003cli class=\"js-tabs__content\"\u003e\n      \u003cp\u003eContent 4\u003c/p\u003e\n    \u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/div\u003e\n```\n\n### JS\n```js\nimport JsTabs from 'js-tabs'\n\nconst myTabs = new JsTabs({\n  elm: '#my-js-tabs'\n})\nmyTabs.init()\n```\n\n### SCSS\n\nRequires `_js-tabs-base.scss` to work properly.\n```scss\n@import '~js-tabs/src/js-tabs-base';\n```\n\n## Usage - ES5 and CSS\n\n```html\n\u003chead\u003e\n  \u003c!-- ... --\u003e\n  \u003clink rel=\"stylesheet\" href=\"js-tabs/_js-tabs-base.css\"\u003e\n  \u003cscript src=\"js-tabs/index.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n  \u003c!-- ... --\u003e\n  \u003cscript\u003e\n    var myTabs = new JsTabs.default({\n      elm: '#my-js-tabs'\n    })\n    myTabs.init()\n  \u003c/script\u003e\n\u003c/body\u003e\n```\n\n## Parameters\n\nJsTabs takes an object with the following properties:\n\n```js\n{\n  elm,\n  onClickHandlerComplete,\n  shouldScrollTabIntoView\n}\n```\n\n### `elm`\n[Element/String, **required**] The root element of the JS Tabs in the DOM. Can be either a reference to the element or a string representing a selector for the element.\n\n### `onClickHandlerComplete`\n[Callback function, optional] If passed, will be called after the tab has changed.\n\n### `shouldScrollTabIntoView`\n[Boolean, optional, default: true] Whether on not to scroll towards the tab when clicked (useful in small displays in which the tabs might not all fit on the screen)\n\n## Public methods\n\n### `init()`\nInitialises the JS Tabs instance for the element specified\n\n### `destory()`\nRemoves all event listeners of the JS Tabs instance\n\n\n## CSS classes used\n\n- `js-tabs__nav`\n- `js-tabs__tab`\n- `js-tabs__content-container`\n- `js-tabs__content`\n- `js-tabs__marker`\n- `js-tabs__no-marker` (see below)\n- `active`\n\n## Removing the marker\nIf you want to implement the marker differently, you can remove the existing one like so:\n\n```diff\n...\n\u003cnav class=\"js-tabs__nav\"\u003e\n- \u003cul class=\"js-tabs__tabs-container\"\u003e\n+ \u003cul class=\"js-tabs__tabs-container js-tabs__no-marker\"\u003e\n    \u003cli class=\"js-tabs__tab active\"\u003eTab 1\u003c/li\u003e\n    \u003cli class=\"js-tabs__tab\"\u003eTab 2\u003c/li\u003e\n    \u003cli class=\"js-tabs__tab\"\u003eTab 3\u003c/li\u003e\n    \u003cli class=\"js-tabs__tab\"\u003eTab 4\u003c/li\u003e\n  \u003c/ul\u003e\n- \u003cdiv class=\"js-tabs__marker\"\u003e\u003c/div\u003e\n\u003c/nav\u003e\n...\n```\n\n## Dependencies\n\nNone\n\n## Contributing\n\nFeel free to submit issues and pull requests\n\n## Development\n\n* Run the following, which will serve the JS Tabs example on localhost:8081 and watch for changes.\n```\nnpm start\n```\n\n* Navigate to http://localhost:8081/example/ to view the output\n* Test the library in `src/example`:\n  * index.html\n  * index.js\n  * _js-tabs-custom.scss\n* Edit the library itself in `src`:\n  * index.js\n  * _js-tabs-base.scss\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliranh85%2Fjs-tabs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliranh85%2Fjs-tabs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliranh85%2Fjs-tabs/lists"}