ionic forms and input boxes


list class can also be used for input elements. The item-input and item classes specify text boxes and their labels.

Input box attributes: placeholder

In the following example, the default is 100% width (no borders on the left and right sides), and the placeholder attribute is used to set the prompt information for the expected value of the input field.

<div class="list">
  <label class="item item-input">
    <input type="text" placeholder="First Name">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Last Name">
  </label>
  <label class="item item-input">
    <textarea placeholder="Comments"></textarea>
  </label>
</div>


Input box attributes: input-label

Use input-label to place the label on the left side of the input box input.

<div class="list">
  <label class="item item-input">
    <span class="input-label">用户名:</span>
    <input type="text">
  </label>
  <label class="item item-input">
    <span class="input-label">密码:</span>
    <input type="password">
  </label>
</div>



Stacking tag

The stacking tag is usually located at the head of the input box. Each option is specified using the item-stacked-label class. Each input box needs to specify input-label. The following example also uses the placeholder attribute to set the information input prompt.

<div class="list">
  <label class="item item-input item-stacked-label">
    <span class="input-label">First Name</span>
    <input type="text" placeholder="John">
  </label>
  <label class="item item-input item-stacked-label">
    <span class="input-label">Last Name</span>
    <input type="text" placeholder="Suhr">
  </label>
  <label class="item item-input item-stacked-label">
    <span class="input-label">Email</span>
    <input type="text" placeholder="john@suhr.com">
  </label>
</div>



Floating label

Floating label is similar to stacked label, but floating label has an animation effect, and each option needs to specify item- Floating-label class, input label needs to specify input-label.

<div class="list">
  <label class="item item-input item-floating-label">
    <span class="input-label">First Name</span>
    <input type="text" placeholder="First Name">
  </label>
  <label class="item item-input item-floating-label">
    <span class="input-label">Last Name</span>
    <input type="text" placeholder="Last Name">
  </label>
  <label class="item item-input item-floating-label">
    <span class="input-label">Email</span>
    <input type="text" placeholder="Email">
  </label>
</div>



Inline form

By default each input field width is 100%, but we can use list list-inset or The card class sets the padding of the form, The card class has a shadow.

<div class="list list-inset">
  <label class="item item-input">
    <input type="text" placeholder="First Name">
  </label>
  <label class="item item-input">
    <input type="text" placeholder="Last Name">
  </label>
</div>



Inline input field

Use list-inset to set the embedded entity list. Use the item-input-inset style to embed a button.

<div class="list">

  <div class="item item-input-inset">
    <label class="item-input-wrapper">
      <input type="text" placeholder="Email">
    </label>
    <button class="button button-small">
      Submit
    </button>
  </div>

</div>



Input box with icon

item-input Input box can easily add icons. Icons can be added before <input>.

<div class="list list-inset">
  <label class="item item-input">
    <i class="icon ion-search placeholder-icon"></i>
    <input type="text" placeholder="Search">
  </label>
</div>



Header input box

The input box can be placed in the header and a submit or cancel button can be added.

<div class="bar bar-header item-input-inset">
  <label class="item-input-wrapper">
    <i class="icon ion-ios-search placeholder-icon"></i>
    <input type="search" placeholder="搜索">
  </label>
  <button class="button button-clear">
    取消
  </button>
</div>