|
| 1 | +# Vue-tabs |
| 2 | +Simplified, customizable bootstrap based tabs |
| 3 | +Vue-tabs is a tab component which simplifies the usage of tabs and their customization |
| 4 | +## Demos |
| 5 | +* [Basic demo](https://jsfiddle.net/CristiJ/b44cc4dq/22/) |
| 6 | +* [Icons and colors](https://jsfiddle.net/CristiJ/b44cc4dq/26/) |
| 7 | +* [Full width centered tabs with text bellow](https://jsfiddle.net/CristiJ/b44cc4dq/29/) |
| 8 | +* [Vertical tabs](https://jsfiddle.net/CristiJ/b44cc4dq/32/) |
| 9 | +* [In browser Plaground](?id=playground) |
| 10 | + |
| 11 | +## Usage |
| 12 | +## NPM |
| 13 | +`npm install --save vue-nav-tabs ` |
| 14 | +`yarn add --dev vue-nav-tabs` |
| 15 | + |
| 16 | +## Direct script include |
| 17 | +Download the css and js files from `dist` folder or reference them directly from github (check jsfiddle links) |
| 18 | +```html |
| 19 | +<link rel="stylesheet" href="https://unpkg.com/vue-nav-tabs/dist/vue-tabs.min.css"> |
| 20 | +<script src="https://unpkg.com/vue-nav-tabs/dist/vue-tabs.js"></script> |
| 21 | + |
| 22 | +Vue.use(VueTabs) |
| 23 | +``` |
| 24 | +## Component registration |
| 25 | +```js |
| 26 | +//global registration |
| 27 | +import VueTabs from 'vue-nav-tabs' |
| 28 | +import 'vue-nav-tabs/dist/vue-tabs.min.css' |
| 29 | +Vue.use(VueTabs) |
| 30 | + |
| 31 | +//local registration |
| 32 | +import {VueTabs, VTab} from 'vue-nav-tabs' |
| 33 | +//you can also import this in your style tag |
| 34 | +import 'vue-nav-tabs/dist/vue-tabs.min.css' |
| 35 | +//component code |
| 36 | +components: { |
| 37 | + VueTabs, |
| 38 | + VTab |
| 39 | +} |
| 40 | +``` |
| 41 | +```html |
| 42 | +<vue-tabs> |
| 43 | + <v-tab title="First tab"> |
| 44 | + First tab content |
| 45 | + </v-tab> |
| 46 | + |
| 47 | + <v-tab title="Second tab"> |
| 48 | + Second tab content |
| 49 | + </v-tab> |
| 50 | + |
| 51 | + <v-tab title="Third tab"> |
| 52 | + Third tab content |
| 53 | + </v-tab> |
| 54 | +</vue-tabs> |
| 55 | +``` |
| 56 | + |
| 57 | +# Props |
| 58 | + |
| 59 | +## Vue-tabs props |
| 60 | +```js |
| 61 | +props: { |
| 62 | + title: { |
| 63 | + type: String, |
| 64 | + default: '' |
| 65 | + }, |
| 66 | + /*** |
| 67 | + * Icon name for the upper circle corresponding to the tab |
| 68 | + * Supports themify icons only for now. |
| 69 | + */ |
| 70 | + icon: { |
| 71 | + type: String, |
| 72 | + default: '' |
| 73 | + }, |
| 74 | + /*** |
| 75 | + * Function to execute before tab switch. Return value must be boolean |
| 76 | + * If the return result is false, tab switch is restricted |
| 77 | + */ |
| 78 | + beforeChange: { |
| 79 | + type: Function |
| 80 | + }, |
| 81 | + route: { |
| 82 | + type: [String, Object] |
| 83 | + } |
| 84 | +} |
| 85 | +``` |
| 86 | + |
| 87 | +## V-tab props |
| 88 | + |
| 89 | +```js |
| 90 | +props: { |
| 91 | + title: { |
| 92 | + type: String, |
| 93 | + default: '' |
| 94 | + }, |
| 95 | + icon: { |
| 96 | + type: String, |
| 97 | + default: '' |
| 98 | + } |
| 99 | +} |
| 100 | +``` |
| 101 | + |
| 102 | +## Events |
| 103 | + |
| 104 | +Event Name | Params |
| 105 | +------------ | ------------- |
| 106 | +tab-change | tabIndex, newTab, oldTab |
| 107 | + |
| 108 | +### tab-change example |
| 109 | + |
| 110 | +Template |
| 111 | +```html |
| 112 | +<vue-tabs @tab-change="handleTabChange"> |
| 113 | + <v-tab title="First tab"> |
| 114 | + First tab content |
| 115 | + </v-tab> |
| 116 | + |
| 117 | + <v-tab title="Second tab"> |
| 118 | + Second tab content |
| 119 | + </v-tab> |
| 120 | + |
| 121 | + <v-tab title="Third tab"> |
| 122 | + Third tab content |
| 123 | + </v-tab> |
| 124 | +</vue-tabs> |
| 125 | +``` |
| 126 | +Javascript |
| 127 | +```js |
| 128 | +methods:{ |
| 129 | + handleTabChange(tabIndex, newTab, oldTab){ |
| 130 | + //your code here |
| 131 | + } |
| 132 | +} |
| 133 | +``` |
| 134 | + |
| 135 | +JSFiddle example - https://jsfiddle.net/b44cc4dq/56/ |
| 136 | + |
| 137 | +# Playground |
| 138 | + |
| 139 | +## Simple |
| 140 | + |
| 141 | +<vuep template="#simpleexample"></vuep> |
| 142 | + |
| 143 | +<script v-pre type="text/x-template" id="simpleexample"> |
| 144 | +<template> |
| 145 | + <vue-tabs> |
| 146 | + <v-tab title="First tab"> |
| 147 | + First tab content |
| 148 | + </v-tab> |
| 149 | + |
| 150 | + <v-tab title="Second tab"> |
| 151 | + Second tab content |
| 152 | + </v-tab> |
| 153 | + |
| 154 | + <v-tab title="Third tab"> |
| 155 | + Third tab content |
| 156 | + </v-tab> |
| 157 | + </vue-tabs> |
| 158 | + |
| 159 | +</template> |
| 160 | + |
| 161 | +<script> |
| 162 | + Vue.use(VueTabs); |
| 163 | + export default {} |
| 164 | +</script> |
| 165 | +</script> |
| 166 | + |
| 167 | + |
| 168 | +## Icons and colored tabs |
| 169 | +<p class="tip"> |
| 170 | + Note that the icons are imported separately (via script tag in this case). |
| 171 | + In the demos below themify-icons are used, but you can use pretty much any icons you wish. |
| 172 | +</p> |
| 173 | +<vuep template="#icons"></vuep> |
| 174 | + |
| 175 | +<script v-pre type="text/x-template" id="icons"> |
| 176 | +<template> |
| 177 | + <vue-tabs active-tab-color="#9b59b6" |
| 178 | + active-text-color="white"> |
| 179 | + <v-tab title="First tab" icon="ti-user"> |
| 180 | + First tab content |
| 181 | + </v-tab> |
| 182 | + |
| 183 | + <v-tab title="Second tab" icon="ti-settings"> |
| 184 | + Second tab content |
| 185 | + </v-tab> |
| 186 | + |
| 187 | + <v-tab title="Third tab" icon="ti-check"> |
| 188 | + Third tab content |
| 189 | + </v-tab> |
| 190 | + </vue-tabs> |
| 191 | + |
| 192 | +</template> |
| 193 | + |
| 194 | +<script> |
| 195 | + Vue.use(VueTabs); |
| 196 | + export default {} |
| 197 | +</script> |
| 198 | +</script> |
| 199 | + |
| 200 | + |
| 201 | +## Full width tabs |
| 202 | + |
| 203 | +<vuep template="#fullpage"></vuep> |
| 204 | + |
| 205 | +<script v-pre type="text/x-template" id="fullpage"> |
| 206 | +<template> |
| 207 | + <vue-tabs active-tab-color="#e74c3c" |
| 208 | + active-text-color="white" |
| 209 | + type="pills" |
| 210 | + text-position="bottom" |
| 211 | + centered |
| 212 | + > |
| 213 | + <v-tab title="First tab" icon="ti-user"> |
| 214 | + First tab content |
| 215 | + </v-tab> |
| 216 | + |
| 217 | + <v-tab title="Second tab" icon="ti-settings"> |
| 218 | + Second tab content |
| 219 | + </v-tab> |
| 220 | + |
| 221 | + <v-tab title="Third tab" icon="ti-check"> |
| 222 | + Third tab content |
| 223 | + </v-tab> |
| 224 | + </vue-tabs> |
| 225 | + |
| 226 | +</template> |
| 227 | + |
| 228 | +<script> |
| 229 | + Vue.use(VueTabs); |
| 230 | + export default {} |
| 231 | +</script> |
| 232 | +</script> |
| 233 | + |
| 234 | +## Vertical tabs |
| 235 | + |
| 236 | +<vuep template="#vertical"></vuep> |
| 237 | + |
| 238 | +<script v-pre type="text/x-template" id="vertical"> |
| 239 | +<template> |
| 240 | + <vue-tabs active-tab-color="#e74c3c" |
| 241 | + active-text-color="white" |
| 242 | + type="pills" |
| 243 | + :start-index="1" |
| 244 | + direction="vertical"> |
| 245 | + <v-tab title="First tab" icon="ti-user"> |
| 246 | + First tab content |
| 247 | + </v-tab> |
| 248 | + |
| 249 | + <v-tab title="Second tab" icon="ti-settings"> |
| 250 | + Second tab content |
| 251 | + </v-tab> |
| 252 | + |
| 253 | + <v-tab title="Third tab" icon="ti-check"> |
| 254 | + Third tab content |
| 255 | + </v-tab> |
| 256 | + </vue-tabs> |
| 257 | + |
| 258 | +</template> |
| 259 | + |
| 260 | +<script> |
| 261 | + Vue.use(VueTabs); |
| 262 | + export default {} |
| 263 | +</script> |
| 264 | +</script> |
0 commit comments