Forms✨ Premium

Input with Icon

An icon on the left of the field that wakes up on focus: it turns indigo, grows by 15% and tilts by 10° while the frame lights up. Any SVG icon you like.

CSSFocusIcon

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Forms has 20 effects, including 2 free. Explore the category →

3 usage examples

Contact details for a first appointment — Varenhol osteopathy practice — Input with Icon example 1

① Contact details for a first appointment — Varenhol osteopathy practice

WhenThe chosen slot is recalled on the left; on the right, phone, email and date of birth, each with its icon. Moving from field to field with Tab, it is the active field's icon that comes alive.
WhyThree different icons say at a glance what each field expects, and the one that moves shows where you are without highlighting the whole form.
SettingsRoot used as the form column, --iin-width: 100%. Handset, envelope and calendar icons; type="tel" + autocomplete="tel", then autocomplete="bday" with inputmode="numeric".
Message field of a support widget — Ombrelune shop — Input with Icon example 2

② Message field of a support widget — Ombrelune shop

WhenAt the bottom of the chat window open on the shop, the "Your message…" field and its paperclip: on click the paperclip tilts and lights up, Enter sends the bubble and the agent answers.
WhyThe paperclip reminds visitors they can attach a photo; its small move on click shows the field is ready without adding text to an already narrow widget.
SettingsNo .iin-caption: aria-label="Your message" on the field. --iin-width: 100% in a flex row with the 46 × 48 px send button; 278 × 324 px widget.
Pickup address on a full-screen map — Trivolle couriers — Input with Icon example 3

③ Pickup address on a full-screen map — Trivolle couriers

WhenThe whole scene is the neighbourhood map; a floating panel asks "Where should the courier pick up?". On tap, the field's pin tilts; once the address is typed, a pin lands on the map.
WhyThe field's pin and the map's pin speak the same language: the focus animation links what you type with where the courier will go.
SettingsMap drawn as SVG in the scene (no network tiles), 300 px panel, --iin-width: 100%, aria-label="Pickup address", autocomplete="street-address".

How it works

The .iin-input field keeps a 48 px left padding; the .iin-icon, a 20 px SVG, sits in that padding with absolute positioning (left: 16px, vertically centred by top: 50% and translateY(-50%)). It ignores clicks: tapping the icon puts the caret in the field.

On focus, two rules work together. .iin-input:focus turns the 2 px border #6366f1 and tints the fill. .iin-input:focus ~ .iin-icon colours the icon indigo and adds scale(1.15) rotate(-10deg) to the vertical centring, over 0.3 s on a cubic-bezier(.4, 0, .2, 1) curve. The small tilt makes the icon look as if it answers the click; everything returns to place when the field loses focus.

The "Email" text (.iin-caption) above the field is its label; the you@email.com placeholder is only an input example. The .fx-0288-root root is just the demo frame (300 px, #0a0a0f background).

Accessibility

  • Label separate from the example: "Email" stays visible and names the field for screen readers, even once the placeholder has vanished under the input.
  • Decorative icon: the SVG carries aria-hidden="true" and focusable="false", so it is neither read nor reached by keyboard.
  • Form: type="email", name="email" and autocomplete="email" are supplied; the browser checks the format, offers the saved address and opens the email keyboard on phones.
  • Reduced motion: under prefers-reduced-motion: reduce, the icon only changes colour, with no growth or tilt, and the frame lights up without a transition.
  • Focus: the 2 px indigo frame on #0a0a0f reaches 4.4:1, above the 3:1 minimum for a focus indicator.

Browser compatibility

CSS transforms and transitions plus one width variable: Chrome 49, Firefox 31, Safari 9.1. Checked in Chromium, Firefox and WebKit: a second copy animates on its own while the first stays still, by click, Tab and touch, at 390 px and under reduced motion. The captures show typing and field-to-field moves simulated by the scene script, which is not included in the code you buy.

Chrome 49+✓ Full (measured)
Firefox 31+✓ Full (measured)
Safari 9.1+✓ Full (WebKit engine measured)
Edge 79+✓ Full (Chromium engine)
Mobile iOS 9.3+✓ Full
Android Chrome 49+✓ Full (Chromium engine)

Without transitions, icon and frame switch at once; without CSS variables, the width falls back to the parent element's.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0288-root">
  <label class="iin-field">
    <span class="iin-caption">Email</span>
    <span class="iin-box">
      <input class="iin-input" type="email" name="email" autocomplete="email" placeholder="you@email.com">
      <span class="iin-icon" aria-hidden="true">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" focusable="false">
          <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
          <polyline points="22,6 12,13 2,6"></polyline>
        </svg>
      </span>
    </span>
  </label>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Icon (HTML — SVG inside .iin-icon) 20 × 20 envelope Any SVG using stroke="currentColor" automatically takes the grey then the indigo. A filled icon needs fill="currentColor".
Icon motion (CSS — transform of the :focus ~ .iin-icon rule) scale(1.15) rotate(-10deg) Always keep translateY(-50%) first in the value, or the icon leaves its axis. rotate(0) for a plain enlargement.
Width (CSS — --iin-width) 280 px 100% to fill a column or a widget; capped by max-width: 100%.
Colours (CSS) icon #8b8b93 → #6366f1, frame rgba(255, 255, 255, .1) → #6366f1 Four values in .iin-icon, .iin-input and their :focus rules.
Visible label (HTML — .iin-caption) "Email" above Remove it only when the context already names the field (message bar, search); then put aria-label on the field.
Duration (CSS — transition) 0.3 s Same duration for frame and icon; beyond 0.4 s the tilt feels sluggish.

FAQ

Yes: replace left: 16px with right: 16px on .iin-icon and move the 48 px padding to the right (padding: 14px 48px 14px 16px). The −10° tilt looks fine either way.
The animation is tied to focus, the moment the field really expects input (click, Tab or tap). Hovering does not change the field's state; add a :hover rule if you want an earlier hint.
Yes, with nothing to rename: there is no id and no script, each <label class="iin-field"> animates its own icon. Just change the SVG, the label and the type, name and autocomplete attributes.