🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

justtabs

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

justtabs

A simple and lightweight tab plugin

1.2.2
latest
Source
npm
Version published
Weekly downloads
11
57.14%
Maintainers
1
Weekly downloads
 
Created
Source

JustTabs

A simple and lightweight tab plugin

Overview

  • No dependencies.
    The library is written in pure JavaScript and requires no additional dependencies.

  • Simplicity and functionality.
    Easily integrate and use the library to implement essential tab functionality.

  • Accessibility.
    The plugin follows all accessibility best practices.

  • CSS customization.
    Modify the appearance and layout effortlessly using CSS.

Installation

  • Download the JS library just-tabs.min.js and the stylesheet just-tabs.min.css from the dist folder.
    Alternatively, install via NPM:
npm i justtabs
  • Include the files in your project:
<link rel="stylesheet" href="just-tabs.min.css">
<script src="just-tabs.min.js"></script>

Or (for module bundlers):

import 'justtabs/dist/just-tabs.min.css';
import JustTabs from 'just-tabs';
  • Add the following HTML structure:
<div data-jtabs="tabs">
  <ul data-jtabs="nav">
    <li>
      <button type="button"
              data-jtabs="control">Tab 1</button>
    </li>
    <li>
      <button type="button"
              data-jtabs="control">Tab 2</button>
    </li>
    <li>
      <button type="button"
              data-jtabs="control">Tab 3</button>
    </li>
  </ul>
  <div>
    <div data-jtabs="panel">Content 1</div>
    <div data-jtabs="panel">Content 2</div>
    <div data-jtabs="panel">Content 3</div>
  </div>
</div>

The data-jtabs attribute is essential for plugin functionality.

  • Initialize the library:
new JustTabs( 'tabs' );

Plugin Configuration

The JustTabs constructor accepts two arguments:

  • Required: A name (string) for the tab instance.
  • Optional: A configuration object.

Features

  • Set an active tab on load by specifying startTabIndex:
new JustTabs( 'tabs', {
	startTabIndex: 1
} );
  • Programmatically switch tabs using the switchTo method (pass the target tab index):
const tabs = new JustTabs( 'tabs' );
tabs.switchTo( 2 );
  • Retrieve configuration via getOptions():
const tabs = new JustTabs( 'tabs' );
tabs.getOptions(); // Returns full config object
tabs.getOptions('el'); // Returns the root HTML element
  • Callback on initialization (onInit):
new JustTabs( 'tabs', {
	onInit: ( tabs ) => {
		console.log( tabs );
	}
} );
  • Callback on tab switch ( onSwitch):
new JustTabs( 'tabs', {
	onSwitch: ( tabs ) => {
		console.log( tabs );
	}
} );

Keywords

JustTabs

FAQs

Package last updated on 06 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts