UNPKG

9.26 kBMarkdownView Raw
1# jQuery Smart Tab v4
2#### The flexible jQuery tab control plugin
3
4[![Build Status](https://travis-ci.org/techlab/jquery-smarttab.svg?branch=master)](https://travis-ci.org/techlab/jquery-smarttab)
5[![npm version](https://badge.fury.io/js/jquery-smarttab.svg)](https://badge.fury.io/js/jquery-smarttab)
6[![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/jquery-smarttab/badge?style=rounded)](https://www.jsdelivr.com/package/npm/jquery-smarttab)
7[![Npm Downloadsl](https://badgen.net/npm/dm/jquery-smarttab?icon=npm)](https://www.npmjs.com/package/jquery-smarttab)
8[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/techlab/jquery-smarttab/master/LICENSE)
9[![GitHub Sponsor](https://img.shields.io/badge/Sponsor-techlab-blue.svg?logo=github)](https://github.com/sponsors/techlab)
10[![Donate on Paypal](https://img.shields.io/badge/PayPal-dipuraj-blue.svg)](https://www.paypal.me/dipuraj)
11
12Smart Tab is a flexible and heavily customizable **tab control plugin for jQuery**.
13
14> If you think it is cool, you should also check it's sibling [React Smart Tab](http://techlaboratory.net/react-smarttab)
15
16+ [Homepage](http://techlaboratory.net/jquery-smarttab)
17+ [Documentation](http://techlaboratory.net/jquery-smarttab#documentation)
18+ [Demos](http://techlaboratory.net/jquery-smarttab#demo)
19+ [StackOverflow Q&A](http://stackoverflow.com/questions/tagged/smart-tab)
20+ [GitHub Issues](https://github.com/techlab/jquery-smarttab/issues)
21
22Demos
23-----
24 + [Basic Example](http://techlaboratory.net/projects/demo/jquery-smart-tab/v4)
25 + [Ajax Contents](http://techlaboratory.net/projects/demo/jquery-smart-tab/v4/ajax)
26 + [Multiple Tabs](http://techlaboratory.net/projects/demo/jquery-smart-tab/v4/multiple)
27 + [Vertical Tab Layout](http://techlaboratory.net/projects/demo/jquery-smart-tab/v4/vertical)
28 + [Bootstrap Modal Example](http://techlaboratory.net/projects/demo/jquery-smart-tab/v4/bootstrap-modal)
29
30Screenshots
31-----
32![jQuery Smart Tab](https://techlaboratory.net/assets/media/jquery-smart-tab/v4/st-v4-basic.gif)
33
34![jQuery Smart Tab](https://techlaboratory.net/assets/media/jquery-smart-tab/v4/st-v6-brick.png)
35
36![jQuery Smart Tab](https://techlaboratory.net/assets/media/jquery-smart-tab/v4/st-v6-basic.png)
37
38![jQuery Smart Tab](https://techlaboratory.net/assets/media/jquery-smart-tab/v4/st-v6-pills.png)
39
40Requirements
41-----
42 + [jQuery](http://jquery.com/) (supports jQuery 1.11.1+ to jQuery 3.6+ and jQuery Slim versions)
43
44Installation
45-----
46
47### [NPM](https://www.npmjs.com/package/jquery-smarttab)
48 npm install jquery-smarttab
49
50### [Yarn](https://yarn.pm/jquery-smarttab)
51 yarn add jquery-smarttab
52
53### [CDN - jsDelivr](https://www.jsdelivr.com/package/npm/jquery-smarttab)
54```html
55<!-- CSS -->
56<link href="https://cdn.jsdelivr.net/npm/jquery-smarttab@4/dist/css/smart_tab_all.min.css" rel="stylesheet" type="text/css" />
57
58<!-- JavaScript -->
59<script src="https://cdn.jsdelivr.net/npm/jquery-smarttab@4/dist/js/jquery.smartTab.min.js" type="text/javascript"></script>
60```
61
62### [CDN - UNPKG](https://unpkg.com/browse/jquery-smarttab/)
63```html
64<!-- CSS -->
65<link href="https://unpkg.com/jquery-smarttab@4/dist/css/smart_tab_all.min.css" rel="stylesheet" type="text/css" />
66
67<!-- JavaScript -->
68<script src="https://unpkg.com/jquery-smarttab@4/dist/js/jquery.smartTab.min.js" type="text/javascript"></script>
69```
70
71### Common JS/Webpack
72```js
73var $ = require("jquery");
74require( "jquery-smarttab/dist/css/smart_tab_all.css");
75const smartTab = require("jquery-smarttab");
76
77$(function() {
78 $('#smarttab').smartTab();
79});
80```
81### ES6/Babel
82```js
83import $ from "jquery";
84import "jquery-smarttab/dist/css/smart_tab_all.css";
85import smartTab from 'jquery-smarttab';
86
87$(function() {
88 $('#smarttab').smartTab();
89});
90```
91
92#### Note: you may have to install the required dependencies
93```bash
94npm i jquery
95npm i jquery-smarttab
96
97// If you are using Webpack, install
98npm i webpack webpack-cli style-loader css-loader --save-dev
99```
100
101### Download
102#### [Download from GitHub](https://github.com/techlab/jquery-smarttab/archive/master.zip)
103
104Features
105-----
106- Easy to implement and minimal HTML required
107- Supports all modern browsers
108- Responsive CSS design
109- Bootstrap compatible
110- Cool themes included and can be easly customize
111- Easy color cusomization using CSS variables
112- Built-in transition animations (none|fade|slideHorizontal|slideVertical|slideSwing|css)
113- Transition animations can be added easly by extending
114- CSS Animations support for transition animations (Supports [Animate.css](https://animate.style/))
115- Accessible controls
116- External controls support
117- Easy ajax content integration
118- Keyboard navigation
119- Auto content height adjustment
120- Buit-in loader
121- Buit-in events
122- UMD (Universal Module Definition) support
123- Compatible with all jQuery versions (jQuery 1.11.1+, jQuery 3.6+, and jQuery Slim)
124- URL navigation and tab selection
125- Auto Progress (automatic navigation of tabs)
126
127Usage
128-----
129
130Include jQuery SmartTab CSS
131```html
132<link href="../dist/css/smart_tab_all.min.css" rel="stylesheet" type="text/css" />
133```
134
135Include HTML
136```html
137<div id="smarttab">
138
139 <ul class="nav">
140 <li>
141 <a class="nav-link" href="#tab-1">
142 Tab 1
143 </a>
144 </li>
145 <li>
146 <a class="nav-link" href="#tab-2">
147 Tab 2
148 </a>
149 </li>
150 <li>
151 <a class="nav-link" href="#tab-3">
152 Tab 3
153 </a>
154 </li>
155 <li>
156 <a class="nav-link" href="#tab-4">
157 Tab 4
158 </a>
159 </li>
160 </ul>
161
162 <div class="tab-content">
163 <div id="tab-1" class="tab-pane" role="tabpanel">
164 Tab content
165 </div>
166 <div id="tab-2" class="tab-pane" role="tabpanel">
167 Tab content
168 </div>
169 <div id="tab-3" class="tab-pane" role="tabpanel">
170 Tab content
171 </div>
172 <div id="tab-4" class="tab-pane" role="tabpanel">
173 Tab content
174 </div>
175 </div>
176</div>
177```
178Include jQuery (*ignore this if you have already included on the page*).
179```html
180<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
181```
182Include jQuery SmartTab JavaScript
183```html
184<script type="text/javascript" src="../dist/js/jquery.smartTab.min.js"></script>
185```
186Initialize the jQuery SmartTab
187```js
188$(function() {
189 // SmartTab initialize
190 $('#smarttab').smartTab();
191});
192```
193That's it!
194
195Please see the [documentation](http://techlaboratory.net/jquery-smarttab#documentation) for more details on implementation and usage.
196
197##### All options
198```JavaScript
199// SmartTab initialize
200$('#smarttab').smartTab({
201 selected: 0, // Initial selected tab, 0 = first tab
202 theme: 'basic', // theme, related css need to include for other than default theme
203 justified: true, // Nav menu justification. true/false
204 autoAdjustHeight: true, // Automatically adjust content height
205 backButtonSupport: true, // Enable the back button support
206 enableUrlHash: true, // Enable selection of the step based on url hash
207 transition: {
208 animation: 'none', // Animation effect on navigation, none|fade|slideHorizontal|slideVertical|slideSwing|css(Animation CSS class also need to specify)
209 speed: '400', // Animation speed. Not used if animation is 'css'
210 easing: '', // Animation easing. Not supported without a jQuery easing plugin. Not used if animation is 'css'
211 prefixCss: '', // Only used if animation is 'css'. Animation CSS prefix
212 fwdShowCss: '', // Only used if animation is 'css'. Step show Animation CSS on forward direction
213 fwdHideCss: '', // Only used if animation is 'css'. Step hide Animation CSS on forward direction
214 bckShowCss: '', // Only used if animation is 'css'. Step show Animation CSS on backward direction
215 bckHideCss: '', // Only used if animation is 'css'. Step hide Animation CSS on backward direction
216 },
217 autoProgress: { // Auto navigate tabs on interval
218 enabled: false, // Enable/Disable Auto navigation
219 interval: 3500, // Auto navigate Interval (used only if "autoProgress" is enabled)
220 stopOnFocus: true, // Stop auto navigation on focus and resume on outfocus
221 },
222 keyboard: {
223 keyNavigation: true, // Enable/Disable keyboard navigation(left and right keys are used if enabled)
224 keyLeft: [37, 38], // Left key code
225 keyRight: [39, 40], // Right key code
226 keyHome: [36], // Home key code
227 keyEnd: [35] // End key code
228 },
229 style: { // CSS Class settings
230 mainCss: 'st',
231 navCss: 'nav',
232 navLinkCss: 'nav-link',
233 contentCss: 'tab-content',
234 contentPanelCss: 'tab-pane',
235 themePrefixCss: 'st-theme-',
236 justifiedCss: 'st-justified',
237 anchorDefaultCss: 'default',
238 anchorActiveCss: 'active',
239 loaderCss: 'st-loading'
240 },
241 getContent: null
242});
243```
244
245License
246----
247[MIT License](https://github.com/techlab/jquery-smarttab/blob/master/LICENSE)
248
249Contribute
250----
251If you like the project please support with your contribution.
252
253[GitHub Sponsor](https://github.com/sponsors/techlab)
254[Donate on Paypal](https://www.paypal.me/dipuraj)
255
256Happy Coding :heart:
257