AddThisFeature

Mobile Keyboard Avoidance

Keep the field being typed in, and the button that submits it, visible above the keyboard.

involved UI & Polish

What it adds

Coordinated handling of the on-screen keyboard so the focused input and the primary action stay in view while it is open.

What your agent is told to do

5
  1. 1

    Identify every screen where a user types on a phone — sign-in, search, comment boxes, checkout, bottom sheets, inline table editors — and confirm for each that the focused field and its submit control remain visible with the keyboard open.

  2. 2

    React to the visual viewport rather than the layout viewport. The layout viewport often does not change when the keyboard opens, so anything keyed to it will believe nothing happened while the bottom half of the screen is covered.

  3. 3

    Bring the focused field into view with the smallest movement that clears the keyboard, and leave a small margin above it. Centring every focused field yanks the page around and loses the user's place in a long form.

  4. 4

    Decide explicitly what fixed footers, sticky action bars, and bottom sheets do when the keyboard opens: ride above it, or unstick and return to the document flow. Both are defensible, but a footer left pinned to the old bottom edge sits underneath the keyboard and its buttons cannot be pressed.

  5. 5

    Do not treat every viewport height change as a keyboard event. Pinch zoom, browser chrome retracting on scroll, and rotation all change the reported height, and scrolling the page in response to them makes the app feel possessed. Choosing which height a container is sized against belongs to Viewport Height Utility; this brief owns only the reaction to the keyboard appearing and disappearing.

Edge cases it handles

7
  • A pinch zoom shrinks the visual viewport exactly as a keyboard does. Treating the two as the same event makes the page scroll away under the user's fingers while they are trying to read something, so distinguish them by whether an input actually holds focus and by the scale factor.
  • Scrolling the page in response to focus must be predictable and minimal. An unprompted jump that moves content the user was reading, or that fires again on every keystroke as the field grows, is worse than the field being partly obscured.
  • Fixed footers, sticky action bars, and bottom sheets are the usual casualties: they stay glued to the pre-keyboard bottom edge and end up behind the keyboard, taking the submit button with them. Every bottom-anchored element needs a defined keyboard behaviour, and only one of them may own the bottom edge.
  • When the keyboard closes, the previous scroll position must be restored rather than left wherever the avoidance logic pushed it. Landing the user halfway down a form they had already scrolled past is disorienting.
  • Different platforms report the keyboard differently and some do not report it at all until after it has finished animating, so the layout must settle correctly rather than assuming a single resize event arrives at a useful moment.
  • Predictive text bars, autofill suggestion strips, and hardware keyboards attached to tablets all change the covered height without a conventional keyboard being present, so the calculation must use the measured obscured area rather than an assumed keyboard height.
  • Moving focus between two adjacent fields must not re-run a full scroll animation each time. Tabbing through a form should feel continuous, not like a series of jumps.

Definition of done

8
  • The focused input and its associated submit control remain visible while the on-screen keyboard is open, on every screen where users type.
  • Pinch zoom and browser chrome changes do not trigger keyboard avoidance behaviour.
  • Scroll adjustments are the minimum needed to clear the keyboard and do not repeat on every keystroke.
  • Every bottom-anchored element has a defined behaviour when the keyboard opens, and none is left unreachable behind it.
  • Closing the keyboard restores the scroll position the user had before it opened.
  • The obscured area is measured rather than assumed, so predictive bars and hardware keyboards behave correctly.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.