Skip to content

Commit 461ba11

Browse files
committed
feat(select): add placeholder as an input for select
closes #6862
1 parent ea450d4 commit 461ba11

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

src/components/select/select.ios.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ $select-ios-padding-bottom: $item-ios-padding-bottom !default;
1010
$select-ios-padding-left: $item-ios-padding-left !default;
1111

1212
$select-ios-icon-color: #999 !default;
13+
$select-ios-placeholder-color: $select-ios-icon-color !default;
1314

1415

1516
ion-select {
1617
padding: $select-ios-padding-top $select-ios-padding-right $select-ios-padding-bottom $select-ios-padding-left;
1718
}
1819

20+
.select-placeholder {
21+
color: $select-ios-placeholder-color;
22+
}
23+
1924
.select-icon {
2025
position: relative;
2126

src/components/select/select.md.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ $select-md-padding-bottom: $item-md-padding-bottom !default;
1010
$select-md-padding-left: $item-md-padding-left !default;
1111

1212
$select-md-icon-color: #999 !default;
13+
$select-md-placeholder-color: $select-md-icon-color !default;
1314

1415

1516
ion-select {
1617
padding: $select-md-padding-top $select-md-padding-right $select-md-padding-bottom $select-md-padding-left;
1718
}
1819

20+
.select-placeholder {
21+
color: $select-md-placeholder-color;
22+
}
23+
1924
.item-select ion-label {
2025
margin-left: 0;
2126
}

src/components/select/select.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ const SELECT_VALUE_ACCESSOR = new Provider(
116116
@Component({
117117
selector: 'ion-select',
118118
template:
119-
'<div class="select-text">{{_text}}</div>' +
119+
'<div *ngIf="!_text" class="select-placeholder select-text">{{placeholder}}</div>' +
120+
'<div *ngIf="_text" class="select-text">{{_text}}</div>' +
120121
'<div class="select-icon">' +
121122
'<div class="select-icon-inner"></div>' +
122123
'</div>' +
@@ -159,6 +160,11 @@ export class Select {
159160
*/
160161
@Input() okText: string = 'OK';
161162

163+
/**
164+
* @input {string} The text to display when the select is empty.
165+
*/
166+
@Input() placeholder: string;
167+
162168
/**
163169
* @input {any} Any addition options that the alert interface can take.
164170
* See the [Alert API docs](../../alert/Alert) for the create options.

src/components/select/select.wp.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ $select-wp-border-color: $input-wp-border-color !default;
1717

1818
$select-wp-icon-width: 18px !default;
1919
$select-wp-icon-arrow-width: 2px !default;
20+
2021
$select-wp-icon-color: $select-wp-border-color !default;
22+
$select-wp-placeholder-color: $select-wp-icon-color !default;
2123

2224

2325
ion-select {
@@ -32,6 +34,10 @@ ion-select {
3234
line-height: 3rem;
3335
}
3436

37+
.select-placeholder {
38+
color: $select-wp-placeholder-color;
39+
}
40+
3541
.item-select ion-label {
3642
margin-left: 0;
3743
}

src/components/select/test/single-value/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
<ion-item>
5151
<ion-label>Music</ion-label>
52-
<ion-select [(ngModel)]="music" [alertOptions]="musicAlertOpts">
52+
<ion-select [(ngModel)]="music" [alertOptions]="musicAlertOpts" placeholder="Select Music">
5353
<ion-option>Alice in Chains</ion-option>
5454
<ion-option>Green Day</ion-option>
5555
<ion-option>Nirvana</ion-option>

0 commit comments

Comments
 (0)