Chapter 17
Mobile
17.1 Built-in behaviour#
| Concern | How PixiFormUI handles it |
|---|---|
| Scroll versus tap | Controls act on tap. A swipe that starts on a field scrolls instead of focusing it, so the keyboard doesn't pop up mid-scroll. |
| On-screen keyboard | FormUI sizes the host to visualViewport (fitVisualViewport: true), and ScrollView keeps the focused field visible above the keyboard. |
| Keyboard type | inputMode and enterKeyHint on text fields; password fields switch the proxy to type=password. |
| Obscured typing | Last character shown briefly on touch devices (revealLastChar: 'auto'). |
| IME and composition | CJK input, swipe keyboards, autocorrect commits and Android backspace are all handled by the proxy. |
| Zoom and callouts | The proxy uses a 16px font (no iOS zoom-on-focus); touch-action: none, no long-press callout, no overscroll bounce. |
| Performance | Render resolution capped at 2×; only visible text lines are rendered; animations stop when idle. |
| Responsive layout | Row(..., breakpoint) stacks into one column on narrow screens. |
17.2 Design tips#
- Keep touch targets ≥ 44 px:
controlHeightandbuttonHeightdefault to 44. - Use
inputMode: 'email' | 'tel' | 'numeric'wherever it fits; it changes the keyboard layout. - Put primary actions in a full-width
Row([...], 12, 0)at the end of the form. - Use page margins of about 12 px below 480 px width (the demo's
Pagedoes this).
17.3 Testing on a real phone#
Two constraints apply: the server only answers allowed host names, and Web Crypto (needed for PFE1) only works in
a secure context. A plain http://192.168.x.x URL fails both. Options, best first:
- USB port forwarding (the phone sees
localhost, which counts as a secure context):- Android:
adb reverse tcp:8787 tcp:8787, then openhttp://localhost:8787in Chrome on the phone. - iOS: use Safari Web Inspector with a tunnel (option 2).
- Android:
- HTTPS tunnel, e.g. Cloudflare Tunnel or ngrok:
Hot reload over the tunnel may not connect (the dev CSP only allows local WebSockets); reload manually.cloudflared tunnel --url http://localhost:8787 # prints https://<random>.trycloudflare.com EXTRA_ALLOWED_HOSTS=<random>.trycloudflare.com npm run dev
17.4 Emulating in desktop Chrome#
DevTools → device toolbar → choose a phone. Touch emulation sets (pointer: coarse), so tap semantics and
revealLastChar: 'auto' behave as on a phone.