whatisgithub

What is contextmenu?

nicklockwood/contextmenu — explained in plain English

Analysis updated 2026-05-18

25SwiftAudience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A Swift library that shows a standard dropdown menu at the exact point a user long presses, without needing a button.

Mindmap

mindmap
  root((ContextMenu))
    What it does
      Menu at press point
      Dropdown style menu
      No hidden buttons
    Tech stack
      Swift
      UIKit
      iOS and Mac Catalyst
    Use cases
      Canvas editors
      Map views
      Document previews
    Audience
      iOS developers

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Show a right click style menu at the touch point on a drawing canvas or editor.

USE CASE 2

Add a contextual dropdown menu to a map or 3D scene view without placing hidden buttons.

USE CASE 3

Give document preview screens a long press menu anchored to the exact pressed location.

What is it built with?

SwiftUIKitiOSMac Catalyst

How does it compare?

nicklockwood/contextmenuappeight/app8-ios-sdklocallens-project/lingdongphoto
Stars252525
LanguageSwiftSwiftSwift
Setup difficultyeasymoderateeasy
Complexity2/54/52/5
Audiencedeveloperdevelopergeneral

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 30min

Full dropdown-style menus require iOS 17.4 or later, older versions fall back to a different system menu style.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

So what is it?

ContextMenu is a small Swift library for iOS apps that lets a developer show a dropdown style menu at the exact point a user long presses on the screen, rather than tying that menu to a visible button. It is built for content areas like drawing canvases, document previews, editors, maps, and 3D scenes, where you want a right click style menu to appear wherever the user touched. Apple's UIKit already offers two related tools, but neither fits this exact case well on its own. Button menus are easy to set up but need a visible button. The system's context menu interaction can attach to any content and knows where the user pressed, but it presents using a different, heavier style than a normal dropdown menu. ContextMenu works around this gap by creating a temporary, invisible button at the pressed location and using it to trigger the standard dropdown menu, so the result looks and behaves like a normal button menu but can appear anywhere in a view. On newer versions of iOS, specifically iOS 17.4 and later, this invisible button trick gives the full standard dropdown appearance. On slightly older versions, iOS 16 through 17.3, the library automatically falls back to a different system menu style called the edit menu interaction, since the newer technique is not available there. The library supports apps built for iOS 14 and later, and Mac Catalyst 14 and later, though menus themselves only appear starting on iOS 16. Developers install it through Swift Package Manager and attach it to any UIView by providing a small function that returns the menu contents for a given touch location, or returns nothing if no menu should appear there. It is released under the MIT license.

Copy-paste prompts

Prompt 1
Show me how to add ContextMenu to an iOS project using Swift Package Manager.
Prompt 2
Write a UIView extension that attaches a ContextMenuInteraction with Copy and Delete actions.
Prompt 3
Explain how ContextMenu behaves differently on iOS 16 through 17.3 versus iOS 17.4 and later.
Prompt 4
Help me call presentMenu(at:) from a custom gesture recognizer instead of a long press.

Frequently asked questions

What is contextmenu?

A Swift library that shows a standard dropdown menu at the exact point a user long presses, without needing a button.

What language is contextmenu written in?

Mainly Swift. The stack also includes Swift, UIKit, iOS.

What license does contextmenu use?

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

How hard is contextmenu to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is contextmenu for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.