Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic - Adding a button inside a input field

Tags:

css

ionic2

iconic

I'm trying to add a button inside an <ion-input> but wherever I add it inside the <ion-list> the button does not show on the screen.

What I'm trying to do is to show a button "Forgot" on top of the password field aligned to the right. Refer screen:

enter image description here

This is my HTML,

<ion-content>
  <ion-list class="au-form" inset padding>
        <ion-item>
            <ion-input type="text" placeholder="Username"></ion-input>
        </ion-item>
        <ion-item>
            <ion-input type="password" placeholder="Password"></ion-input>
            <button clear>Forgot</button>
        </ion-item>
   </ion-list>
</ion-content>

How do I achieve this layout in Ionic 2?

like image 682
user3607282 Avatar asked Mar 24 '16 08:03

user3607282


2 Answers

For ionic 4 it will look a bit different:

<ion-item>
 <ion-input type="password" placeholder="Password"></ion-input>
 <button clear slot="end">Forgot</button>
</ion-item>

Instead of left and right they introduced start and end values, which make it easier to build interfaces for both left-to-right and right-to-left writing directions

like image 129
DerBesondereEin Avatar answered Nov 16 '22 01:11

DerBesondereEin


Fixed in the recent Ionic releases. Adding item-right on the button works.

<ion-item>
 <ion-input type="password" placeholder="Password"></ion-input>
 <button clear item-right>Forgot</button>
</ion-item>
like image 37
user3607282 Avatar answered Nov 16 '22 02:11

user3607282