Skip to content

Commit 05302b8

Browse files
authored
docs(input): add example of a clearable input (#3730)
* docs(input): add example of a clearable input * use icon button
1 parent 8ae4d9d commit 05302b8

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/material-examples/example-module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ import {DatepickerMinMaxExample} from './datepicker-min-max/datepicker-min-max-e
8383
import {DatepickerFilterExample} from './datepicker-filter/datepicker-filter-example';
8484
import {DatepickerTouchExample} from './datepicker-touch/datepicker-touch-example';
8585
import {DatepickerApiExample} from './datepicker-api/datepicker-api-example';
86-
86+
import {InputClearableExample} from './input-clearable/input-clearable-example';
8787
import {
8888
MdAutocompleteModule, MdButtonModule, MdButtonToggleModule, MdCardModule, MdCheckboxModule,
8989
MdChipsModule, MdDatepickerModule, MdDialogModule, MdGridListModule, MdIconModule, MdInputModule,
@@ -147,6 +147,7 @@ export const EXAMPLE_COMPONENTS = {
147147
'grid-list-overview': {title: 'Basic grid-list', component: GridListOverviewExample},
148148
'icon-overview': {title: 'Basic icons', component: IconOverviewExample},
149149
'icon-svg': {title: 'SVG icons', component: IconSvgExample},
150+
'input-clearable': {title: 'Input with clear button', component: InputClearableExample},
150151
'input-form': {title: 'Inputs in a form', component: InputFormExample},
151152
'input-overview': {title: 'Basic inputs', component: InputOverviewExample},
152153
'input-errors': {title: 'Input Errors', component: InputErrorsExample},
@@ -267,6 +268,7 @@ export const EXAMPLE_LIST = [
267268
GridListOverviewExample,
268269
IconOverviewExample,
269270
IconSvgExample,
271+
InputClearableExample,
270272
InputFormExample,
271273
InputOverviewExample,
272274
InputPrefixSuffixExample,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.example-input-container {
2+
width: 200px;
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<md-input-container class="example-input-container">
2+
<input mdInput type="text" placeholder="Clearable input" [(ngModel)]="value"/>
3+
<md-button *ngIf="value" mdSuffix md-icon-button aria-label="Clear" (click)="value=''">
4+
<md-icon>close</md-icon>
5+
</md-button>
6+
</md-input-container>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {Component} from '@angular/core';
2+
3+
4+
@Component({
5+
selector: 'input-clearable-example',
6+
templateUrl: './input-clearable-example.html',
7+
styleUrls: ['./input-clearable-example.css'],
8+
})
9+
export class InputClearableExample {
10+
value = 'Clear me';
11+
}

0 commit comments

Comments
 (0)