Skip to content

About

Capacitor plugin to toggle text interaction in iOS apps

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

10 stars

Watchers

0 watching

Forks

@capgo/capacitor-textinteraction

Turn text selection on or off in the WebView of your Capacitor iOS app, so it feels like a native app instead of a web page.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

14-day unlimited free trial. No credit card required

Missing a feature? We'll build the plugin for you 💪

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-textinteraction in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-textinteraction to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-textinteraction for Capacitor apps

Key features

  • One call: toggle() enables or disables text interaction.
  • Native feel: stops long-press text selection when disabled. Text inputs stop working too, so turn it back on before text entry.
  • WebKit based: uses the WKWebView text interaction setting on iOS.
  • Reversible: turn it back on for screens with editable or copyable text.
  • Platforms: iOS. iOS only. Android and web are not supported.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/textinteraction/

Compatibility

Plugin version Capacitor compatibility Maintained
v8.*.* v8.*.* ✅
v7.*.* v7.*.* On demand
v6.*.* v6.*.* ❌
v5.*.* v5.*.* ❌

Note: The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-textinteraction` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

npm install @capgo/capacitor-textinteraction
npx cap sync

Usage

import { TextInteraction } from '@capgo/capacitor-textinteraction';

const { enabled } = await TextInteraction.isEnabled();

if (enabled) {
  // Disable the iOS magnifier lens while the WebView is visible
  await TextInteraction.toggle({ enabled: false });
}

// Remember to re-enable before presenting any text inputs
await TextInteraction.toggle({ enabled: true });

Configuration

Set defaults in capacitor.config.ts:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    TextInteraction: {
      enabled: true,
      locked: false,
    },
  },
};

export default config;
  • enabled (default true): when false, text interaction starts disabled on app launch.
  • locked (default false): when true, toggle() rejects at runtime; use isEnabled() to read the current state.

API

toggle(...)

toggle(options: TextInteractionOptions) => Promise<TextInteractionResult>

Toggle text interaction (selection) on the Capacitor WebView.

⚠️ Disabling text interaction prevents all text input controls from working while disabled. Use it sparingly and re-enable when text entry is required.

iOS only.

Param Type
options TextInteractionOptions

Returns: Promise<TextInteractionResult>


isEnabled()

isEnabled() => Promise<TextInteractionEnabledResult>

Returns whether text interaction is currently enabled.

On iOS this reflects the WebView preference. On Android and web, toggling text interaction is not supported; the value reflects the plugin configuration state (plugins.TextInteraction.enabled at startup) rather than a platform change.

Returns: Promise<TextInteractionEnabledResult>

Since: 8.0.41


getPluginVersion()

getPluginVersion() => Promise<{ version: string; }>

Get the native Capacitor plugin version

Returns: Promise<{ version: string; }>


Interfaces

TextInteractionResult

Prop Type Description
success boolean true when the platform supports toggling text interaction (iOS >= 14.5), otherwise false.

TextInteractionOptions

Prop Type Description
enabled boolean Whether text interaction should be enabled or disabled. Disabling hides the magnifier lens reintroduced with iOS 15.

TextInteractionEnabledResult

Prop Type Description
enabled boolean Whether text interaction is currently enabled.

Credits

This plugin was inspired by the work of https://github.com/astrocreep/capacitor-plugins/tree/main/packages/textinteraction

About

Capacitor plugin to toggle text interaction in iOS apps

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

10 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages