Responsive Tabs To Accordion jQuery Plugin – Responsive-tabs

Looking for a affordable website?

GET STARTED
www.codingexpertz.com
Responsive Tabs To Accordion jQuery Plugin – Responsive-tabs

File Size: 364KB

Total Views: 538

Date Created:

Last Modified Date:

Official Website: Go to website

License: MIT

Responsive-Tabs is a very useful jQuery plugin that converts the tabs to accordion on mobile automatically through CSS breakpoint. By default, it transforms to an accordion below 768px, but you can modify this breakpoint in CSS as per your requirements.

Features:

  • It can be installed with Bower and NPM.
  • Lightweight and easy to implement.
  • Tabs can be opened with URL hashes.
  • Uses CSS for the desktop/tablet/mobile view.
  • Supported on all major browsers and devices.
  • Tabs can be disabled.
  • Tabs can auto rotate.

Install with Bower

$ bower install responsive-tabs

Install with NPM

$ npm install responsive-tabs

How to use it:

1. Include the Javascript jquery.responsiveTabs.min.js at the bottom of the web page.

<script src="path/to/jquery.responsiveTabs.min.js"></script>

2. Include the CSS responsive-tabs.css in the header of the page.

<link rel="stylesheet" href="css/responsive-tabs.css">

3. Add the basic HTML to the page.

<div id="defaultTabs">
    <ul>
        <li><a href="#tab-1">Tab-1</a></li>
        <li><a href="#tab-2">Tab-2</a></li>
        <li><a href="#tab-3">Tab-3</a></li>
    </ul>

    <div id="tab-1">Tab content 1</div>
    <div id="tab-2">Tab content 2</div>
    <div id="tab-3">Tab content 3</div>
</div>

4. Initialize the plugin and we’re ready to go.

$('#defaultTabs').responsiveTabs({
    startCollapsed: 'accordion'
});

5. Include style.css for a basic tab/accordion theme

<link rel="stylesheet" href="path/to/style.css">

Plugin’s default options:

Name Default Description
Collapsible accordion
collapsible: false // The panels are not collapsible
collapsible: true // The panels are collapsible
collapsible: 'tabs' // The panels are only collapsible if the view is currently tab based
collapsible: 'accordion' // The panels are only collapsible if the view is currently accordion based
Start collapsed false
startCollapsed: false // Do not collapse on start
startCollapsed: true // Start with the panels collapsed
startCollapsed: 'tabs' // Start with the panels collapsed if the view is currently tab based
startCollapsed: 'accordion' // Start with the panels collapsed if the view is currently accordion based
Disabled tabs []
disabled: [0,2] // Disables the first and third tab
Active tab null
active: 1 // Opens the second tab on load
Accordion Tab HTML element '<div></div>'
accordionTabElement: '<div></div>'
Set hash false
setHash: true
Rotate false
rotate: false, // The tabs won't auto rotate
rotate: true, // The tabs will auto rotate from the start
Event 'click'
event: 'click' // (default) The tabs will activate on click
event: 'mouseover' // The tabs will activate on mouseover
etc...
Animation default
animation: 'fade', // The panels will fade in and out
animation: 'slide', // The panels will slide up and down
Animation Queue false
animationQueue: false, // (default) disables the queueing of the animations. With this option on, all animations happen at the same time
animationQueue: true, // enables the queueing of the animations. With this option on, animations wait for each other
animationQueue: 'tabs', // enables the queueing of the animations for the tabs state only
animationQueue: 'accordion', // enables the queueing of the animations for the accordion state only
Animation Duration 500
duration: 500, // (default) Sets the animation duration to 500
Scroll to Accordion panel false
scrollToAccordion: false, // (default) disables the auto scrolling to the accordion panel
scrollToAccordion: true, // enables the auto scrolling to the accordion panel
Scroll To Accordion On Load true
scrollToAccordionOnLoad: true, // (default) enables scrolling to accordion on load
scrollToAccordionOnLoad: false, // disables scrolling to accordion on load
Scroll To Accordion Offset false
scrollToAccordionOffset: false, // (default) disables the auto scrolling to the accordion panel
scrollToAccordionOffset: true, // enables the auto scrolling to the accordion panel
Navigation container ''
navigationContainer: '.some-css-selector'

Click

This callback is called after a tab is clicked, regardless of whether it’s disabled

Arguments

  • event: Clicked event
  • tab: Clicked tab object
click: function(event, tab){},

Activate

This callback is called after a tab is selected

Arguments

  • event: Activate event
  • tab: Activated tab object
activate: function(event, tab){},

Deactivate

This callback is called after a tab is deactivated

Arguments

  • event: Deactivate event
  • tab: Deactivated tab object
deactivate: function(event, tab){},

Load

This callback is called after the plugin has been loaded

Arguments

  • event: Load event
  • tab: First tab object
load: function(event, firstTab){},

Activate State

This callback is called after the plugin switches from state (Tab view / Accordion view)

activateState: function(){}

Leave a comment

Your email address will not be published. Required fields are marked *

STAYUPDATED

Receive all our future posts instantly in your inbox. Enter your email to enroll.