Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic 2: Input with Icon-Label

Tags:

ionic2

There are quite nice input-examples in the Ionic2 documentation but has somebody tried to create a normal label (not floating or so) with an input AND an icon to the left of the label?

I thought it might go like that:

<ion-item>
        <ion-icon name="logo-playstation"></ion-icon>
        <ion-label>PSN</ion-label>
        <ion-input clearInput type="text"></ion-input>
</ion-item>

but the Icon doesn't apper. Should I use a <div> for that or how would/did you do this?

like image 554
cherry-wave Avatar asked Feb 03 '17 08:02

cherry-wave


2 Answers

You have to use ion-icon inside ion-label

<ion-item>        
        <ion-label> <ion-icon name="logo-playstation"></ion-icon> PSN</ion-label>
        <ion-input clearInput type="text"></ion-input>
</ion-item>
like image 66
AishApp Avatar answered Nov 14 '22 00:11

AishApp


I had to use an icon and input element in separate fields of a row.. within a table.. within a ion-col.. and within an ion-row.

    <ion-row>
        <ion-col col-auto>
            <table>
                <tr>
                    <td>
                        <ion-icon name="logo-playstation"></ion-icon>
                    </td>
                    <td>
                        <ion-input clearInput type="text"></ion-input>
                    </td>
                </tr>
            </table>
        </ion-col>
     </ion-row>
like image 32
Johnathan J. Avatar answered Nov 13 '22 23:11

Johnathan J.