-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
select.html
394 lines (375 loc) · 15.6 KB
/
select.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!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>
Select allows user input through specified options. Make sure you wrap it in a
<code class="language-html">.input-field</code> for proper alignment with other text fields.
</p>
<div class="row">
<form class="col s12">
<div class="row">
<div class="input-field outlined col s12 m6">
<select id="select-example-1">
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="select-example-1">Materialize Select</label>
</div>
<div class="col s12">
<p>
You can add the property
<code class="language-html">multiple</code> to get the multiple select and select several options.
</p>
</div>
<div class="input-field col s12 m6">
<select id="select-example-2" multiple>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="select-example-2">Materialize Multiple Select</label>
</div>
<div class="col s12">
<p>We also support optgroups in our selects.</p>
</div>
<div class="input-field col s12 m6">
<select id="select-example-3">
<optgroup label="team 1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</optgroup>
<optgroup label="team 2">
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</optgroup>
</select>
<label for="select-example-3">Optgroups</label>
</div>
<div class="col s12">
<p>
You can add icons to your options in any type of select. In the option you add the image source with the
<code class="language-html">data-icon</code>
attribute.
</p>
</div>
<div class="input-field col s12 m6">
<select id="select-example-4" class="icons">
<option value="" disabled selected>Choose your option</option>
<option value="" data-icon="images/sample-1.jpg">example 1</option>
<option value="" data-icon="images/office.jpg">example 2</option>
<option value="" data-icon="images/yuna.jpg">example 3</option>
</select>
<label for="select-example-4">Images in select</label>
</div>
<div class="input-field col s12 m6">
<select id="select-example-5" class="icons">
<option value="" disabled selected>Choose your option</option>
<option value="" data-icon="images/sample-1.jpg" class="left">example 1</option>
<option value="" data-icon="images/office.jpg" class="left">example 2</option>
<option value="" data-icon="images/yuna.jpg" class="left">example 3</option>
</select>
<label for="select-example-5">Images in select</label>
</div>
<div class="col s12">
<p>
You can add the class
<code class="language-html">browser-default</code> to get the browser default.
</p>
</div>
<div class="col s12 m6">
<label for="select-example-6">Browser Select</label>
<select id="select-example-6" class="browser-default">
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</div>
</div>
</form>
<div class="col s12">
<pre><code class="language-html">
<xmp>
<div class="input-field col s12">
<select id="form-select-1">
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="form-select-1">Materialize Select</label>
</div>
<div class="input-field col s12">
<select id="form-select-2" multiple>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="form-select-2">Materialize Multiple Select</label>
</div>
<div class="input-field col s12">
<select id="form-select-3">
<optgroup label="team 1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</optgroup>
<optgroup label="team 2">
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</optgroup>
</select>
<label for="form-select-3">Optgroups</label>
</div>
<div class="input-field col s12 m6">
<select id="form-select-4" class="icons">
<option value="" disabled selected>Choose your option</option>
<option value="" data-icon="images/sample-1.jpg">example 1</option>
<option value="" data-icon="images/office.jpg">example 2</option>
<option value="" data-icon="images/yuna.jpg">example 3</option>
</select>
<label for="form-select-4">Images in select</label>
</div>
<div class="input-field col s12 m6">
<select id="form-select-5" class="icons">
<option value="" disabled selected>Choose your option</option>
<option value="" data-icon="images/sample-1.jpg" class="left">example 1</option>
<option value="" data-icon="images/office.jpg" class="left">example 2</option>
<option value="" data-icon="images/yuna.jpg" class="left">example 3</option>
</select>
<label for="form-select-5">Images in select</label>
</div>
<label for="form-select-6">Browser Select</label>
<select id="form-select-6" class="browser-default">
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</xmp>
</code></pre>
</div>
</div>
</div>
<div id="initialization" class="scrollspy section">
<h3 class="header">Initialization</h3>
<p>
You must initialize the select element as shown below. In addition, you will need a separate call to init() for any dynamically generated select or any changes to
an existing select.
</p>
<pre><code class="language-javascript">
document.addEventListener('DOMContentLoaded', function() {
var elems = document.querySelectorAll('select');
var instances = M.FormSelect.init(elems, {
// specify options here
});
});
</code></pre>
</div>
<div id="options" class="scrollspy section">
<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>classes</td>
<td>String</td>
<td>''</td>
<td>Classes to be added to the select wrapper element.</td>
</tr>
<tr>
<td>dropdownOptions</td>
<td>Object</td>
<td>{}</td>
<td>Pass options object to select dropdown initialization.</td>
</tr>
</tbody>
</table>
</div>
<div id="methods" class="scrollspy section">
<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.FormSelect.getInstance(elem);
</code></pre>
</blockquote>
<h5 class="method-header">.getSelectedValues();</h5>
<p>Get selected values in an array.</p>
<h6>Return Value</h6>
<p><b>Array:</b> Array of selected values.</p>
<pre><code class="language-javascript col s12">
instance.getSelectedValues();
</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="scrollspy section">
<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>isMultiple</td>
<td>Boolean</td>
<td>If this is a multiple select.</td>
</tr>
<tr>
<td>wrapper</td>
<td>Element</td>
<td>The select wrapper element.</td>
</tr>
<tr>
<td>dropdownOptions</td>
<td>Element</td>
<td>Dropdown UL element.</td>
</tr>
<tr>
<td>labelEl</td>
<td>Element</td>
<td>Label associated with the current select element. Is "null", if not detected.</td>
</tr>
<tr>
<td>input</td>
<td>Element</td>
<td>Text input that shows current selected option.</td>
</tr>
<tr>
<td>dropdown</td>
<td>Dropdown</td>
<td>Instance of the dropdown plugin for this select.</td>
</tr>
</tbody>
</table>
</div>
<div id="disabled" class="section scrollspy">
<div class="row">
<div class="col s12">
<h3 class="header">Disabled Styles</h3>
<p>
You can also add
<code class="language-html">disabled</code> to the select element to make the whole thing disabled. Or if you add <code class="language-html">disabled</code> to
the options, the individual options will be unselectable.
</p>
</div>
<form class="col s12 m6">
<div class="row">
<div class="col s12 input-field">
<select id="select-example-7" disabled>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="select-example-7">Materialize Disabled</label>
</div>
</div>
<div class="row">
<div class="col s12">
<label for="select-example-8">Browser Disabled</label>
<select id="select-example-8" class="browser-default" disabled>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</div>
</div>
</form>
<div class="col s12">
<pre><code class="language-html">
<xmp>
<div class="input-field">
<select id="form-select-7" disabled>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
<label for="form-select-7">Materialize Disabled</label>
</div>
<label for="form-select-8">Browser Disabled</label>
<select id="form-select-8" class="browser-default" disabled>
<option value="" disabled selected>Choose your option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</select>
</xmp>
</code></pre>
</div>
</div>
</div>
</div>
<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="#initialization">Initialization</a>
</li>
<li>
<a href="#options">Options</a>
</li>
<li>
<a href="#methods">Methods</a>
</li>
<li>
<a href="#properties">Properties</a>
</li>
<li>
<a href="#disabled">Disabled Styles</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</main>
{{> footer }}
<script type="module" src="/src/main.ts"></script>
</body>
</html>