1
1
# Tabs
2
2
3
- > Create tabbable panes of local content.
3
+ > Create tabbable panes of local content. The tabs component is built upon navs and cards internally.
4
4
5
5
6
6
## Basic usage
21
21
<!-- basic.vue -->
22
22
```
23
23
24
+ ** Tip:** You should supply each child ` <b-tab> ` component a unique ` key ` value if dynamically
25
+ adding, removing, showing, or hiding ` <b-tab> ` components. The ` key ` attribute is a special
26
+ Vue attribute, see https://vuejs.org/v2/api/#key ).
27
+
24
28
## Cards Integration
25
29
26
30
Tabs support integrating with bootstrap cards. Just add the ` card ` property to
@@ -31,10 +35,10 @@ header and remove the extra padding introduced by `card-body`.
31
35
``` html
32
36
<b-card no-body >
33
37
<b-tabs card >
34
- <b-tab title =" Tab 1" active >
38
+ <b-tab title =" Tab 1" active key = " tab-1 " >
35
39
Tab Contents 1
36
40
</b-tab >
37
- <b-tab title =" Tab 2" >
41
+ <b-tab title =" Tab 2" key = " tab-2 " >
38
42
Tab Contents 2
39
43
</b-tab >
40
44
</b-tabs >
@@ -50,19 +54,19 @@ To disable the `card-body` class, set the `no-body` prop on `<b-tab>` sub compon
50
54
``` html
51
55
<b-card no-body >
52
56
<b-tabs card >
53
- <b-tab no-body title =" Picture 1" active >
57
+ <b-tab no-body title =" Picture 1" active key = " tab-1 " >
54
58
<b-card-img bottom src =" https://picsum.photos/600/200/?image=21" />
55
59
<b-card-footer >Picture 1 footer</b-card-footer >
56
60
</b-tab >
57
- <b-tab no-body title =" Picture 2" >
61
+ <b-tab no-body title =" Picture 2" key = " tab-2 " >
58
62
<b-card-img bottom src =" https://picsum.photos/600/200/?image=25" />
59
63
<b-card-footer >Picture 2 footer</b-card-footer >
60
64
</b-tab >
61
- <b-tab no-body title =" Picture 3" >
65
+ <b-tab no-body title =" Picture 3" key = " tab-3 " >
62
66
<b-card-img bottom src =" https://picsum.photos/600/200/?image=26" />
63
67
<b-card-footer >Picture 3 footer</b-card-footer >
64
68
</b-tab >
65
- <b-tab title =" Text" >
69
+ <b-tab title =" Text" key = " tab-1 " >
66
70
<h5 >This tab does not have the <code >no-body</code > prop set</h5 >
67
71
Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla
68
72
tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat
@@ -88,10 +92,10 @@ the pill style variant.
88
92
``` html
89
93
<b-card no-body >
90
94
<b-tabs pills card >
91
- <b-tab title =" Tab 1" active >
95
+ <b-tab title =" Tab 1" active key = " tab-1 " >
92
96
Tab Contents 1
93
97
</b-tab >
94
- <b-tab title =" Tab 2" >
98
+ <b-tab title =" Tab 2" key = " tab-2 " >
95
99
Tab Contents 2
96
100
</b-tab >
97
101
</b-tabs >
@@ -107,10 +111,10 @@ Visually move the tab controls to the bottom by setting the prop `end`
107
111
``` html
108
112
<b-card no-body >
109
113
<b-tabs pills card end >
110
- <b-tab title =" Tab 1" active >
114
+ <b-tab title =" Tab 1" active key = " tab-1 " >
111
115
Tab Contents 1
112
116
</b-tab >
113
- <b-tab title =" Tab 2" >
117
+ <b-tab title =" Tab 2" key = " tab-1 " >
114
118
Tab Contents 2
115
119
</b-tab >
116
120
</b-tabs >
@@ -138,13 +142,13 @@ Vertical tabs work with or without `card` mode enabled.
138
142
``` html
139
143
<b-card no-body >
140
144
<b-tabs pills card vertical >
141
- <b-tab title =" Tab 1" active >
145
+ <b-tab title =" Tab 1" active key = " tab-1 " >
142
146
Tab Contents 1
143
147
</b-tab >
144
- <b-tab title =" Tab 2" >
148
+ <b-tab title =" Tab 2" key = " tab-2 " >
145
149
Tab Contents 2
146
150
</b-tab >
147
- <b-tab title =" Tab 3" >
151
+ <b-tab title =" Tab 3" key = " tab-3 " >
148
152
Tab Contents 3
149
153
</b-tab >
150
154
</b-tabs >
@@ -158,13 +162,13 @@ Visually move the tab controls to the right hand side by setting the `end` prop:
158
162
``` html
159
163
<b-card no-body >
160
164
<b-tabs pills card vertical end >
161
- <b-tab title =" Tab 1" active >
165
+ <b-tab title =" Tab 1" active key = " tab-1 " >
162
166
Tab Contents 1
163
167
</b-tab >
164
- <b-tab title =" Tab 2" >
168
+ <b-tab title =" Tab 2" key = " tab-2 " >
165
169
Tab Contents 2
166
170
</b-tab >
167
- <b-tab title =" Tab 3" >
171
+ <b-tab title =" Tab 3" key = " tab-3 " >
168
172
Tab Contents 3
169
173
</b-tab >
170
174
</b-tabs >
@@ -181,13 +185,13 @@ or column classes such as `col-2`, `col-3`, etc.
181
185
``` html
182
186
<b-card no-body >
183
187
<b-tabs pills card vertical nav-wrapper-class =" w-50" >
184
- <b-tab title =" Tab 1" active >
188
+ <b-tab title =" Tab 1" active key = " tab-1 " >
185
189
Tab Contents 1
186
190
</b-tab >
187
- <b-tab title =" Tab 2" >
191
+ <b-tab title =" Tab 2" key = " tab-2 " >
188
192
Tab Contents 2
189
193
</b-tab >
190
- <b-tab title =" Tab 3" >
194
+ <b-tab title =" Tab 3" key = " tab-3 " >
191
195
Tab Contents 3
192
196
</b-tab >
193
197
</b-tabs >
@@ -233,7 +237,7 @@ If you want to add custom content to tab title, like HTML code, icons, or anothe
233
237
234
238
``` html
235
239
<b-tabs >
236
- <b-tab active >
240
+ <b-tab active key = " tab-1 " >
237
241
<!-- Add your custom title here-->
238
242
<template slot =" title" >
239
243
i'm <i >Custom</i > <strong >Title</strong >
@@ -260,13 +264,13 @@ You may need to accomodate your custom classes for this._
260
264
<template >
261
265
<b-card no-body >
262
266
<b-tabs card v-model =" tabIndex" >
263
- <b-tab title =" Tab 1" :title-link-class =" linkClass(0)" >
267
+ <b-tab title =" Tab 1" :title-link-class =" linkClass(0)" key = " tab-1 " >
264
268
Tab Contents 1
265
269
</b-tab >
266
- <b-tab title =" Tab 2" :title-link-class =" linkClass(1)" >
270
+ <b-tab title =" Tab 2" :title-link-class =" linkClass(1)" key = " tab-2 " >
267
271
Tab Contents 2
268
272
</b-tab >
269
- <b-tab title =" Tab 3" :title-link-class =" linkClass(2)" >
273
+ <b-tab title =" Tab 3" :title-link-class =" linkClass(2)" key = " tab-3 " >
270
274
Tab Contents 3
271
275
</b-tab >
272
276
</b-tabs >
@@ -328,14 +332,14 @@ as it is not possble to use key presses to jump out of a text (or test-like) inp
328
332
<!-- Tabs with card integration -->
329
333
<b-card no-body >
330
334
<b-tabs small card v-model =" tabIndex" >
331
- <b-tab title =" General" >
335
+ <b-tab title =" General" key = " tab-1 " >
332
336
I'm the first fading tab
333
337
</b-tab >
334
- <b-tab title =" Edit profile" >
338
+ <b-tab title =" Edit profile" key = " tab-2 " >
335
339
I'm the second tab
336
340
<b-card >I'm the card in tab</b-card >
337
341
</b-tab >
338
- <b-tab title =" Premium Plan" disabled >
342
+ <b-tab title =" Premium Plan" disabled key = " tab-3 " >
339
343
Sibzamini!
340
344
</b-tab >
341
345
<b-tab title =" Info" >
@@ -376,8 +380,8 @@ export default {
376
380
<div >
377
381
<b-card no-body >
378
382
<b-tabs card >
379
- <!-- Render Tabs -->
380
- <b-tab :title =" `Tab ${i}`" v-for =" i in tabs" :key =" i " >
383
+ <!-- Render Tabs, supply a unique `key` to each tab -->
384
+ <b-tab :title =" `Tab ${i}`" v-for =" i in tabs" :key =" `dyntab-${i}` " >
381
385
Tab Contents {{i}}
382
386
<b-btn size =" sm" variant =" danger" class =" float-right" @click =" ()=>closeTab(i)" >
383
387
Close tab
0 commit comments