Javascript Tabs: Save Space! Examples Of Tabbed Widgets
Tags: webdev, javascript, frontend
Published: 2021-06-07 12:04:44

---
title: Javascript Tabs: Save Space! Examples Of Tabbed Widgets
published: true
description: It seems that tabs are taken for granted, as an essential UI component of the site, that don’t really deserve close attention. But, thanks to tabs which resolve the question of data segmentation and organisation, the site audience can easily choose the relevant data they need to explore. Plus, tabs make the website more interactive and responsive, adding clarity that enhances user experience.
tags: webdev, js, frontend
//cover_image: https://direct_url_to_image.jpg
canonical_url: https://flatlogic.com/blog/javascript-tabs-save-space-examples-of-tabbed-widgets/
---

It seems that tabs are taken for granted, as an essential UI component of the site, that don’t really deserve close attention. But, thanks to tabs which resolve the question of data segmentation and organisation, the site audience can easily choose the relevant data they need to explore. Plus, tabs make the website more interactive and responsive, adding clarity that enhances user experience.

We’ve made a review of some examples of javascript tabs, including how to make javascript tabs, and which snippets to use when building a web app.

##What is the Javascript tab

A tab, in a nutshell, is a single content area/component of a site design system (also called a tabbed widget) with multiple panels, each linked to a title/header in a list. Tabs may vary in size and shape, and they make the website page more structured and easier to grasp. From the position of web developers, tabbed widgets is a collection of links or other HTML elements that can be visually represented in the form of buttons, a group of buttons, and in some other ways. In essence, they simply turn on the visibility of one content block while hiding others.

##Types of Tabs: Navigation Tabs and Modular Tabs

Frequently, the focused, currently-used tab is somehow highlighted or moved forward to the user. And this way, tabs can be divided into navigation tabs and modular tabs. Navigation tabs work as a clickable space opening content in a new webpage. Modular tabs open further info within the same page. Well, needless to say, each interface is designed to resemble the tabs at the top of traditional file folders, as viewed from inside a file cabinet. The main advantage of modular tabs is that they help to reflect the relevant data optimized within the web page screen area without data cluttering and reduce the amount of info on the screen to that needed to be shown. 

##Scrollable and Fixed Tabs

Additionally, tabs can be divided into scrollable and fixed. When a set of tabs cannot fit on screen, use scrollable tabs. Scrollable tabs can use longer text labels and a larger number of tabs. They are best used for browsing on touch interfaces.


##Tab Structure

Tab components consist of the container (the frame), tab item, active/inactive tab icon or text, tab indicator. Tabs control the UI region displayed below them. Tabs can be joined with components like top app bars, or nested into components like cards and sheets. In this sample we have no clear tab indicator, but we’ve defined its place by number 2, the aim of the indicator is to show the state of the content within the tab item. 


![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/picture-1536x996.png?lossy=1&strip=1&webp=1)

1.Frame (Container)
2.Tab indicator (Active/Inactive)
3.Text (Active/Inactive)
4.Icon/Label (Active/Inactive)
5.Tab item

##Common Problems Resolved by Tabs

* Organization of info and navigation of chunks of information between groups of different or related content or at the same level of site hierarchy
* Easily customizable with the colors or type of content to match site branding
* Faster orientation and management of the website data

##Criteria to Evaluate a Good Tab Component


* User Experience/ External Appeal
* Documentation
* Customization
* Reusability

##Free Javascript Tabs Examples

Make use of our top 10 tab snippets to help you while building your site. Set up these tab widgets absolutely free. 

###1. Vanilla JavaScript Tabs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-1.gif?lossy=1&strip=1&webp=1)

Simple Fast Vanilla JavaScript Tabs is an easy maintainable vanilla JavaScript library for web development. This tabs snippet will help to build responsive vertical navigation. Vanilla Javascript Tabs are pretty darn simple to use. Vanilla Javascript tabs are supported by any modern browsers like Chrome, Firefox, Safari, Opera, and others. First off,  you should add the JS vanilla-js-tabs.js and Stylesheet vanilla-js-tabs.css to the page.

