<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIContextMenuConfiguration",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIContextMenuConfiguration"
  },
  "title" : "UIContextMenuConfiguration"
}
-->

# UIContextMenuConfiguration

An object containing the configuration details for the contextual menu.

```
@MainActor class UIContextMenuConfiguration
```

## Overview

Before displaying a contextual menu, the system asks your [`UIContextMenuInteractionDelegate`](/documentation/UIKit/UIContextMenuInteractionDelegate) to provide a [`UIContextMenuConfiguration`](/documentation/UIKit/UIContextMenuConfiguration) object with details about that menu. In your [`contextMenuInteraction(_:configurationForMenuAtLocation:)`](/documentation/UIKit/UIContextMenuInteractionDelegate/contextMenuInteraction(_:configurationForMenuAtLocation:)) method, use the location parameter to determine where the interaction occurred, and use the content at that location to configure your contextual menu and view controller. Provide custom blocks to generate:

- The contextual menu with the actions for your content.
- An optional view controller to use when displaying your content.

If you specify a default object without any custom handler blocks, the system displays a default preview interface with no menu.

## Topics

### Creating the menu configuration object

[`init(identifier:previewProvider:actionProvider:)`](/documentation/UIKit/UIContextMenuConfiguration/init(identifier:previewProvider:actionProvider:))

Creates a menu configuration object with the specified action and preview providers.

[`UIContextMenuContentPreviewProvider`](/documentation/UIKit/UIContextMenuContentPreviewProvider)

Returns the custom view controller to use when previewing your content.

[`UIContextMenuActionProvider`](/documentation/UIKit/UIContextMenuActionProvider)

Returns an action-based contextual menu, optionally incorporating the system-suggested actions.

### Creating the menu configuration object

[`configurationWithIdentifier:previewProvider:actionProvider:`](/documentation/UIKit/UIContextMenuConfiguration/configurationWithIdentifier:previewProvider:actionProvider:)

Creates a menu configuration object with the specified action and preview providers.

[`UIContextMenuContentPreviewProvider`](/documentation/UIKit/UIContextMenuContentPreviewProvider)

Returns the custom view controller to use when previewing your content.

[`UIContextMenuActionProvider`](/documentation/UIKit/UIContextMenuActionProvider)

Returns an action-based contextual menu, optionally incorporating the system-suggested actions.

### Getting the configuration identifier

[`identifier`](/documentation/UIKit/UIContextMenuConfiguration/identifier)

The unique identifier for this configuration object.

### Handling multiple-item interactions

[`secondaryItemIdentifiers`](/documentation/UIKit/UIContextMenuConfiguration/secondaryItemIdentifiers)

A set of identifiers corresponding to each item other than the primary item in a multiple-item interaction.

[`badgeCount`](/documentation/UIKit/UIContextMenuConfiguration/badgeCount)

The number of items in a multiple-item interaction.

### Specifying the order of menu elements

[`preferredMenuElementOrder`](/documentation/UIKit/UIContextMenuConfiguration/preferredMenuElementOrder)

The preferred menu-element ordering strategy for the menu.

[`UIContextMenuConfiguration.ElementOrder`](/documentation/UIKit/UIContextMenuConfiguration/ElementOrder)

Constants that define the ordering strategy for menu elements in a context menu.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)