/
mdc-input-demo.html
789 lines (721 loc) · 26 KB
/
mdc-input-demo.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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Basic</mat-toolbar>
<mat-card-content>
<form>
<mat-form-field class="demo-full-width">
<mat-label>Company (disabled)</mat-label>
<input matNativeControl disabled value="Google">
</mat-form-field>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field style="width: 100%">
<input matInput placeholder="First name">
</mat-form-field>
</td>
<td>
<mat-form-field style="width: 100%">
<mat-label>Long last name that will be truncated</mat-label>
<input matInput>
</mat-form-field>
</td>
</tr></table>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Address</mat-label>
<textarea matInput>1600 Amphitheatre Pkway</textarea>
</mat-form-field>
<mat-form-field class="demo-full-width">
<mat-label>Address 2</mat-label>
<textarea matNativeControl></textarea>
</mat-form-field>
</p>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field class="demo-full-width">
<mat-label>City</mat-label>
<input matInput value="Mountain View">
</mat-form-field>
</td>
<td>
<mat-form-field class="demo-full-width">
<mat-label>State</mat-label>
<input matInput maxLength="2" value="CA">
</mat-form-field>
</td>
<td>
<mat-form-field class="demo-full-width">
<mat-label>Postal code</mat-label>
<input matInput #postalCode maxLength="5" value="94043" pattern="[0-9]{5}">
<mat-hint align="end">
<mat-icon>mode_edit</mat-icon>
<span aria-live="polite">{{postalCode.value.length}} / 5</span>
</mat-hint>
</mat-form-field>
</td>
</tr></table>
</form>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Error messages</mat-toolbar>
<mat-card-content>
<h4>Regular</h4>
<p>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput [(ngModel)]="errorMessageExample1" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>Email</mat-label>
<input matInput [formControl]="emailFormControl">
<mat-error *ngIf="emailFormControl.hasError('required')">
This field is required
</mat-error>
<mat-error *ngIf="emailFormControl.hasError('pattern')">
Please enter a valid email address
</mat-error>
</mat-form-field>
</p>
<h4>With hint</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput [(ngModel)]="errorMessageExample2" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<form novalidate>
<h4>Inside a form</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput name="example" [(ngModel)]="errorMessageExample3" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<button color="primary" mat-raised-button>Submit</button>
</form>
<h4>With a custom error function</h4>
<mat-form-field>
<mat-label>Example</mat-label>
<input matInput
[(ngModel)]="errorMessageExample4"
[errorStateMatcher]="customErrorStateMatcher"
required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Prefix + Suffix</mat-toolbar>
<mat-card-content>
<h4>Text</h4>
<mat-form-field [appearance]="prefixSuffixAppearance" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix *ngIf="showPrefix">$</span>
<span matTextSuffix>.00</span>
</mat-form-field>
<h4>Text (always outline)</h4>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$</span>
<span matTextSuffix>.00</span>
</mat-form-field>
<h4>Icons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
<mat-icon matIconPrefix *ngIf="showPrefix">calendar_today</mat-icon>
<mat-icon matIconSuffix>mode_edit</mat-icon>
</mat-form-field>
<h4>Icon buttons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
<button mat-icon-button matIconPrefix *ngIf="showPrefix">
<mat-icon>calendar_today</mat-icon>
</button>
<button mat-icon-button matIconSuffix>
<mat-icon>mode_edit</mat-icon>
</button>
</mat-form-field>
<h4>Text & Icons</h4>
<mat-form-field [appearance]="prefixSuffixAppearance">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$</span>
<span matTextSuffix>.00</span>
<button mat-icon-button matIconPrefix *ngIf="showPrefix">
<mat-icon>calendar_today</mat-icon>
</button>
<button mat-icon-button matIconSuffix>
<mat-icon>mode_edit</mat-icon>
</button>
</mat-form-field>
<p>
<mat-button-toggle-group [(ngModel)]="prefixSuffixAppearance">
<mat-button-toggle value="fill">Fill</mat-button-toggle>
<mat-button-toggle value="outline">Outline</mat-button-toggle>
</mat-button-toggle-group>
</p>
<p>
<button (click)="showPrefix = !showPrefix">Toggle prefix</button>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Divider Colors</mat-toolbar>
<mat-card-content>
<h4>Input</h4>
<mat-form-field color="primary" >
<mat-label>Default color</mat-label>
<input matInput value="example">
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<input matInput value="example">
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<input matInput value="example">
</mat-form-field>
<h4>Textarea</h4>
<mat-form-field color="primary">
<mat-label>Default color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<textarea matInput>example</textarea>
</mat-form-field>
<h4>With error</h4>
<mat-form-field color="primary" >
<mat-label>Default color</mat-label>
<input matInput [(ngModel)]="dividerColorExample1" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field color="accent">
<mat-label>Accent color</mat-label>
<input matInput [(ngModel)]="dividerColorExample2" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
<mat-form-field color="warn">
<mat-label>Warn color</mat-label>
<input matInput [(ngModel)]="dividerColorExample3" required>
<mat-error>This field is required</mat-error>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Hints</mat-toolbar>
<mat-card-content>
<h4>Input</h4>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Character count (100 max)</mat-label>
<input matInput
#characterCountInputHintExample
maxLength="100"
value="Hello world. How are you?">
<mat-hint align="end" aria-live="polite">
{{characterCountInputHintExample.value.length}} / 100
</mat-hint>
</mat-form-field>
</p>
<h4>Textarea</h4>
<p>
<mat-form-field class="demo-full-width">
<mat-label>Character count (100 max)</mat-label>
<textarea matInput
#characterCountTextareaHintExample
maxLength="100">Hello world. How are you?</textarea>
<mat-hint align="end" aria-live="polite">
{{characterCountTextareaHintExample.value.length}} / 100
</mat-hint>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">
<span>
Hello
<mat-form-field color="accent">
<mat-label>First name</mat-label>
<input matInput [(ngModel)]="name" type="text">
</mat-form-field>,
how are you?
</span>
</mat-toolbar>
<mat-card-content>
<p>
<mat-form-field>
<mat-label>Disabled field</mat-label>
<input matInput disabled value="Value">
</mat-form-field>
<mat-form-field>
<mat-label>Label</mat-label>
<input matInput disabled required>
</mat-form-field>
<mat-form-field>
<mat-label>Required field</mat-label>
<input matInput required>
</mat-form-field>
</p>
<p>
<mat-form-field style="width: 100%">
<mat-label>100% width label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field style="width: 100%">
<mat-label>Character count (100 max)</mat-label>
<input matInput #input maxLength="100">
<mat-hint align="end" aria-live="polite">{{input.value.length}} / 100</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field hintLabel="Hint label" style="width: 100%">
<mat-label>Show hint label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field>
<input matInput>
<mat-label>
I <mat-icon>favorite</mat-icon> <b>bold</b> label
</mat-label>
<mat-hint>
I also <mat-icon>home</mat-icon> <i>italic</i> hint labels
</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field hintLabel="Hint label" style="width: 100%">
<mat-label>Show hint label with character count</mat-label>
<input matInput #hintLabelWithCharCount>
<mat-hint align="end" aria-live="polite">{{hintLabelWithCharCount.value.length}}</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field style="margin-bottom: 4em">
<mat-label>Enter text to count</mat-label>
<textarea matInput #longHint></textarea>
<mat-hint>Enter
some text to count how many characters are in it. The character count is shown on
the right.
</mat-hint>
<mat-hint align="end" style="white-space: nowrap" aria-live="polite">
Length: {{longHint.value.length}}
</mat-hint>
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="color">Check to change the color:</mat-checkbox>
<mat-form-field [color]="color ? 'primary' : 'accent'">
<input matInput [placeholder]="color ? 'Primary color' : 'Accent color'">
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="requiredField"> Check to make required:</mat-checkbox>
<mat-form-field>
<mat-label>{{requiredField ? 'Required field' : 'Not required field'}}</mat-label>
<input matInput [required]="requiredField">
</mat-form-field>
</p>
<p>
<mat-checkbox [(ngModel)]="hideRequiredMarker">Check to hide the required marker:</mat-checkbox>
<mat-form-field [hideRequiredMarker]="hideRequiredMarker" style="width: 300px">
<mat-label>
{{hideRequiredMarker ? 'Required Without Marker' : 'Required With Marker'}}
</mat-label>
<input matInput required>
</mat-form-field>
</p>
<p>
<mat-button-toggle-group [(ngModel)]="floatingLabel">
<mat-button-toggle value="auto">Auto Float</mat-button-toggle>
<mat-button-toggle value="always">Always Float</mat-button-toggle>
</mat-button-toggle-group>
</p>
<p>
<mat-form-field [floatLabel]="floatingLabel">
<mat-label>Label</mat-label>
<input matInput>
</mat-form-field>
</p>
<p>
<mat-form-field [floatLabel]="floatingLabel">
<mat-label>What is your favorite color?</mat-label>
<input matInput type="color" value="#00ff00">
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Prefixed</mat-label>
<input matInput value="example">
<span matTextPrefix>Example: </span>
</mat-form-field>
<mat-form-field class="demo-text-align-end">
<mat-label>Suffixed</mat-label>
<input matInput value="123">
<span matTextSuffix>.00 €</span>
</mat-form-field>
<br/>
Both:
<mat-form-field class="demo-text-align-end">
<mat-label>Email address</mat-label>
<input matInput #email="matInput" value="angular-core">
<span matIconPrefix>
<mat-icon [class.primary]="email.focused">email</mat-icon>
</span>
<span matTextSuffix [class.primary]="email.focused"> @gmail.com</span>
</mat-form-field>
</p>
<p>
Empty: <mat-form-field><input matInput></mat-form-field>
<label>Label: <mat-form-field><input matInput></mat-form-field></label>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Number Inputs</mat-toolbar>
<mat-card-content>
<table width="100%">
<thead>
<td>Table</td>
<td colspan="3">
<button (click)="addABunch(5)">Add 5</button>
<button (click)="addABunch(10)">Add 10</button>
<button (click)="addABunch(100)">Add 100</button>
<button (click)="addABunch(1000)">Add 1000</button>
</td>
</thead>
<tr *ngFor="let item of items; let i = index">
<td>{{i+1}}</td>
<td>
<mat-form-field>
<mat-label>Value</mat-label>
<input matInput
type="number"
[(ngModel)]="items[i].value">
</mat-form-field>
</td>
<td>
<input type="number" [(ngModel)]="items[i].value">
</td>
<td>{{item.value}}</td>
</tr>
</table>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Forms</mat-toolbar>
<mat-card-content>
<mat-form-field>
<mat-label>Reactive</mat-label>
<input matInput [formControl]="formControl">
</mat-form-field>
<mat-form-field>
<mat-label>Template</mat-label>
<input matInput [(ngModel)]="model" required [disabled]="ctrlDisabled">
</mat-form-field>
<button mat-raised-button color="primary"
(click)="formControl.enabled ? formControl.disable() : formControl.enable()">
DISABLE REACTIVE CTRL
</button>
<button mat-raised-button color="primary" (click)="ctrlDisabled = !ctrlDisabled">
DISABLE TD CTRL
</button>
<div>
<mat-form-field>
<mat-label>Delayed value</mat-label>
<input matInput [formControl]="delayedFormControl">
</mat-form-field>
</div>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Floating labels</mat-toolbar>
<mat-card-content>
<div>
<mat-form-field>
<input matInput [formControl]="placeholderTestControl">
</mat-form-field>
<mat-form-field>
<input matInput [formControl]="placeholderTestControl" placeholder="Only placeholder">
</mat-form-field>
<mat-form-field>
<mat-label>Only label</mat-label>
<input matInput [formControl]="placeholderTestControl">
</mat-form-field>
<mat-form-field>
<mat-label>Label and placeholder</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="This is the placeholder">
</mat-form-field>
<mat-form-field floatLabel="always">
<mat-label>Always float</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="This is the placeholder">
</mat-form-field>
<mat-form-field>
<mat-label>Label w/ placeholder</mat-label>
<input matInput [formControl]="placeholderTestControl" placeholder="Placeholder">
</mat-form-field>
</div>
<button
mat-raised-button
color="primary"
(click)="togglePlaceholderTestValue()">Toggle value</button>
<button
mat-raised-button
color="primary"
(click)="togglePlaceholderTestTouched()">Toggle touched</button>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Textarea Autosize</mat-toolbar>
<mat-card-content>
<h3>Regular <textarea></h3>
<textarea class="demo-textarea" cdkTextareaAutosize cdkAutosizeMaxRows="10"></textarea>
<h3>Regular <textarea> with maxRows and minRows</h3>
<div>
<label>minRows<input type="number" #minRows class="demo-rows" (input)="1+1"></label>
<label>maxRows<input type="number" #maxRows class="demo-rows" (input)="1+1"></label>
</div>
<textarea class="demo-textarea"
cdkTextareaAutosize
[cdkAutosizeMinRows]="parseNumber(minRows.value)"
[cdkAutosizeMaxRows]="parseNumber(maxRows.value)"></textarea>
<button type="button" (click)="minRows.value = (parseNumber(minRows.value) - 1) + ''">Decrement minRows</button>
<h3><textarea> with mat-form-field</h3>
<div>
<mat-form-field>
<mat-label>Autosized textarea</mat-label>
<textarea matInput cdkTextareaAutosize cdkAutosizeMaxRows="10"></textarea>
</mat-form-field>
</div>
<h3><textarea> with ngModel</h3>
<div>
<label>Input with same ngModel <input [(ngModel)]="textareaNgModelValue"></label>
</div>
<label>
Plain textarea with auto size
<textarea cdkTextareaAutosize [(ngModel)]="textareaNgModelValue"></textarea>
</label>
<h3><textarea> with bindable autosize </h3>
<mat-checkbox [(ngModel)]="textareaAutosizeEnabled" name="autosizeEnabledCheckbox">
Autosize enabled
</mat-checkbox>
<textarea [cdkTextareaAutosize]="textareaAutosizeEnabled"></textarea>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Appearance</mat-toolbar>
<mat-card-content>
<mat-form-field appearance="fill" [color]="color">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<mat-form-field appearance="outline" [color]="color">
<mat-label>Outline appearance</mat-label>
<input matInput [(ngModel)]="outlineAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
<table style="width: 100%" cellspacing="0"><tr>
<td>
<mat-form-field appearance="fill" [color]="color" style="width: 100%">
<mat-label>Fill appearance</mat-label>
<input matInput [(ngModel)]="fillAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
</td>
<td>
<mat-form-field appearance="outline" [color]="color" style="width: 100%">
<mat-label>Outline appearance</mat-label>
<input matInput [(ngModel)]="outlineAppearance" required>
<mat-error>This field is required</mat-error>
<mat-hint>Please type something here</mat-hint>
</mat-form-field>
</td>
</tr></table>
<mat-button-toggle-group [(ngModel)]="color">
<mat-button-toggle value="primary">Primary</mat-button-toggle>
<mat-button-toggle value="accent">Accent</mat-button-toggle>
<mat-button-toggle value="warn">Warn</mat-button-toggle>
</mat-button-toggle-group>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Autofill</mat-toolbar>
<mat-card-content>
<form novalidate>
<mat-checkbox [(ngModel)]="customAutofillStyle" name="custom">
Use custom autofill style
</mat-checkbox>
<mat-form-field>
<mat-label>Autofill monitored</mat-label>
<input matInput (cdkAutofill)="isAutofilled = $event.isAutofilled" name="autofill"
[class.demo-custom-autofill-style]="customAutofillStyle">
</mat-form-field>
<button color="primary" mat-raised-button>Submit</button>
<span> is autofilled? {{isAutofilled ? 'yes' : 'no'}}</span>
</form>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Textarea form-fields</mat-toolbar>
<mat-card-content>
<mat-form-field appearance="fill" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<textarea matInput [disabled]="disableTextarea"></textarea>
</mat-form-field>
<mat-form-field appearance="outline" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<textarea matInput [disabled]="disableTextarea"></textarea>
</mat-form-field>
<p>
<mat-checkbox [(ngModel)]="disableTextarea">Disable textarea form-fields</mat-checkbox>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Appearance toggle</mat-toolbar>
<mat-card-content>
<mat-form-field [appearance]="appearance" class="demo-horizontal-spacing">
<mat-label>Label</mat-label>
<input matInput value="Initial">
</mat-form-field>
<p>
<mat-button-toggle-group [(ngModel)]="appearance">
<mat-button-toggle value="fill">Fill</mat-button-toggle>
<mat-button-toggle value="outline">Outline</mat-button-toggle>
</mat-button-toggle-group>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Autocomplete</mat-toolbar>
<mat-card-content>
<p>
<mat-form-field>
<mat-label>Pick Number</mat-label>
<input type="text" aria-label="Number" matInput
[matAutocomplete]="autoComplete1">
<mat-autocomplete #autoComplete1="matAutocomplete">
<mat-option *ngFor="let option of options" [value]="option">{{option}}</mat-option>
</mat-autocomplete>
</mat-form-field>
</p>
<p>
<mat-form-field appearance="outline">
<mat-label>Pick Number</mat-label>
<input type="text" aria-label="Number" matInput
[matAutocomplete]="autoComplete2">
<mat-autocomplete #autoComplete2="matAutocomplete">
<mat-option *ngFor="let option of options" [value]="option">{{option}}</mat-option>
</mat-autocomplete>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Outline form field in a tab</mat-toolbar>
<mat-card-content>
<mat-tab-group>
<mat-tab label="Tab 1">
<mat-form-field appearance="outline">
<mat-label>Tab 1 input</mat-label>
<input matInput value="test">
</mat-form-field>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$ </span>
<span matTextSuffix>.00</span>
</mat-form-field>
</mat-tab>
<mat-tab label="Tab 2">
<mat-form-field appearance="outline">
<mat-label>Tab 2 input</mat-label>
<input matInput value="test">
</mat-form-field>
<mat-form-field appearance="outline" class="demo-text-align-end">
<mat-label>Amount</mat-label>
<input matInput>
<span matTextPrefix>$ </span>
<span matTextPrefix *ngIf="showSecondPrefix">! </span>
<span matTextSuffix>.00</span>
</mat-form-field>
</mat-tab>
</mat-tab-group>
<button (click)="showSecondPrefix = !showSecondPrefix">Toggle second prefix.</button>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Baseline</mat-toolbar>
<mat-card-content>
<span style="display: inline-block; margin-top: 20px">Shifted text</span>
<mat-form-field>
<mat-label>Label</mat-label>
<input matInput>
</mat-form-field>
<p>
Textarea alignment
</p>
<mat-form-field appearance="outline">
<mat-label>Textarea</mat-label>
<textarea matInput rows="1"></textarea>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field appearance="outline">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
</mat-card-content>
</mat-card>
<mat-card class="demo-card demo-basic">
<mat-toolbar color="primary">Examples</mat-toolbar>
<mat-card-content>
<h4>Custom control</h4>
<mdc-form-field-custom-control-example></mdc-form-field-custom-control-example>
<p>
<mat-form-field appearance="outline">
<mat-label>Phone number</mat-label>
<example-tel-input required></example-tel-input>
<mat-icon matIconSuffix>phone</mat-icon>
<mat-hint>Include area code</mat-hint>
</mat-form-field>
</p>
<p>
<mat-form-field>
<mat-label>Label</mat-label>
<select matNativeControl>
<option>First</option>
<option>Second</option>
</select>
</mat-form-field>
</p>
<p>
<mat-form-field appearance="outline">
<mat-label>Label</mat-label>
<select matNativeControl>
<option>First</option>
<option>Second</option>
</select>
</mat-form-field>
</p>
</mat-card-content>
</mat-card>