Skip to content

docs(examples): all examples should use mat-form-field's fill appearance by default #18252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-full-width">
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker">
<mat-icon matDatepickerToggleIcon>keyboard_arrow_down</mat-icon>
</mat-datepicker-toggle>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-full-width">
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker [dateClass]="dateClass" #picker></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
<p>
<mat-form-field>
<input matInput [matDatepicker]="dp1" placeholder="Completely disabled" disabled>
<mat-label>Completely disabled</mat-label>
<input matInput [matDatepicker]="dp1" disabled>
<mat-datepicker-toggle matSuffix [for]="dp1"></mat-datepicker-toggle>
<mat-datepicker #dp1></mat-datepicker>
</mat-form-field>
</p>

<p>
<mat-form-field>
<input matInput [matDatepicker]="dp2" placeholder="Popup disabled">
<mat-label>Popup disabled</mat-label>
<input matInput [matDatepicker]="dp2">
<mat-datepicker-toggle matSuffix [for]="dp2" disabled></mat-datepicker-toggle>
<mat-datepicker #dp2></mat-datepicker>
</mat-form-field>
</p>

<p>
<mat-form-field>
<input matInput [matDatepicker]="dp3" placeholder="Input disabled" disabled>
<mat-label>Input disabled</mat-label>
<input matInput [matDatepicker]="dp3" disabled>
<mat-datepicker-toggle matSuffix [for]="dp3"></mat-datepicker-toggle>
<mat-datepicker #dp3 disabled="false"></mat-datepicker>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Input & change events"
<mat-label>Input & change events</mat-label>
<input matInput [matDatepicker]="picker"
(dateInput)="addEvent('input', $event)" (dateChange)="addEvent('change', $event)">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-full-width">
<input matInput [matDatepickerFilter]="myFilter" [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepickerFilter]="myFilter" [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="dp" placeholder="Verbose datepicker" [formControl]="date">
<mat-label>Verbose datepicker</mat-label>
<input matInput [matDatepicker]="dp" [formControl]="date">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="dp" placeholder="Different locale">
<mat-label>Different locale</mat-label>
<input matInput [matDatepicker]="dp">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp></mat-datepicker>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-full-width">
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [min]="minDate" [max]="maxDate" [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="dp" placeholder="Moment.js datepicker" [formControl]="date">
<mat-label>Moment.js datepicker</mat-label>
<input matInput [matDatepicker]="dp" [formControl]="date">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker startView="year" [startAt]="startDate"></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-full-width">
<input matInput [matDatepicker]="picker" placeholder="Choose a date">
<mat-label>Choose a date</mat-label>
<input matInput [matDatepicker]="picker">
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker touchUi #picker></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<mat-form-field>
<input matInput [matDatepicker]="picker1" placeholder="Angular forms" [formControl]="date">
<mat-label>Angular forms</mat-label>
<input matInput [matDatepicker]="picker1" [formControl]="date">
<mat-datepicker-toggle matSuffix [for]="picker1"></mat-datepicker-toggle>
<mat-datepicker #picker1></mat-datepicker>
</mat-form-field>

<mat-form-field>
<input matInput [matDatepicker]="picker2" placeholder="Angular forms (w/ deserialization)"
<mat-label>Angular forms (w/ deserialization)</mat-label>
<input matInput [matDatepicker]="picker2"
[formControl]="serializedDate">
<mat-datepicker-toggle matSuffix [for]="picker2"></mat-datepicker-toggle>
<mat-datepicker #picker2></mat-datepicker>
</mat-form-field>

<mat-form-field>
<input matInput [matDatepicker]="picker3" placeholder="Value binding" [value]="date.value">
<mat-label>Value binding</mat-label>
<input matInput [matDatepicker]="picker3" [value]="date.value">
<mat-datepicker-toggle matSuffix [for]="picker3"></mat-datepicker-toggle>
<mat-datepicker #picker3></mat-datepicker>
</mat-form-field>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field>
<input matInput [matDatepicker]="dp" placeholder="Month and Year" [formControl]="date">
<mat-label>Month and Year</mat-label>
<input matInput [matDatepicker]="dp" [formControl]="date">
<mat-datepicker-toggle matSuffix [for]="dp"></mat-datepicker-toggle>
<mat-datepicker #dp
startView="multi-year"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ <h1 mat-dialog-title>Hi {{data.name}}</h1>
<div mat-dialog-content>
<p>What's your favorite animal?</p>
<mat-form-field>
<mat-label>Favorite Animal</mat-label>
<input matInput [(ngModel)]="data.animal">
</mat-form-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ol>
<li>
<mat-form-field>
<input matInput [(ngModel)]="name" placeholder="What's your name?">
<mat-label>What's your name?</mat-label>
<input matInput [(ngModel)]="name">
</mat-form-field>
</li>
<li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
justify-content: space-between;
align-items: center;
}

.example-headers-align .mat-form-field + .mat-form-field {
margin-left: 8px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="First name">
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>

<mat-form-field>
<input matInput type="number" min="1" placeholder="Age">
<mat-label>Age</mat-label>
<input matInput type="number" min="1">
</mat-form-field>

</mat-expansion-panel>
Expand All @@ -36,7 +38,8 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="Country">
<mat-label>Country</mat-label>
<input matInput>
</mat-form-field>
</mat-expansion-panel>

Expand All @@ -52,7 +55,8 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="Date" [matDatepicker]="picker" (focus)="picker.open()" readonly>
<mat-label>Date</mat-label>
<input matInput [matDatepicker]="picker" (focus)="picker.open()" readonly>
</mat-form-field>
<mat-datepicker #picker></mat-datepicker>
</mat-expansion-panel>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/** No CSS for this example */
.mat-form-field + .mat-form-field {
margin-left: 8px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="First name">
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>

<mat-form-field>
<input matInput placeholder="Age">
<mat-label>Age</mat-label>
<input matInput type="number" min="1">
</mat-form-field>
</mat-expansion-panel>
<mat-expansion-panel (opened)="panelOpenState = true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
align-items: center;
}

mat-form-field {
margin-right: 12px;
.example-headers-align .mat-form-field + .mat-form-field {
margin-left: 8px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="First name">
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field>

<mat-form-field>
<input matInput type="number" min="1" placeholder="Age">
<mat-label>Age</mat-label>
<input matInput type="number" min="1">
</mat-form-field>

<mat-action-row>
Expand All @@ -35,7 +37,8 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="Country">
<mat-label>Country</mat-label>
<input matInput>
</mat-form-field>

<mat-action-row>
Expand All @@ -56,7 +59,8 @@
</mat-expansion-panel-header>

<mat-form-field>
<input matInput placeholder="Date" [matDatepicker]="picker" (focus)="picker.open()" readonly>
<mat-label>Date</mat-label>
<input matInput [matDatepicker]="picker" (focus)="picker.open()" readonly>
</mat-form-field>
<mat-datepicker #picker></mat-datepicker>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<mat-form-field class="example-form-field">
<input matInput type="text" placeholder="Clearable input" [(ngModel)]="value">
<mat-label>Clearable input</mat-label>
<input matInput type="text" [(ngModel)]="value">
<button mat-button *ngIf="value" matSuffix mat-icon-button aria-label="Clear" (click)="value=''">
<mat-icon>close</mat-icon>
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Email" [formControl]="emailFormControl"
[errorStateMatcher]="matcher">
<mat-label>Email</mat-label>
<input matInput [formControl]="emailFormControl" [errorStateMatcher]="matcher"
placeholder="Ex. [email protected]">
<mat-hint>Errors appear instantly!</mat-hint>
<mat-error *ngIf="emailFormControl.hasError('email') && !emailFormControl.hasError('required')">
Please enter a valid email address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Email" [formControl]="emailFormControl">
<mat-label>Email</mat-label>
<input matInput [formControl]="emailFormControl" placeholder="Ex. [email protected]">
<mat-error *ngIf="emailFormControl.hasError('email') && !emailFormControl.hasError('required')">
Please enter a valid email address
</mat-error>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Company (disabled)" disabled value="Google">
<mat-label>Company (disabled)</mat-label>
<input matInput disabled value="Google">
</mat-form-field>

<table class="example-full-width" cellspacing="0"><tr>
<td><mat-form-field class="example-full-width">
<input matInput placeholder="First name">
<mat-label>First name</mat-label>
<input matInput>
</mat-form-field></td>
<td><mat-form-field class="example-full-width">
<input matInput placeholder="Long Last Name That Will Be Truncated">
<mat-label>Long Last Name That Will Be Truncated</mat-label>
<input matInput>
</mat-form-field></td>
</tr></table>

<p>
<mat-form-field class="example-full-width">
<textarea matInput placeholder="Address">1600 Amphitheatre Pkwy</textarea>
<mat-label>Address</mat-label>
<textarea matInput placeholder="Ex. 100 Main St">1600 Amphitheatre Pkwy</textarea>
</mat-form-field>
<mat-form-field class="example-full-width">
<textarea matInput placeholder="Address 2"></textarea>
<mat-label>Address 2</mat-label>
<textarea matInput></textarea>
</mat-form-field>
</p>

<table class="example-full-width" cellspacing="0"><tr>
<td><mat-form-field class="example-full-width">
<input matInput placeholder="City">
<mat-label>City</mat-label>
<input matInput placeholder="Ex. San Francisco">
</mat-form-field></td>
<td><mat-form-field class="example-full-width">
<input matInput placeholder="State">
<mat-label>State</mat-label>
<input matInput placeholder="Ex. California">
</mat-form-field></td>
<td><mat-form-field class="example-full-width">
<input matInput #postalCode maxlength="5" placeholder="Postal Code" value="94043">
<mat-label>Postal Code</mat-label>
<input matInput #postalCode maxlength="5" placeholder="Ex. 94105" value="94043">
<mat-hint align="end">{{postalCode.value.length}} / 5</mat-hint>
</mat-form-field></td>
</tr></table>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<form class="example-form">

<mat-form-field class="example-full-width">
<input matInput #message maxlength="256" placeholder="Message">
<mat-label>Message</mat-label>
<input matInput #message maxlength="256" placeholder="Ex. I need help with...">
<mat-hint align="start"><strong>Don't disclose personal info</strong> </mat-hint>
<mat-hint align="end">{{message.value.length}} / 256</mat-hint>
</mat-form-field>

</form>
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<form class="example-form">
<mat-form-field class="example-full-width">
<input matInput placeholder="Favorite food" value="Sushi">
<mat-label>Favorite food</mat-label>
<input matInput placeholder="Ex. Pizza" value="Sushi">
</mat-form-field>

<mat-form-field class="example-full-width">
<textarea matInput placeholder="Leave a comment"></textarea>
<mat-label>Leave a comment</mat-label>
<textarea matInput placeholder="Ex. It makes me feel..."></textarea>
</mat-form-field>
</form>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<form class="example-form">

<mat-form-field class="example-full-width">
<mat-label>Telephone</mat-label>
<span matPrefix>+1 &nbsp;</span>
<input type="tel" matInput placeholder="Telephone">
<input type="tel" matInput placeholder="555-555-1234">
<mat-icon matSuffix>mode_edit</mat-icon>
</mat-form-field>

</form>
Loading