[Demo](https://zoltantothcom.github.io/vanilla-js-tabs/)
[GitHub](https://github.com/zoltantothcom/vanilla-js-tabs)

###2. Tabby Tabs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-2-1.gif?lossy=1&strip=1&webp=1)

Tabby tabs is another example of extremely lightweight and accessible vanilla JS toggle tabs. Compiled and production-ready code can be found in the `dist` directory. The `src` directory contains development code.

[Demo](https://codepen.io/Sarah_C/pen/NNBwWm)

###3. Adaptive tabs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-3.gif?lossy=1&strip=1&webp=1)

Adaptive Tabs is a super useful snippet to build in on your site page. These tabs are animated to the height of their content when being switched. Adaptive tabs are highly simple in use, and there’s no risk of a huge page jump when moving from a content-heavy tab to a smaller one.

[Demo](https://codepen.io/Lewitje/pen/doJRBX)

###4. Mobile-first accordion to tabs by Chyno Deluxe

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-10.gif?lossy=1&strip=1&webp=1)

Responsive, Mobile first, drop-down accordion tabs is another simple tabbed widget for developers made with HTML, CSS (SCSS language), and JS. It works well with all modern browsers like Chrome, Edge, Firefox, Opera, Safari.

[Demo](https://codepen.io/ChynoDeluxe/pen/qemoLr)

###5. Simple Tab Designs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-11.gif?lossy=1&strip=1&webp=1)

Simple tab design is not just a name, it’s as simple as possible in use. This tab component is built on a mix of CSS and JavaScript. The individual tab contents slide down & out of view almost like notecards. This whole tab feature gives highly visual experience.

[Demo](https://codepen.io/0zero4four/pen/PPjZzj)

###6. CSS Tabs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker.gif?lossy=1&strip=1&webp=1)

CSS Tabs, by Ramnek Sinkh, made with smooth scroll property. Without animations or transitions used for tabs switching, tabs transition is made through the scroll-behaviour property and html id’s.

[Demo](https://codepen.io/Ramnk7/pen/yWBWEe)

###7. MetroTab

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-2-2.gif?lossy=1&strip=1&webp=1)

Metro tabs use the M4Q library, and these tabs are [jQuery free](https://flatlogic.com/blog/top-7-jquery-free-admin-templates/). MetroTab plugin lets you make horizontal tabs by adding class `tabs` to list and attribute `data-role="tabs"`. And, `bottom` tabs by setting add class on.

[Demo](https://metroui.org.ua/tabs.html)

###8. Responsive Tabs/Accordion In Vanilla JavaScript

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-12.gif?lossy=1&strip=1&webp=1)

Responsive Tabs/Accordion is a pure JavaScript plugin with accordions and tabs, aimed to generate mobile-friendly horizontal or vertical tabs from unordered HTML lists with a switchable option.

[Demo](https://www.cssscript.com/demo/responsive-tabs-accordion-vanilla/)

###9. Material Design Vanilla Javascript Tabs

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-4-1.gif?lossy=1&strip=1&webp=1)

[Material design](https://flatlogic.com/blog/top-material-design-dashboards/) is loved by thousands of people. Vanilla JavaScript tabs is one more neat snippet for coders. These tabs are made with pure Javascript, CSS and CSS3. For more illustrative examples of material design tabs, refer to this detailed [guide](https://flatlogic.com/blog/react-table-guide-and-best-react-table-examples/).

[Demo](https://codepen.io/LukyVj/pen/yNwgrK)

###10. Gettin’ Practical with Tabs – Vue Challenge by Jack Domleo

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-8-2.gif?lossy=1&strip=1&webp=1)

Gettin’ Practical is for the lovers of minimalistic design. Well-ordered approach makes the tabs look extremely clean. They work in Chrome, Safari, Firefox, Opera, and Edge. And, this UI component allows [Vue.js](https://flatlogic.com/blog/9-awesome-projects-built-with-vue-js/) tab switching.

[Demo](https://codepen.io/jackdomleo7/pen/qBOKaeK)

###11. Tabs with elastic border

![](https://833250.smushcdn.com/1694534/wp-content/uploads/2021/04/ezgif.com-gif-maker-5-1.gif?lossy=1&strip=1&webp=1)

Tabs with elastic border is one more variant to use for tabs option. The code is represented in HTML, CSS and Javascript (Babel). The structure of the code is well-organized and the tabbed widget looks really modern.

[Demo](https://codepen.io/iremlopsum/pen/aqvKJL)

##How to Use Js tabs?

Implement the following functions which allow you to create and toggle the tabs on your website step-by-step according to this [guide](https://rudrastyh.com/javascript/tabs.html).

##How to Make a Switchable Tab on Your Page?

To make the tabs toggleable, add the `data-toggle="tab"` attribute to each link. Then add a .tab-pane class with a unique ID for every tab and wrap them inside a div element with class `.tab-content`.

You can also activate tabs by writing Javascript code. Then you do not need to add the `data-toggle="tab"` attribute. 

Displaying the tab in this case will be done by calling the tab (‘show’) method. This method should be used for the relevant tab (link) every time the user clicks on it.

The source JS code:
* The source JavaScript code consists of  `$tab. function`. There will be `_elemTabs` and functions `_showTab`, `_switchTabTo`. Inside this function there is a variable `_elemTabs` and functions `_showTab`, `_switchTabTo`. A variable `_elemTabs` has a DOM-element, it looks like a container with tabs.
* `_showTab` is made to hide the active tab and display the other tab based on the transferred link.  `_switchTabTo` method is used for switching the tab by number. `addEventListener` is set by event handlers.
* `_showTab` and `_switchTabTo` are the only methods available out of the function. `showTab` lets you go to the tab through transferring the link on DOM-element, and the second one (`switchTabTo`) opens up the page by its page number.

__________

#About Flatlogic

At Flatlogic, we help businesses to speed up web development with our beautifully designed web & mobile application templates built with [React](https://flatlogic.com/templates/react), [Vue](https://flatlogic.com/templates/vue), [Angular](https://flatlogic.com/templates/angular), [React Native](https://flatlogic.com/templates/react-native), and [Bootstrap](https://flatlogic.com/templates/bootstrap). During the last several years we have successfully delivered more than 100 custom dashboards and data management solutions to various clients starting from innovative startups to established and respected enterprises.

{% youtube WpVQsS-Bb3U %}

_____________

**You might also like these articles:**
[Top 24 Free Essential Plugins To Extend Bootstrap](https://dev.to/flatlogic/top-24-free-essential-plugins-to-extend-bootstrap-4mn6)
[37 Simple And Useful Table Templates & Examples For Web Developers](https://dev.to/flatlogic/37-simple-and-useful-table-templates-examples-for-web-developers-i3j)
[Top 13+ Login Pages Design Examples](https://dev.to/flatlogic/top-13-login-pages-design-examples-57ip)