-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
tabs.html
315 lines (295 loc) · 13.8 KB
/
tabs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="en">
<head>
{{> head }}
</head>
<body>
{{> navbar }}
<main>
{{> intro}}
<div class="container">
<div class="row">
<div class="col s12 m8 offset-m1 xl7 offset-xl1">
<div id="introduction" class="section scrollspy">
<p class="caption">
The tabs structure consists of an unordered list of tabs that have hashes corresponding to tab ids. Then when you click on each tab, only the container with the
corresponding tab id will become visible. You can add the class
<code class="language-html">.disabled</code> to make a tab inaccessible.
</p>
<ul class="tabs tab-demo z-depth-1">
<li class="tab"><a href="#test16">Test 1</a></li>
<li class="tab">
<a class="active" href="#test17">Another Tab</a>
</li>
<li class="tab"><a href="#test18">Test 3</a></li>
<li class="tab"><a href="#test19">Test 4</a></li>
</ul>
<div id="test16" class="col s12"><p>Test 1</p></div>
<div id="test17" class="col s12"><p>Another Tab content</p></div>
<div id="test18" class="col s12"><p>Test 3</p></div>
<div id="test19" class="col s12"><p>Test 4</p></div>
</div>
<p>Tabs automatically become scrollable when there are too many to fit on screen</p>
<ul class="tabs tab-demo z-depth-1">
<li class="tab"><a href="#test5">Test 1</a></li>
<li class="tab"><a class="active" href="#test6">Test 2</a></li>
<li class="tab"><a href="#test7">Test 3</a></li>
<li class="tab"><a href="#test8">Test 4</a></li>
<li class="tab"><a class="active" href="#test9">Test 5</a></li>
<li class="tab disabled"><a href="#test10">Disabled Tab</a></li>
<li class="tab"><a href="#test11">Test 7</a></li>
<li class="tab"><a href="#test12">Test 8</a></li>
<li class="tab"><a class="active" href="#test13">Test 9</a></li>
<li class="tab disabled"><a href="#test14">Disabled Tab</a></li>
<li class="tab"><a href="#test15">Test 11</a></li>
</ul>
<div id="test5" class="col s12"><p>Test 1</p></div>
<div id="test6" class="col s12"><p>Test 2</p></div>
<div id="test7" class="col s12"><p>Test 3</p></div>
<div id="test8" class="col s12"><p>Test 4</p></div>
<div id="test9" class="col s12"><p>Test 5</p></div>
<div id="test10" class="col s12"><p>Test 6</p></div>
<div id="test11" class="col s12"><p>Test 7</p></div>
<div id="test12" class="col s12"><p>Test 8</p></div>
<div id="test13" class="col s12"><p>Test 9</p></div>
<div id="test14" class="col s12"><p>Test 10</p></div>
<div id="test15" class="col s12"><p>Test 11</p></div>
<div id="structure" class="section scrollspy">
<pre><code class="language-html">
<xmp>
<div class="row">
<div class="col s12">
<ul class="tabs">
<li class="tab col s3"><a href="#test1">Test 1</a></li>
<li class="tab col s3"><a class="active" href="#test2">Test 2</a></li>
<li class="tab col s3 disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab col s3"><a href="#test4">Test 4</a></li>
</ul>
</div>
<div id="test1" class="col s12">Test 1</div>
<div id="test2" class="col s12">Test 2</div>
<div id="test3" class="col s12">Test 3</div>
<div id="test4" class="col s12">Test 4</div>
</div>
</xmp>
</code></pre>
</div>
<div id="initialization" class="section scrollspy">
<h3 class="header">Initialization</h3>
<pre><code class="language-javascript">
var instance = M.Tabs.init(el, options);
</code></pre>
</div>
<div id="options" class="section scrollspy">
<h3 class="header">Options</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>duration</td>
<td>Number</td>
<td>300</td>
<td>Transition duration in milliseconds.</td>
</tr>
<tr>
<td>onShow</td>
<td>Function</td>
<td>null</td>
<td>Callback for when a new tab content is shown.</td>
</tr>
<tr>
<td>swipeable</td>
<td>Boolean</td>
<td>false</td>
<td>Set to true to enable swipeable tabs. This also uses the responsiveThreshold option.</td>
</tr>
<tr>
<td>responsiveThreshold</td>
<td>Number</td>
<td>Infinity</td>
<td>The maximum width of the screen, in pixels, where the swipeable functionality initializes.</td>
</tr>
</tbody>
</table>
</div>
<div id="method" class="section scrollspy">
<h3 class="header">Methods</h3>
<blockquote>
<p>All the methods are called on the plugin instance. You can get the plugin instance like this:</p>
<pre><code class="language-javascript col s12">
var instance = M.Tabs.getInstance(elem);
</code></pre>
</blockquote>
<h5 class="method-header">.select();</h5>
<p>Show tab content that corresponds to the tab with the id</p>
<h6>Arguments</h6>
<p><b>String:</b> The id of the tab that you want to switch to</p>
<pre><code class="language-javascript col s12">instance.select('tab_id');</code></pre>
<h5 class="method-header">.updateTabIndicator();</h5>
<p>Recalculate tab indicator position. This is useful when the indicator position is not correct.</p>
<pre><code class="language-javascript col s12">instance.updateTabIndicator();</code></pre>
<h5 class="method-header">.destroy();</h5>
<p>Destroy plugin instance and teardown</p>
<pre><code class="language-javascript col s12">instance.destroy();</code></pre>
</div>
<div id="properties" class="section scrollspy">
<h3 class="header">Properties</h3>
<table class="striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>el</td>
<td>Element</td>
<td>The DOM element the plugin was initialized with.</td>
</tr>
<tr>
<td>options</td>
<td>Object</td>
<td>The options the instance was initialized with.</td>
</tr>
<tr>
<td>index</td>
<td>Number</td>
<td>The index of tab that is currently shown.</td>
</tr>
</tbody>
</table>
</div>
<div id="preselecting" class="section scrollspy">
<h3 class="header">Preselecting a tab</h3>
<p>
By default, the first tab is selected. But if this is not what you want, you can preselect a tab by either passing in the hash in the url ex:<code
class="language-html"
>#test2</code
>. Or you can add the class <code class="language-html">active</code> to the <code class="language-html">a</code> tag.
</p>
<pre><code class="language-html">
<li class="tab"><a class="active" href="#test3">Test 3</a></li>
</code></pre>
</div>
<div id="external" class="section scrollspy">
<h3 class="header">Linking to an External Page</h3>
<p>
By default, Materialize tabs will ignore their default anchor behaviour. To force a tab to behave as a regular hyperlink, just specify the
<code class="language-html">target</code> property of that link! A list of <code class="language-html">target</code> values may be
<a href="https://www.w3schools.com/tags/att_a_target.asp">found here</a>.
</p>
<pre><code class="language-html">
<xmp>
<li class="tab col s2">
<a target="_blank" href="https://github.com/materializecss/materialize">External link in new window</a>
</li>
<li class="tab col s2">
<a target="_self" href="https://github.com/materializecss/materialize">External link in same window</a>
</li>
</xmp>
</code></pre>
</div>
<div id="swipeable" class="section scrollspy">
<h3 class="header">Swipeable Tabs</h3>
<p>
By setting the
<code class="language-javascript">swipeable</code> option to <code class="language-html">true</code>, you can enable tabs where you can swipe on touch enabled
devices to switch tabs. Make sure you keep the tab content divs in the same wrapping container. You can also set the
<code class="language-javascript">responsiveThreshold</code>
option to a screen width in pixels where the swipeable functionality will activate.
</p>
<p>Note: This is also touch compatible! Try swiping with your finger to scroll through the carousel.</p>
<ul id="tabs-swipe-demo" class="tabs">
<li class="tab col s3"><a href="#test-swipe-1">Test 1</a></li>
<li class="tab col s3">
<a class="active" href="#test-swipe-2">Test 2</a>
</li>
<li class="tab col s3"><a href="#test-swipe-3">Test 3</a></li>
</ul>
<div id="test-swipe-1" class="col s12 blue">Test 1</div>
<div id="test-swipe-2" class="col s12 red">Test 2</div>
<div id="test-swipe-3" class="col s12 green">Test 3</div>
<pre><code class="language-html">
<xmp>
<ul id="tabs-swipe-demo" class="tabs">
<li class="tab col s3"><a href="#test-swipe-1">Test 1</a></li>
<li class="tab col s3"><a class="active" href="#test-swipe-2">Test 2</a></li>
<li class="tab col s3"><a href="#test-swipe-3">Test 3</a></li>
</ul>
<div id="test-swipe-1" class="col s12 blue">Test 1</div>
<div id="test-swipe-2" class="col s12 red">Test 2</div>
<div id="test-swipe-3" class="col s12 green">Test 3</div>
</xmp>
</code></pre>
</div>
<div id="fixed-width" class="scrollspy section">
<h3 class="header">Fixed Width Tabs</h3>
<p>
Add the
<code class="language-html">.tabs-fixed-width</code> class to the tabs container
</p>
<ul class="tabs tabs-fixed-width tab-demo z-depth-1">
<li class="tab"><a href="#test1">Test 1</a></li>
<li class="tab"><a class="active" href="#test2">Test 2</a></li>
<li class="tab disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab"><a href="#test4">Test 4</a></li>
<li class="tab"><a href="#test0">Test 5</a></li>
</ul>
<div id="test1" class="col s12"><p>Test 1</p></div>
<div id="test2" class="col s12"><p>Test 2</p></div>
<div id="test3" class="col s12"><p>Test 3</p></div>
<div id="test4" class="col s12"><p>Test 4</p></div>
<div id="test0" class="col s12"><p>Test 5</p></div>
<pre><code class="language-html">
<xmp>
<ul class="tabs tabs-fixed-width tab-demo z-depth-1">
<li class="tab"><a href="#test1">Test 1</a></li>
<li class="tab"><a class="active" href="#test2">Test 2</a></li>
<li class="tab disabled"><a href="#test3">Disabled Tab</a></li>
<li class="tab"><a href="#test4">Test 4</a></li>
<li class="tab"><a href="#test0">Test 5</a></li>
</ul>
<div id="test1" class="col s12"><p>Test 1</p></div>
<div id="test2" class="col s12"><p>Test 2</p></div>
<div id="test3" class="col s12"><p>Test 3</p></div>
<div id="test4" class="col s12"><p>Test 4</p></div>
<div id="test0" class="col s12"><p>Test 5</p></div>
</xmp>
</code></pre>
</div>
</div>
<!-- Table of Contents -->
<div class="col hide-on-small-only m3 xl3">
<div class="toc-wrapper">
<div style="height: 1px">
<ul class="section table-of-contents">
<li><a href="#introduction">Introduction</a></li>
<li><a href="#structure">Structure</a></li>
<li><a href="#initialization">Initialization</a></li>
<li><a href="#options">Options</a></li>
<li><a href="#method">Methods</a></li>
<li><a href="#properties">Properties</a></li>
<li><a href="#preselecting">Preselecting</a></li>
<li><a href="#external">External Links</a></li>
<li><a href="#swipeable">Swipeable Tabs</a></li>
<li><a href="#fixed-width">Fixed Width Tabs</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</main>
{{> footer }}
<script type="module" src="/src/main.ts"></script>
</body>
</html>