Easy Responsive Tabs to Accordion

Easy responsive tabs - is a lightweight jQuery plugin which optimizes normal horizontal or vertical tabs to accordion on multi devices like: web, tablets, Mobile (IPad & IPhone). This plugin adapts the screen size and changes its action accordingly.

Download .zip View on GitHub

Features

  • Horizontal / Vertical Tabs to Accordion
  • Tabs and accordion are created entirely with jQuery
  • Supports multiple sets of tabs on same page
  • Cross browser compatibility (IE7+, Chrome, Firefox, Safari and Opera)
  • Multi device support (Web, Tablets & Mobile)
  • Link directly to specified tab (works with multiple instances)
  • Maintains state of tabs when navigating away from page and then returning using back or forward (if browser supports the History API)
  • Nested tabs

Demo

Selected tab:

  • Horizontal 1
  • Horizontal 2
  • Horizontal 3

  • Responsive Tab 1
  • Responsive Tab 2
  • Responsive Tab 3
  • Long name Responsive Tab 4

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nibh urna, euismod ut ornare non, volutpat vel tortor. Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravida mollis.

This tab has icon in it.

Suspendisse blandit velit Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravid urna gravid eget erat suscipit in malesuada odio venenatis.

d ut ornare non, volutpat vel tortor. InLorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nibh urna, euismod ut ornare non, volutpat vel tortor. Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravida mollis.t in malesuada odio venenatis.

Child 1 Container

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nibh urna, euismod ut ornare non, volutpat vel tortor. Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravida mollis.

Child 2 Container

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum nibh urna, euismod ut ornare non, volutpat vel tortor. Integer laoreet placerat suscipit. Sed sodales scelerisque commodo. Nam porta cursus lectus. Proin nunc erat, gravida a facilisis quis, ornare id lectus. Proin consectetur nibh quis urna gravida mollis.

Child 3 Container

How to use

=> Included jQuery file (minimum jQuery-1.5.1.min.js)
=> Included easyResponsiveTabs.js
=> Include responsive-tabs.css

=> Here is the Markup for Tabs structure (non nested tabs):


    <div id="demoTab">          
        <ul class="resp-tabs-list">
            <li> .... </li>
            <li> .... </li>
            <li> .... </li>
        </ul> 

        <div class="resp-tabs-container">                                                        
            <div> ....... </div>
            <div> ....... </div>
            <div> ....... </div>
        </div>
    </div>    

=> Here is the Markup for Tabs structure (nested tabs):


    <div id="ParentTab">          
        <ul class="resp-tabs-list tab_identifier_parent">
            <li> .... </li>
            <li> .... </li>
            <li> .... </li>
        </ul> 

        <div class="resp-tabs-container tab_identifier_parent">                                                     
            <div>
               <p> 
                  <div id="ChildTab">          
                    <ul class="resp-tabs-list tab_identifier_child">
                       <li> .... </li>
                       <li> .... </li>
                       <li> .... </li>
                    </ul> 

                    <div class="resp-tabs-container tab_identifier_child">                                                                     <div> ....... </div>
                       <div> ....... </div>
                       <div> ....... </div>
                    </div>
                  </div>    
               </p>
            </div>
            <div> ....... </div>
            <div> ....... </div>
        </div>
    </div>    

=> Call the easyResponsiveTabs function:


    $('#demoTab').easyResponsiveTabs();

=> With optional parameters:


    $("#demoTab").easyResponsiveTabs({
        type: 'default', //Types: default, vertical, accordion           
        width: 'auto', //auto or any custom width
        fit: true,   // 100% fits in a container
        closed: false, // Close the panels on start, the options 'accordion' and 'tabs' keep them closed in there respective view types
        activate: function() {},  // Callback function, gets called if tab is switched
        tabidentify: 'tab_identifier_child', // The tab groups identifier *This should be a unique name for each tab group and should not be defined in any styling or css file.
        activetab_bg: '#B5AC5F', // background color for active tabs in this group
        inactive_bg: '#E0D78C', // background color for inactive tabs in this group
        active_border_color: '#9C905C', // border color for active tabs heads in this group
        active_content_border_color: '#9C905C' // border color for active tabs contect in this group so that it matches the tab head border
    });

=> Linking to Tabs:


    http://yoursite.com/tabs.html#{TAB ID}{TAB NUM}
    http://yoursite.com/tabs.html#demoTab2

    Multiple Instances:
    http://yoursite.com/tabs.html#{TAB ID 1}{TAB NUM}|{TAB ID 2}{TAB NUM}
    http://yoursite.com/tabs.html#demoTab2|demoTwo3

For any support

Samson Onna
My email: samson3d@gmail.com
My LinkedIn Profile
My Profile

ToDo

I am planning on adding these options in the future:

  • Ajax panels
  • Tabs that can be disabled
  • Keyboard interaction
  • Selection event type (for instance, mouseover)
  • If you have good ideas / tips about options / functionality, let me know!