capacitor-native-feel
Removes the "website in a WebView" tells from a Capacitor app so it feels installed - sticky hover after tap, gray tap-highlight flash, inputs that zoom the page, laggy press feedback, whole-page rubber-banding or Android overscroll stretch, long-press selecting button text or op
Install
npx skills add https://github.com/Cap-go/capgo-skills/tree/main/skills/capacitor-native-feel
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install cap-go-capgo-skills@llmmart
git clone https://github.com/Cap-go/capgo-skills.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole cap-go/capgo-skills collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Native Feel for Capacitor Apps
A fix-it skill: take a Capacitor app that feels like a web page in a WebView and remove the tells one by one. Most fixes are one CSS declaration, one meta tag, or one capacitor.config key. Adapted for Capacitor WebViews from Emil Kowalski's MIT-licensed mobile-native skill.
When to Use
TRIGGER when:
- The app "works in Chrome but feels wrong on the phone"
- Hover styles stick after a tap, or taps flash gray/blue
- Focusing an input zooms the page and it never zooms back
- Buttons feel laggy, long-press selects button labels, or links open a preview/callout
- The whole page bounces (iOS) or stretches/glows (Android) behind fixed headers or sheets
- A carousel or drag gesture scrolls the page instead
- Status bar icons are unreadable, or a white flash appears on launch / overscroll
- Reviewing a Capacitor, Ionic, Konsta, or PWA UI for touch quality
Do not use:
- Notch, home indicator, Android edge-to-edge, SystemBars insets in depth:
safe-area-handling - Inputs hidden by the keyboard, accessory bar, resize modes:
capacitor-keyboard - Tailwind install / v4 config:
tailwind-capacitor - Jank, long tasks, bundle size:
capacitor-performance - Screen readers, contrast, focus order, full Dynamic Type audits:
capacitor-accessibility
Hard Rules
- Every fix ships with its reason. Apply a rule where its reason applies.
user-select: noneon a button is correct; on body text it is a defect. - Capability queries, not device sniffing. Use
(hover: hover),(pointer: fine),env(),dvh. Do not branch on user agent or screen width to guess touch.Capacitor.getPlatform()is for native API differences, not for hiding hover styles. iPads with trackpads and Android with a mouse exist. - Page zoom stays off; text scales instead. Pinch-zooming the whole screen is a website tell, and native apps do not do it. Keep Capacitor's default
zoomEnabled: falseand never turn it on. Accessibility comes from honoring the system text size: iOS Dynamic Type and Android font scale (section 3). Input zoom is caused by inputs under 16px, so fix the font size; a viewportmaximum-scalehack is not the fix. - Config before JavaScript. If CSS, a meta tag, or a
capacitor.configkey does it, do not write atouchmovelistener or auseIsTouch()hook. - Verify on a real device before calling it fixed. Desktop device emulation reproduces none of these bugs. If you cannot run on hardware, say which fixes you verified from code and which need a phone.
Symptom Table
| Symptom | Fix |
|---|---|
| Hover state stuck after tap | Gate :hover in @media (hover: hover) and (pointer: fine) (section 1) |
| Gray/blue flash on tap | -webkit-tap-highlight-color: transparent + an :active state (2) |
| Page zooms into an input | Input font size of at least 16px (3) |
| Tap feels laggy | :active press feedback + touch-action: manipulation (4) |
| Whole page bounces or stretches | overscroll-behavior on root and scrollers; ios.scrollEnabled: false for app shells (5) |
| Long-press selects label or opens link preview | user-select: none on controls; ios.allowsLinkPreview: false (6) |
| Carousel / drag scrolls the page | touch-action: pan-y / none on the gesture surface, or scroll-snap (7) |
| Layout too tall, bottom button hidden | 100dvh / flex shell instead of 100vh (8) |
| Status bar icons unreadable / white flash | SystemBars.setStyle + backgroundColor config; theme-color only for web/PWA (9) |
| Fine in the browser, wrong on the phone | Live reload on hardware + remote inspector (10) |
The Fixes
1. Hover state stuck after tap
Touch has no hover, so WebViews fake one: the first tap applies :hover and keeps it until the user taps elsewhere.
@media (hover: hover) and (pointer: fine) {
.button:hover { background: var(--gray-3); }
}
(pointer: fine) excludes touchscreens that report hover with a coarse pointer. Tailwind v4 hover: already compiles to @media (hover: hover); v3 needs future.hoverOnlyWhenSupported. Ionic components already gate their hover styles; check custom CSS only. Touch users get press feedback from :active (section 4).
2. Gray/blue flash on tap
WKWebView and Android WebView paint a highlight over tapped elements with click handlers. It is the loudest "this is a website" tell.
html { -webkit-tap-highlight-color: transparent; }
Set it once, globally, then give every tappable element its own :active state, because you just removed the only feedback the WebView gave.
3. Page zooms into the input
iOS zooms when focus lands on an input whose computed font size is under 16px, and does not zoom back out on blur.
input, textarea, select { font-size: 16px; }
/* or only for touch if desktop needs smaller text */
@media (pointer: coarse) { input, textarea, select { font-size: 16px; } }
Larger text, not page zoom. Users who need bigger content set it in the OS, so the app must follow that setting:
- Size text in
rem/em, never fixedpxon body copy, and let containers grow (no fixed heights orline-clampon key text). - iOS: WKWebView ignores Dynamic Type by default. Either set
html { font: -apple-system-body; }and size the rest inrem, or readTextZoom.getPreferred()from@capacitor/text-zoomand apply it withTextZoom.set()on launch andresume. Pick one, or text scales twice. - Android: the WebView follows the system font scale automatically; make sure layouts reflow at 200%.
- Test with
xcrun simctl ui booted content_size accessibility-extra-extra-extra-largeandadb shell settings put system font_scale 2.0. Details live incapacitor-accessibility.
Also set the right keyboard: inputmode="numeric" for codes, inputmode="decimal" for amounts, type="email" / type="tel", autocapitalize="none" and autocorrect="off" for usernames and codes, enterkeyhint="send" | "search" | "done", and autocomplete="one-time-code" for SMS codes. Keyboard overlap itself belongs to capacitor-keyboard.
4. Tap feels laggy
Two causes stack:
- Click delay.
touch-action: manipulationtells the WebView the element never double-tap-zooms, soclickfires immediately. - Feedback on release. Native controls react when the finger lands. Show the pressed state on
:active(or a reversiblepointerdownstyle that clears onpointerup/pointercancel). Keep the action itself onclick: it lets users cancel by dragging off the control, and it also fires for keyboard and assistive-technology activation.
button, a, [role="button"], .tappable { touch-action: manipulation; }
.button { transition: transform 100ms ease-out, background-color 100ms ease-out; }
.button:active { transform: scale(0.97); background: var(--gray-4); }
Keep press feedback at 100-160ms with ease-out. For important actions (toggle, delete, purchase), add a light haptic with @capacitor/haptics (Haptics.impact({ style: ImpactStyle.Light })); do not buzz on every tap.
5. Whole page bounces or stretches
iOS rubber-bands the whole WKWebView past the top or bottom, dragging fixed headers and tab bars with it. Android WebView shows an overscroll stretch or glow. Right for a document, wrong for an app shell with its own scroll containers.
html, body { overscroll-behavior: none; }
.scroll-area { overflow-y: auto; overscroll-behavior: contain; }
none on the root, contain on inner scrollers: the container keeps its own bounce but stops chaining to the page. overscroll-behavior needs iOS 16+ (Capacitor 8 still supports iOS 15).
For a fixed app shell where only inner containers scroll (Ionic-style), also turn off the WKWebView's own scroll view:
// capacitor.config.ts
ios: { scrollEnabled: false },
This disables scrolling of the document itself on iOS; elements with overflow: auto keep scrolling. Do not set it on apps that scroll the document, or the page stops scrolling. Never stop overscroll with touchmove + preventDefault(): it blocks scrolling and forces non-passive listeners.
6. Long-press selects button text or opens a preview
Holding a control selects its label, or iOS shows the link-preview / callout sheet. Native controls never do.
button, [role="button"], .tab, .chip, .drag-handle {
user-select: none;
-webkit-user-select: none; /* WKWebView still needs the prefix */
-webkit-touch-callout: none; /* no callout on links/images used as controls */
}
img { -webkit-user-drag: none; }
// capacitor.config.ts - stop iOS link previews on long-press in the WebView
ios: { allowsLinkPreview: false },
Never put user-select: none on body: users copy order numbers, addresses, and error messages.
7. Carousel or drag scrolls the page
The WebView cannot tell whether a diagonal swipe belongs to the page or the gesture. Declare which axes the browser keeps:
.carousel { touch-action: pan-y; } /* JS handles horizontal; page keeps vertical */
.sheet-handle { touch-action: pan-x; } /* JS handles vertical drag-to-dismiss */
.slider, .canvas { touch-action: none; } /* element owns every axis */
Use none only on elements that really handle every axis, or users cannot scroll past them. For native-scroll carousels prefer scroll-snap-type: x mandatory on the track and scroll-snap-align: start on slides; the WebView's physics beat a hand-rolled spring.
8. Layout has the wrong height
The native WebView has no URL bar, but the same code often ships as web/PWA, and 100vh still covers the area under system bars and ignores the keyboard. Use dynamic units or a flex shell:
.app {
height: 100vh; /* fallback: iOS 15.0-15.3 (still supported by Capacitor 8) has no dvh */
height: 100dvh;
display: flex; flex-direction: column;
}
.app-main { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.hero { min-height: 100vh; min-height: 100svh; } /* web marketing pages: stable, never overflows */
dvh / svh need iOS 15.4+ and Chrome 108+. Keep the 100vh line first while the app supports older WebViews (Capacitor 8 targets iOS 15.0+); browsers that understand the second declaration override it. An alternative with no unit support issues is html, body, #app { height: 100%; }.
Pad headers and tab bars with safe-area insets; the full fallback chain (--safe-area-inset-* from SystemBars, then env()) lives in safe-area-handling.
9. Status bar and background colors don't match
<meta name="theme-color"> colors browser chrome and PWAs. It does nothing inside a Capacitor native shell. There, the WebView draws behind the status bar and you control:
- Icon color:
SystemBars.setStyle({ style: SystemBarsStyle.Dark })(light icons for dark backgrounds) from@capacitor/coreon Capacitor 8+; update it when the app theme toggles. - Bar background: paint the header (with
padding-topfor the inset) in your top color. On Android 15/16StatusBar.setBackgroundColorno longer works; seesafe-area-handling. - WebView background: set
backgroundColorincapacitor.config(orios.backgroundColor/android.backgroundColor) to the app's background so launch, rotation, and overscroll never flash white. Match the splash screen (capacitor-splash-screen).
Keep per-scheme theme-color tags for the web/PWA build:
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0a0a0a" />
<meta name="color-scheme" content="light dark" />
10. Fine in the browser, wrong on the phone
Sticky hover, tap highlight, input zoom, overscroll, safe areas, link previews, and the keyboard are hardware behaviors. Device emulation shows none of them.
- Run the dev server on the LAN:
npx vite --host(or the framework's equivalent0.0.0.0flag). - Load it in the native shell: Capacitor 9
npx cap run ios --url http://<LAN-IP>:5173(Android adds--forwardPorts 5173:5173with USB). On older Capacitor, setserver.urltemporarily incapacitor.config. Android blocks cleartext traffic by default, so anhttp://dev URL also needsserver.cleartext: true. Remove both before any release build. - Inspect: iOS Safari > Develop > device (release builds need
ios.webContentsDebuggingEnabled); Androidchrome://inspect. Device logs:ios-android-logs. - Test an older, slower phone too, with the keyboard open, in landscape once, and on Android in both gesture and 3-button navigation.
The iOS Simulator catches layout and safe-area issues but not touch feel. Real hardware is the bar.
Baseline
Ship this before the first component in a new Capacitor app:
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" />
html {
-webkit-tap-highlight-color: transparent;
-webkit-text-size-adjust: 100%; /* no font inflation in landscape */
overscroll-behavior: none;
}
input, textarea, select { font-size: 16px; }
button, a, [role="button"] { touch-action: manipulation; }
button, [role="button"] { user-select: none; -webkit-user-select: none; }
@media (hover: hover) and (pointer: fine) {
/* every :hover rule lives here */
}
// capacitor.config.ts (excerpt)
backgroundColor: '#0a0a0a', // match the app background
ios: { allowsLinkPreview: false }, // add scrollEnabled: false for fixed app shells
Drop overscroll-behavior: none if the app is a scrolling document where bounce is welcome. interactive-widget affects Android Chromium only; iOS keyboard behavior is configured through capacitor-keyboard.
Never Ship
| Never | Instead |
|---|---|
maximum-scale=1 as the fix for input zoom |
16px inputs |
zoomEnabled: true or pinch zoom as the accessibility answer |
Honor system text size (Dynamic Type, Android font scale) |
Fixed px body text and fixed-height text boxes |
rem sizes and layouts that reflow at 200% text |
Ungated :hover |
@media (hover: hover) and (pointer: fine) |
Press feedback on click only |
:active / reversible pointerdown styling; the action stays on click |
touchmove + preventDefault() against bounce |
overscroll-behavior, ios.scrollEnabled: false |
ios.scrollEnabled: false on a document-scrolling app |
Leave it on; use overscroll-behavior |
user-select: none on body |
Only on controls |
touch-action: none on something users scroll past |
pan-x / pan-y |
env(safe-area-inset-*) without viewport-fit=cover |
Add it, or the value is 0 |
theme-color as the native status bar fix |
SystemBars.setStyle + CSS header background |
| Default white WebView background on a dark app | backgroundColor in capacitor.config |
User-agent or getPlatform() checks to detect touch |
(hover) / (pointer) media queries |
Shipping with server.url or server.cleartext left in config |
Remove both before release builds |
| "Fixed" based on desktop emulation | Real device via live reload |
Capgo UI building blocks
Prefer these over hand-rolled components; they already handle gestures, safe areas, and platform feel:
| Need | Package | Skill |
|---|---|---|
| Tailwind components (buttons, lists, navbars, forms) | Capgo registry Cap-go/tailwind-capacitor |
capgo-tailwind-ui |
| Bottom sheets, drawers, dialogs | @capgo/capacitor-sheets |
capgo-sheets |
| Native navbar / tab bar (Liquid Glass) | @capgo/capacitor-native-navigation |
capgo-native-navigation |
| Success / error / loading toasts | @capgo/capacitor-pretty-toast |
capgo-pretty-toast |
| Push / pop transitions, swipe-back | @capgo/capacitor-transitions |
capgo-transitions |
Beyond the platform layer
Once the website tells are gone, polish is about design and state handling: hierarchy, spacing, empty and loading states, optimistic UI, haptics, and forgiving input. Load references/ui-polish-vocabulary.md when the user asks to make a screen look or feel better, or when reviewing UI quality. It lists precise terms to use instead of vague requests, each with its Capacitor angle.
Workflow
- Inspect
index.htmlviewport meta, global CSS,capacitor.config.*(ios.scrollEnabled,ios.allowsLinkPreview,backgroundColor,zoomEnabledmust stay unset orfalse,server.url), the UI framework (Ionic and Konsta already handle some of this), and Tailwind version. - Match the user's symptom in the table; otherwise audit against the Baseline and Never Ship lists:
grep -rnE "user-scalable=no|maximum-scale=1|100vh|:hover|tap-highlight|overscroll-behavior|touch-action|user-select" index.html src 2>/dev/null
grep -nE "scrollEnabled|allowsLinkPreview|backgroundColor|server" capacitor.config.* 2>/dev/null
- Apply the smallest fix, then
npx cap syncif config changed. - Verify on hardware (section 10).
Output
Apply the fixes, then report in a few lines:
- What was wrong: the matched symptom and its one-line cause.
- What changed: file and declaration or config key, one line each.
- What needs a phone: which fixes you verified from code and which the user must confirm on a device.
The code is the deliverable; do not pad the report.
Resources
- Capacitor config reference: https://capacitorjs.com/docs/config
- System Bars API: https://capacitorjs.com/docs/apis/system-bars
- Haptics API: https://capacitorjs.com/docs/apis/haptics
- CLI
cap run: https://capacitorjs.com/docs/cli/commands/run - MDN
touch-action: https://developer.mozilla.org/docs/Web/CSS/touch-action - MDN
overscroll-behavior: https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior - Source skill (MIT): https://github.com/emilkowalski/skills/tree/main/skills/mobile-native
Files (capgo-skills)
-
references
-
ui-polish-vocabulary.md 4.5 KB
Loading…
-
-
metadata.json 1.4 KB
Loading… -
SKILL.md 18.6 KB
--- name: capacitor-native-feel description: Removes the "website in a WebView" tells from a Capacitor app so it feels installed - sticky hover after tap, gray tap-highlight flash, inputs that zoom the page, laggy press feedback, whole-page rubber-banding or Android overscroll stretch, long-press selecting button text or opening link previews, carousels fighting vertical scroll, 100vh layouts, unreadable status bar icons, and white flashes behind the WebView. Covers CSS and meta-tag fixes plus Capacitor config that replaces browser-only fixes (ios.scrollEnabled, ios.allowsLinkPreview, backgroundColor, SystemBars.setStyle instead of theme-color) and real-device testing with live reload. Use when an app works in the browser but feels wrong on the phone, or when reviewing touch UI, tab bars, sheets, carousels, or full-screen shells. Do not use for notch/system-bar layout (safe-area-handling), keyboard overlap (capacitor-keyboard), Tailwind setup (tailwind-capacitor), or performance (capacitor-performance). --- # Native Feel for Capacitor Apps A fix-it skill: take a Capacitor app that feels like a web page in a WebView and remove the tells one by one. Most fixes are one CSS declaration, one meta tag, or one `capacitor.config` key. Adapted for Capacitor WebViews from Emil Kowalski's MIT-licensed [`mobile-native`](https://github.com/emilkowalski/skills/tree/main/skills/mobile-native) skill. ## When to Use TRIGGER when: - The app "works in Chrome but feels wrong on the phone" - Hover styles stick after a tap, or taps flash gray/blue - Focusing an input zooms the page and it never zooms back - Buttons feel laggy, long-press selects button labels, or links open a preview/callout - The whole page bounces (iOS) or stretches/glows (Android) behind fixed headers or sheets - A carousel or drag gesture scrolls the page instead - Status bar icons are unreadable, or a white flash appears on launch / overscroll - Reviewing a Capacitor, Ionic, Konsta, or PWA UI for touch quality Do not use: - Notch, home indicator, Android edge-to-edge, SystemBars insets in depth: `safe-area-handling` - Inputs hidden by the keyboard, accessory bar, resize modes: `capacitor-keyboard` - Tailwind install / v4 config: `tailwind-capacitor` - Jank, long tasks, bundle size: `capacitor-performance` - Screen readers, contrast, focus order, full Dynamic Type audits: `capacitor-accessibility` ## Hard Rules 1. **Every fix ships with its reason.** Apply a rule where its reason applies. `user-select: none` on a button is correct; on body text it is a defect. 2. **Capability queries, not device sniffing.** Use `(hover: hover)`, `(pointer: fine)`, `env()`, `dvh`. Do not branch on user agent or screen width to guess touch. `Capacitor.getPlatform()` is for native API differences, not for hiding hover styles. iPads with trackpads and Android with a mouse exist. 3. **Page zoom stays off; text scales instead.** Pinch-zooming the whole screen is a website tell, and native apps do not do it. Keep Capacitor's default `zoomEnabled: false` and never turn it on. Accessibility comes from honoring the system text size: iOS Dynamic Type and Android font scale (section 3). Input zoom is caused by inputs under 16px, so fix the font size; a viewport `maximum-scale` hack is not the fix. 4. **Config before JavaScript.** If CSS, a meta tag, or a `capacitor.config` key does it, do not write a `touchmove` listener or a `useIsTouch()` hook. 5. **Verify on a real device before calling it fixed.** Desktop device emulation reproduces none of these bugs. If you cannot run on hardware, say which fixes you verified from code and which need a phone. ## Symptom Table | Symptom | Fix | |---------|-----| | Hover state stuck after tap | Gate `:hover` in `@media (hover: hover) and (pointer: fine)` (section 1) | | Gray/blue flash on tap | `-webkit-tap-highlight-color: transparent` + an `:active` state (2) | | Page zooms into an input | Input font size of at least 16px (3) | | Tap feels laggy | `:active` press feedback + `touch-action: manipulation` (4) | | Whole page bounces or stretches | `overscroll-behavior` on root and scrollers; `ios.scrollEnabled: false` for app shells (5) | | Long-press selects label or opens link preview | `user-select: none` on controls; `ios.allowsLinkPreview: false` (6) | | Carousel / drag scrolls the page | `touch-action: pan-y` / `none` on the gesture surface, or scroll-snap (7) | | Layout too tall, bottom button hidden | `100dvh` / flex shell instead of `100vh` (8) | | Status bar icons unreadable / white flash | `SystemBars.setStyle` + `backgroundColor` config; `theme-color` only for web/PWA (9) | | Fine in the browser, wrong on the phone | Live reload on hardware + remote inspector (10) | ## The Fixes ### 1. Hover state stuck after tap Touch has no hover, so WebViews fake one: the first tap applies `:hover` and keeps it until the user taps elsewhere. ```css @media (hover: hover) and (pointer: fine) { .button:hover { background: var(--gray-3); } } ``` `(pointer: fine)` excludes touchscreens that report hover with a coarse pointer. Tailwind v4 `hover:` already compiles to `@media (hover: hover)`; v3 needs `future.hoverOnlyWhenSupported`. Ionic components already gate their hover styles; check custom CSS only. Touch users get press feedback from `:active` (section 4). ### 2. Gray/blue flash on tap WKWebView and Android WebView paint a highlight over tapped elements with click handlers. It is the loudest "this is a website" tell. ```css html { -webkit-tap-highlight-color: transparent; } ``` Set it once, globally, then give every tappable element its own `:active` state, because you just removed the only feedback the WebView gave. ### 3. Page zooms into the input iOS zooms when focus lands on an input whose computed font size is under 16px, and does not zoom back out on blur. ```css input, textarea, select { font-size: 16px; } /* or only for touch if desktop needs smaller text */ @media (pointer: coarse) { input, textarea, select { font-size: 16px; } } ``` **Larger text, not page zoom.** Users who need bigger content set it in the OS, so the app must follow that setting: - Size text in `rem`/`em`, never fixed `px` on body copy, and let containers grow (no fixed heights or `line-clamp` on key text). - iOS: WKWebView ignores Dynamic Type by default. Either set `html { font: -apple-system-body; }` and size the rest in `rem`, or read `TextZoom.getPreferred()` from `@capacitor/text-zoom` and apply it with `TextZoom.set()` on launch and `resume`. Pick one, or text scales twice. - Android: the WebView follows the system font scale automatically; make sure layouts reflow at 200%. - Test with `xcrun simctl ui booted content_size accessibility-extra-extra-extra-large` and `adb shell settings put system font_scale 2.0`. Details live in `capacitor-accessibility`. Also set the right keyboard: `inputmode="numeric"` for codes, `inputmode="decimal"` for amounts, `type="email"` / `type="tel"`, `autocapitalize="none"` and `autocorrect="off"` for usernames and codes, `enterkeyhint="send" | "search" | "done"`, and `autocomplete="one-time-code"` for SMS codes. Keyboard overlap itself belongs to `capacitor-keyboard`. ### 4. Tap feels laggy Two causes stack: - **Click delay.** `touch-action: manipulation` tells the WebView the element never double-tap-zooms, so `click` fires immediately. - **Feedback on release.** Native controls react when the finger lands. Show the pressed state on `:active` (or a reversible `pointerdown` style that clears on `pointerup` / `pointercancel`). Keep the action itself on `click`: it lets users cancel by dragging off the control, and it also fires for keyboard and assistive-technology activation. ```css button, a, [role="button"], .tappable { touch-action: manipulation; } .button { transition: transform 100ms ease-out, background-color 100ms ease-out; } .button:active { transform: scale(0.97); background: var(--gray-4); } ``` Keep press feedback at 100-160ms with `ease-out`. For important actions (toggle, delete, purchase), add a light haptic with `@capacitor/haptics` (`Haptics.impact({ style: ImpactStyle.Light })`); do not buzz on every tap. ### 5. Whole page bounces or stretches iOS rubber-bands the whole WKWebView past the top or bottom, dragging fixed headers and tab bars with it. Android WebView shows an overscroll stretch or glow. Right for a document, wrong for an app shell with its own scroll containers. ```css html, body { overscroll-behavior: none; } .scroll-area { overflow-y: auto; overscroll-behavior: contain; } ``` `none` on the root, `contain` on inner scrollers: the container keeps its own bounce but stops chaining to the page. `overscroll-behavior` needs iOS 16+ (Capacitor 8 still supports iOS 15). For a fixed app shell where only inner containers scroll (Ionic-style), also turn off the WKWebView's own scroll view: ```ts // capacitor.config.ts ios: { scrollEnabled: false }, ``` This disables scrolling of the document itself on iOS; elements with `overflow: auto` keep scrolling. Do not set it on apps that scroll the document, or the page stops scrolling. Never stop overscroll with `touchmove` + `preventDefault()`: it blocks scrolling and forces non-passive listeners. ### 6. Long-press selects button text or opens a preview Holding a control selects its label, or iOS shows the link-preview / callout sheet. Native controls never do. ```css button, [role="button"], .tab, .chip, .drag-handle { user-select: none; -webkit-user-select: none; /* WKWebView still needs the prefix */ -webkit-touch-callout: none; /* no callout on links/images used as controls */ } img { -webkit-user-drag: none; } ``` ```ts // capacitor.config.ts - stop iOS link previews on long-press in the WebView ios: { allowsLinkPreview: false }, ``` Never put `user-select: none` on `body`: users copy order numbers, addresses, and error messages. ### 7. Carousel or drag scrolls the page The WebView cannot tell whether a diagonal swipe belongs to the page or the gesture. Declare which axes the browser keeps: ```css .carousel { touch-action: pan-y; } /* JS handles horizontal; page keeps vertical */ .sheet-handle { touch-action: pan-x; } /* JS handles vertical drag-to-dismiss */ .slider, .canvas { touch-action: none; } /* element owns every axis */ ``` Use `none` only on elements that really handle every axis, or users cannot scroll past them. For native-scroll carousels prefer `scroll-snap-type: x mandatory` on the track and `scroll-snap-align: start` on slides; the WebView's physics beat a hand-rolled spring. ### 8. Layout has the wrong height The native WebView has no URL bar, but the same code often ships as web/PWA, and `100vh` still covers the area under system bars and ignores the keyboard. Use dynamic units or a flex shell: ```css .app { height: 100vh; /* fallback: iOS 15.0-15.3 (still supported by Capacitor 8) has no dvh */ height: 100dvh; display: flex; flex-direction: column; } .app-main { flex: 1; overflow-y: auto; overscroll-behavior: contain; } .hero { min-height: 100vh; min-height: 100svh; } /* web marketing pages: stable, never overflows */ ``` `dvh` / `svh` need iOS 15.4+ and Chrome 108+. Keep the `100vh` line first while the app supports older WebViews (Capacitor 8 targets iOS 15.0+); browsers that understand the second declaration override it. An alternative with no unit support issues is `html, body, #app { height: 100%; }`. Pad headers and tab bars with safe-area insets; the full fallback chain (`--safe-area-inset-*` from SystemBars, then `env()`) lives in `safe-area-handling`. ### 9. Status bar and background colors don't match `<meta name="theme-color">` colors browser chrome and PWAs. **It does nothing inside a Capacitor native shell.** There, the WebView draws behind the status bar and you control: - **Icon color**: `SystemBars.setStyle({ style: SystemBarsStyle.Dark })` (light icons for dark backgrounds) from `@capacitor/core` on Capacitor 8+; update it when the app theme toggles. - **Bar background**: paint the header (with `padding-top` for the inset) in your top color. On Android 15/16 `StatusBar.setBackgroundColor` no longer works; see `safe-area-handling`. - **WebView background**: set `backgroundColor` in `capacitor.config` (or `ios.backgroundColor` / `android.backgroundColor`) to the app's background so launch, rotation, and overscroll never flash white. Match the splash screen (`capacitor-splash-screen`). Keep per-scheme `theme-color` tags for the web/PWA build: ```html <meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff" /> <meta name="theme-color" media="(prefers-color-scheme: dark)" content="#0a0a0a" /> <meta name="color-scheme" content="light dark" /> ``` ### 10. Fine in the browser, wrong on the phone Sticky hover, tap highlight, input zoom, overscroll, safe areas, link previews, and the keyboard are hardware behaviors. Device emulation shows none of them. 1. Run the dev server on the LAN: `npx vite --host` (or the framework's equivalent `0.0.0.0` flag). 2. Load it in the native shell: Capacitor 9 `npx cap run ios --url http://<LAN-IP>:5173` (Android adds `--forwardPorts 5173:5173` with USB). On older Capacitor, set `server.url` temporarily in `capacitor.config`. Android blocks cleartext traffic by default, so an `http://` dev URL also needs `server.cleartext: true`. Remove both before any release build. 3. Inspect: iOS Safari > Develop > device (release builds need `ios.webContentsDebuggingEnabled`); Android `chrome://inspect`. Device logs: `ios-android-logs`. 4. Test an older, slower phone too, with the keyboard open, in landscape once, and on Android in both gesture and 3-button navigation. The iOS Simulator catches layout and safe-area issues but not touch feel. Real hardware is the bar. ## Baseline Ship this before the first component in a new Capacitor app: ```html <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover, interactive-widget=resizes-content" /> ``` ```css html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; /* no font inflation in landscape */ overscroll-behavior: none; } input, textarea, select { font-size: 16px; } button, a, [role="button"] { touch-action: manipulation; } button, [role="button"] { user-select: none; -webkit-user-select: none; } @media (hover: hover) and (pointer: fine) { /* every :hover rule lives here */ } ``` ```ts // capacitor.config.ts (excerpt) backgroundColor: '#0a0a0a', // match the app background ios: { allowsLinkPreview: false }, // add scrollEnabled: false for fixed app shells ``` Drop `overscroll-behavior: none` if the app is a scrolling document where bounce is welcome. `interactive-widget` affects Android Chromium only; iOS keyboard behavior is configured through `capacitor-keyboard`. ## Never Ship | Never | Instead | |-------|---------| | `maximum-scale=1` as the fix for input zoom | 16px inputs | | `zoomEnabled: true` or pinch zoom as the accessibility answer | Honor system text size (Dynamic Type, Android font scale) | | Fixed `px` body text and fixed-height text boxes | `rem` sizes and layouts that reflow at 200% text | | Ungated `:hover` | `@media (hover: hover) and (pointer: fine)` | | Press feedback on `click` only | `:active` / reversible `pointerdown` styling; the action stays on `click` | | `touchmove` + `preventDefault()` against bounce | `overscroll-behavior`, `ios.scrollEnabled: false` | | `ios.scrollEnabled: false` on a document-scrolling app | Leave it on; use `overscroll-behavior` | | `user-select: none` on `body` | Only on controls | | `touch-action: none` on something users scroll past | `pan-x` / `pan-y` | | `env(safe-area-inset-*)` without `viewport-fit=cover` | Add it, or the value is `0` | | `theme-color` as the native status bar fix | `SystemBars.setStyle` + CSS header background | | Default white WebView background on a dark app | `backgroundColor` in `capacitor.config` | | User-agent or `getPlatform()` checks to detect touch | `(hover)` / `(pointer)` media queries | | Shipping with `server.url` or `server.cleartext` left in config | Remove both before release builds | | "Fixed" based on desktop emulation | Real device via live reload | ## Capgo UI building blocks Prefer these over hand-rolled components; they already handle gestures, safe areas, and platform feel: | Need | Package | Skill | |------|---------|-------| | Tailwind components (buttons, lists, navbars, forms) | Capgo registry `Cap-go/tailwind-capacitor` | `capgo-tailwind-ui` | | Bottom sheets, drawers, dialogs | `@capgo/capacitor-sheets` | `capgo-sheets` | | Native navbar / tab bar (Liquid Glass) | `@capgo/capacitor-native-navigation` | `capgo-native-navigation` | | Success / error / loading toasts | `@capgo/capacitor-pretty-toast` | `capgo-pretty-toast` | | Push / pop transitions, swipe-back | `@capgo/capacitor-transitions` | `capgo-transitions` | ## Beyond the platform layer Once the website tells are gone, polish is about design and state handling: hierarchy, spacing, empty and loading states, optimistic UI, haptics, and forgiving input. Load [references/ui-polish-vocabulary.md](references/ui-polish-vocabulary.md) when the user asks to make a screen look or feel better, or when reviewing UI quality. It lists precise terms to use instead of vague requests, each with its Capacitor angle. ## Workflow 1. Inspect `index.html` viewport meta, global CSS, `capacitor.config.*` (`ios.scrollEnabled`, `ios.allowsLinkPreview`, `backgroundColor`, `zoomEnabled` must stay unset or `false`, `server.url`), the UI framework (Ionic and Konsta already handle some of this), and Tailwind version. 2. Match the user's symptom in the table; otherwise audit against the Baseline and Never Ship lists: ```bash grep -rnE "user-scalable=no|maximum-scale=1|100vh|:hover|tap-highlight|overscroll-behavior|touch-action|user-select" index.html src 2>/dev/null grep -nE "scrollEnabled|allowsLinkPreview|backgroundColor|server" capacitor.config.* 2>/dev/null ``` 3. Apply the smallest fix, then `npx cap sync` if config changed. 4. Verify on hardware (section 10). ## Output Apply the fixes, then report in a few lines: - **What was wrong**: the matched symptom and its one-line cause. - **What changed**: file and declaration or config key, one line each. - **What needs a phone**: which fixes you verified from code and which the user must confirm on a device. The code is the deliverable; do not pad the report. ## Resources - Capacitor config reference: https://capacitorjs.com/docs/config - System Bars API: https://capacitorjs.com/docs/apis/system-bars - Haptics API: https://capacitorjs.com/docs/apis/haptics - CLI `cap run`: https://capacitorjs.com/docs/cli/commands/run - MDN `touch-action`: https://developer.mozilla.org/docs/Web/CSS/touch-action - MDN `overscroll-behavior`: https://developer.mozilla.org/docs/Web/CSS/overscroll-behavior - Source skill (MIT): https://github.com/emilkowalski/skills/tree/main/skills/mobile-native
Reviews (0)
No reviews yet.
Comments
Sign in to join the conversation.
No comments yet. Start the conversation.