• Stars
    star
    371
  • Rank 115,103 (Top 3 %)
  • Language
    HTML
  • License
    MIT License
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bootstrap Tab Collapse plugin. Switches bootstrap tabs component to collapse for small screens

Bootstrap Tab Collapse

Small bootstrap plugin that switches bootstrap tabs component to collapse component for small screens.

View Demo | Download | More templates | Support forum

How it works

The most obvious way: bootstrap tab collapse generates accordion markup and appends it right away after tabs component. When accordion becomes (If accordion is) visible tabcollapse searchs for .tab-pane and detaches their content to appropriate accordion groups keeping all attached js data. Tabs component is given hidden-xs-class and accordion component is given visible-xs-class. That's it.

Use

Lets say you have your tabs component right from bootstrap's site:

<ul id="myTab" class="nav nav-tabs">
  <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
  <li><a href="#profile" data-toggle="tab">Profile</a></li>
  ...
</ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane fade in active" id="home">
        <p>Raw denim you probably haven't...</p>
    </div>
    <div class="tab-pane fade" id="profile">
        <p>Food truck fixie locavore, accus...</p>
    </div>
    ...
</div>

To activate tab collapse just include bootstrap-tabcollapse.js somewhere in your file and call:

$('#myTab').tabCollapse();

If you want to specify the class that is given to accordion and tabs components you can do so by passing options to tabCollapse:

$('#myTab').tabCollapse({
    tabsClass: 'hidden-sm',
    accordionClass: 'visible-sm'
});

The default class is hidden-xs. So it means that tabs component will be switched to accordion for 767px and below. You can define your own classes and use them. You can also use multiple Bootstrap classes in order to, for example, show accordion for mobile + tablets and tabs for desktop+:

$('#myTab').tabCollapse({
    tabsClass: 'hidden-sm hidden-xs',
    accordionClass: 'visible-sm visible-xs'
});

Events

There are four events tabcollapse triggers (for entire component, not for single tabs or accordion groups!):

  • show-tabs.bs.tabcollapse - triggered before tabs component is shown
  • shown-tabs.bs.tabcollapse - triggered after tabs component is shown
  • show-accordion.bs.tabcollapse - triggered before accordion component is shown
  • shown-accordion.bs.tabcollapse - triggered after accordion component is shown

To attach event handler just call:

$('#myTab').on('shown-accordion.bs.tabcollapse', function(){
    alert('accordion is shown now!');
});

Attach an event handler when either tab or collapse is opened:

$(document).on("shown.bs.collapse shown.bs.tab", ".panel-collapse, a[data-toggle='tab']", function (e) {
    alert('either tab or collapse opened - check arguments to distinguish ' + e);
});

Support

For any additional information please go to our support forum and raise your questions or feedback provide there. We highly appreciate your participation!

How can I support developers?

  • Star our GitHub repo โญ
  • Create pull requests, submit bugs, suggest new features or documentation updates ๐Ÿ”ง
  • Follow us on Twitter ๐Ÿพ
  • Like our page on Facebook ๐Ÿ‘

Contributors

Thanks to bdaenen for contributing.

More Repositories

1

react-native-starter

๐Ÿš€A powerful react native starter template that bootstraps development of your mobile application
JavaScript
2,047
star
2

awesome-bootstrap-checkbox

โœ”๏ธFont Awesome Bootstrap Checkboxes & Radios. Pure css way to make inputs look prettier
CSS
2,042
star
3

react-material-admin

โ˜„๏ธReact Material Admin is a React template built with Material-UI
JavaScript
1,535
star
4

react-dashboard

๐Ÿ”ฅReact Dashboard - isomorphic admin dashboard template (React.js, Bootstrap, Node.js, GraphQL, React Router, Babel, Webpack, Browsersync) ๐Ÿ”ฅ
JavaScript
1,526
star
5

angular-material-dashboard

Angular admin dashboard with material design
JavaScript
1,346
star
6

sing-app

๐Ÿ’ฅFree and open-source admin dashboard template built with Bootstrap 4.5 ๐Ÿ’ฅ
Handlebars
1,267
star
7

sing-app-vue-dashboard

Vue.js admin dashboard template built with Bootstrap 4.5
Vue
681
star
8

light-blue-react-template

Light Blue React Template - Admin Dashboard Template built with React
JavaScript
491
star
9

light-blue-vue-admin

๐Ÿค˜Vue admin dashboard template with stylish transparent design
Vue
349
star
10

angular-dashboard-seed

Angular dashboard sample application with nodejs REST backend integration
JavaScript
195
star
11

light-blue-dashboard

๐Ÿ”ฅ Free and open-source admin dashboard template built with Bootstrap
Handlebars
146
star
12

material-vue

๐Ÿ’Ž Vue Material Template - Vuetify admin dashboard template built with Vuetify and Love ๐Ÿ’
Vue
142
star
13

sofia-react-template

๐Ÿ”ฎ Sofia React Template - Admin Dashboard Template built with React
JavaScript
142
star
14

one-react-template

Flatlogic One - React Template and Theme
JavaScript
141
star
15

widgster

Small jQuery plugin that provides an easy way to handle basic widget functions like collapsing, closing, ajax-refreshing & fullsreening.
JavaScript
37
star
16

ecommerce-dashboard-react

E-commerce dashboard built with Cube.js and React
JavaScript
26
star
17

one-bootstrap-template

Flatlogic One - Free Bootstrap Template and Theme
Handlebars
25
star
18

dashboard

JavaScript
16
star
19

joulon-demo

JavaScript
2
star
20

cli

Fullstack application generator
TypeScript
2
star
21

app-generator-java

Flatlogic App Generator
Java
1
star