2.1.1 • Published 7 years ago

gridtab v2.1.1

Weekly downloads
62
License
MIT
Repository
github
Last release
7 years ago

GridTab jQuery Plugin

GridTab is a lightweight jQuery plugin to create grid based responsive tabs.

Demo

http://gopalraju.github.io/gridtab

Features

  • Responsive
  • Lightweight and based on CSS3 flexbox
  • Set Grid for each breakpoint
  • Switch between Grid and Tab layout
  • Next, previous and close controls
  • Scroll to current tab
  • Custom selectors
  • Right-To-Left Support

Usage

Setting up GridTab is really simple

HTML Markup

Your markup should look something like this

<dl id="gridtab-1">
	<dt>Tab 1</dt>
	<dd>Tab 1 Description</dd>
	<dt>Tab 2</dt>
	<dd>Tab 2 Description</dd>
	<dt>Tab 3</dt>
	<dd>Tab 3 Description</dd>
	<dt>Tab 4</dt>
	<dd>Tab 4 Description</dd>
	<dt>Tab 5</dt>
	<dd>Tab 5 Description</dd>
	<dt>Tab 6</dt>
	<dd>Tab 6 Description</dd>
</dl>

Where, <dt> contains the title of the tab nad <dd> contains the description to be shown on click.

Stylesheet

Just add a link to the css file in your :

<link rel="stylesheet" type="text/css" href="gridtab.min.css"/>

jQuery Plugin

Then, before your closing <body> tag add:

<script type="text/javascript" src="gridtab.min.js"></script>

and initialize the plugin as shown below:

<script>
	$(document).ready(function() {
		$('#gridtab-1').gridtab({
			grid:3
		});
	});
</script>

Where grid is the number of grids/tabs in a row

Settings

Basic SettingsTypeDefaultDescription
gridinteger4Number of grids or tabs per row
borderWidthinteger2Width of the borders.
tabBorderColorstring'#ddd'border color of the tabs (Hex Color Code).
tabPaddinginteger25padding/spacing around the tabs.
contentBorderColorstring'#ddd'border color of the content section (Hex Color Code).
contentPaddinginteger25padding/spacing around content section.
contentBackgroundstring'#fff'Background color for the content section (Hex Color Code).
activeTabBackgroundstring'#fff'Background color for the active tab (Hex Color Code).
responsiveArraynullArray of objects having breakpoints and settings object which is enabled at a given breakpoint.
selectorsObjectsee table belowObject with options to set custom selectors.
configObjectsee table belowObject with options to enable features like, setting initially active tab, next/prev controls, close button, transition speed etc.
callbacksObjectopen:false, close:falseCallbacks for the open and close states of the content section.
selectorsTypeDefaultDescription
tabstring'> dt'By default, the click event is triggered on the entire tab ('dt'). This can be replaced with any custom selector within the dt. For example: '.readmore'.
closeButtonstring'.gridtab__close'Custom class for the close button, if 'showClose' is set to true.
nextArrowstring'.gridtab__next.gridtab__arrow'Custom class for the next button, if 'showArrows' is set to true.
prevArrowstring'.gridtab__prev.gridtab__arrow'Custom class for the prev button, if 'showArrows' is set to true.
disabledArrowstring'.is-disabled'Custom class for the disabled state of next/prev buttons, if 'showArrows' is set to true.
configTypeDefaultDescription
layoutstring'grid'Change the value to 'tab' for a tab layout. By default, the layout is 'grid' based.
keepOpenBooleanfalseIf set to true keeps the active tab open (Disables toggle).
speedinteger500Transition speed in milliseconds.
activeTabinteger0Initially active tab. For example, 1 enables the first tab.
showCloseBooleanfalseShows the close button if set to true.
showArrowsBooleanfalseShows the next/prev buttons if set to true.
scrollToTabBooleanfalseScrolls to the active tab on click

Responsive Example

The responsive settings is where you reset the grids and other properties at a given breakpoint.

$('#gridtab-1').gridtab({
	grid:5,
	contentPadding: 40,
	responsive:[{
		breakpoint: 1024,
		settings:{
			grid:3,
			contentPadding: 30
		}
	},{
		breakpoint:767,
		settings:{
			grid:2,
			contentPadding: 25
		}
	},{
		breakpoint:520,
		settings:{
			grid:1,
			contentPadding: 20
		}
	}]
});

All properties under basic settings like: borderWidth, tabPadding, tabBorderColor, contentBorderColor, contentPadding, contentBackground and activeTabBackground, can be updated with the responsive settings.

Version

2.1.1

Browser support

GridTab works on IE10+ in addition to other modern browsers like Chrome, Firefox and Safari

Dependencies

jQuery 1.8.3 +

License

Licensed under the MIT license.