All Projects → wnda → Stabs

wnda / Stabs

Licence: bsd-3-clause-clear
tabs in vanilla JS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Stabs

Core Components
Accessible and lightweight Javascript components
Stars: ✭ 85 (+844.44%)
Mutual labels:  tabs, vanilla-js
tabbis.js
Pure vanilla javascript tabs with nesting
Stars: ✭ 44 (+388.89%)
Mutual labels:  tabs, vanilla-js
Tabby
Lightweight, accessible vanilla JS toggle tabs.
Stars: ✭ 449 (+4888.89%)
Mutual labels:  tabs, vanilla-js
React Router Navigation
⛵️ A complete navigation library for React Native, React DOM and React Router
Stars: ✭ 498 (+5433.33%)
Mutual labels:  tabs
Atomic
A tiny, Promise-based vanilla JS Ajax/HTTP plugin with great browser support.
Stars: ✭ 526 (+5744.44%)
Mutual labels:  vanilla-js
Gumshoe
A simple vanilla JS scrollspy script.
Stars: ✭ 640 (+7011.11%)
Mutual labels:  vanilla-js
Union Js
🏷️ Tagged unions for vanilla JavaScript!
Stars: ✭ 24 (+166.67%)
Mutual labels:  vanilla-js
Mixitup
A high-performance, dependency-free library for animated filtering, sorting, insertion, removal and more
Stars: ✭ 4,431 (+49133.33%)
Mutual labels:  vanilla-js
Labelsview
Android的标签列表控件。可以设置标签的选中效果。 可以设置标签的选中类型:不可选中、单选、限数量多选和不限数量多选等, 并支持设置必选项、单行显示、最大显示行数等功能。
Stars: ✭ 777 (+8533.33%)
Mutual labels:  tabs
Smooth Scroll
A lightweight script to animate scrolling to anchor links.
Stars: ✭ 5,350 (+59344.44%)
Mutual labels:  vanilla-js
Animatedtablayout
Yet another android tab layout
Stars: ✭ 572 (+6255.56%)
Mutual labels:  tabs
Responsive Tabs
Responsive Tabs is a jQuery plugin that provides responsive tab functionality. The tabs transform to an accordion when it reaches a CSS breakpoint. You can use this plugin as a solution for displaying tabs elegantly on desktop, tablet and mobile.
Stars: ✭ 529 (+5777.78%)
Mutual labels:  tabs
Jkanban
Vanilla Javascript plugin for manage kanban boards
Stars: ✭ 664 (+7277.78%)
Mutual labels:  vanilla-js
Simple Tab Groups
Create, modify and quick change tab groups. Inspired by the Tab Groups app :)
Stars: ✭ 500 (+5455.56%)
Mutual labels:  tabs
Push State
Turn static web sites into dynamic web apps.
Stars: ✭ 16 (+77.78%)
Mutual labels:  vanilla-js
Bootstrap Vertical Tabs
Missing vertical tabs component for bootstrap.
Stars: ✭ 489 (+5333.33%)
Mutual labels:  tabs
Vanilla Lazyload
LazyLoad is a lightweight, flexible script that speeds up your website by deferring the loading of your below-the-fold images, backgrounds, videos, iframes and scripts to when they will enter the viewport. Written in plain "vanilla" JavaScript, it leverages IntersectionObserver, supports responsive images and enables native lazy loading.
Stars: ✭ 6,596 (+73188.89%)
Mutual labels:  vanilla-js
Easytimer.js
Easy to use Timer/Stopwatch/Countdown library compatible with AMD, ES6 and Typescript
Stars: ✭ 562 (+6144.44%)
Mutual labels:  vanilla-js
Suneditor
Pure javascript based WYSIWYG html editor, with no dependencies.
Stars: ✭ 557 (+6088.89%)
Mutual labels:  vanilla-js
Vue Tabs Component
An easy way to display tabs with Vue
Stars: ✭ 616 (+6744.44%)
Mutual labels:  tabs

What is stabs.js?

stabs.js is near enough 2 (or 3 if you want IE8 support) kilobytes of JavaScript for creating tabbed sections of your webpage.

It's not something I'm especially proud of. It's not the friendliest or the most modern approach.

However, it is easy to use, you can just drop it in and it'll work nicely, and coming soon is support for custom selectors specified by you. It's pretty robust.

Why make this lib?

Bootstrap and other libraries/frameworks which include, or are solely intended for, the creation of tabbed UI elements, tend to require jQuery. This is not surprising but it is disappointing. My 80 lines of vanilla would probably be about 8 lines of jQuery, that much is true.

However, it is 2016, and while ES5/ES6 are gaining traction, in the real and non-transpiled world, ES3 is finally becoming standardised across all browsers, even in IE. Vanilla JS is a good deal faster than working with a framework or abstraction layer, and certainly there's the filesize of libraries/frameworks compared to this tab snippet.

There are of course some other vanilla JS alternatives, like tabby, or that random one whose demo features cats, but they all navigate to hash fragments in the URL bar, which is a feature I explicitly didn't want, and should at most be an optional extra.

I wanted something lean and robust. Thus, stabs.js was born.

What's the approach?

stabs.js uses only vanilla JavaScript primarily relying on for loops and className.

stabs loops through everything in the DOM with a class of “tabcontainer” and then adds event listeners to everything that is a “tab” in that tabcontainer.

These event listeners wait for a tab to be clicked and then, if the tab is not active, set it and its corresponding tabpane to active (with a CSS class) and all other tabs/tabpanes have their active status removed. This is additionally reflected with aria-attributes and the html5 hidden attribute.

This might seem like cheating, but the approach could easily be adapted to manipulate styles directly. However, appending and removing classes is ultimately more efficient, and also enables the exact way tabs are displayed/hidden to be very flexible to the CSS-savvy dev.

This is ultimately the simplest way to work with tabs.

How does one use it?

Include stabs.js in your page and make sure you have elements corresponding to the selectors. tabs and tab panes do not need to be siblings, but they must be contained within a tabcontainer element and there must be a tab pane for every tab. tabs must be siblings of tabs and same for tab panes. This is easier to explain in a demo.

You need a containing element and the tabs and tabpanes must be children of the container, though they need not necessarily be immediate children.

stabs supports nested tabs. This is achieved using 'indexOf' which is polyfilled within the IE8 standalone lib.

Demo 1 (home page) : https://stabs.js.org

Demo 2 (nesting tabs) : https://output.jsbin.com/hosomi/31

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].