---
title: "Context Menu Preview | Explore SwiftUI"
description: "A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
canonical_url: "https://exploreswiftui.com/library/menu/context-menu-preview"
meta:
  author: "Explore SwiftUI"
  "og:description": "A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Context%2BMenu%2BPreview%2Cdescription_A%2Bcontext%2Bmenu%2Bwith%2Bcustom%2Bpreview%2Ccategory_Menu%2Cimage_~L2FwaS9pbWFnZXMvMjUvdmFyaWFudHMvMTU5P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ0dk9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L21lbnUvY29udGV4dC1tZW51LXByZXZpZXci%2Cs_mOSYqQ3nk5_ZbGz_.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Context Menu Preview | Explore SwiftUI"
  "twitter:description": "A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Context%2BMenu%2BPreview%2Cdescription_A%2Bcontext%2Bmenu%2Bwith%2Bcustom%2Bpreview%2Ccategory_Menu%2Cimage_~L2FwaS9pbWFnZXMvMjUvdmFyaWFudHMvMTU5P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ0dk9TIiwidmlzaW9uT1MiXX0%2Cp_Ii9saWJyYXJ5L21lbnUvY29udGV4dC1tZW51LXByZXZpZXci%2Cs_mOSYqQ3nk5_ZbGz_.png"
  "twitter:title": "Context Menu Preview | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=25)

# **Context Menu Preview**

A context menu with custom preview

![Context Menu Preview - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/25/variants/159?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 16.0+ iPadOS 16.0+ macOS 13.0+ tvOS 16.0+ visionOS 1.0+

### **Tags**

### **SwiftUI Code**

[ Docs](<https://developer.apple.com/documentation/swiftui/view/contextmenu(menuitems:preview:)>)

```
Text("Buttons")
    .contextMenu {
        Button("Button 1", action: action)
        Button("Button 2", systemImage: "button.vertical.left.press", action: action)
        Button(action: action) {
            Text("Button 3")
            Text("Description 3")
        }
    } preview: {
        Text("Custom Preview")
            .padding()
    }
```

### **Found an issue or have a suggestion?**

Created: May 30, 2025Updated: December 27, 2025

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

### **More Menu Components **

[**View all **](https://exploreswiftui.com/library/menu)

![Menu Action Button - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/23/variants/141?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu Action Button**

Acts like a button and opens the menu on a secondary gesture

![Context Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/22/variants/147?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Context Menu**

Adds a context menu to a view.

![Nested Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/21/variants/151?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Nested Menu**

A Menu inside a Menu

![Menu Divider - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/20/variants/128?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu Divider**

A Menu with a Divider

![Menu Section - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/19/variants/416?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu Section**

A Section inside a Menu

![Menu Fixed Order - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/18/variants/132?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu Fixed Order**

Order items from top to bottom

![Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/17/variants/122?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Menu**

A control for presenting a menu of actions.

### **Explore Other Components **

[**Browse all **](https://exploreswiftui.com/)

![List Section Separator Tint - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/118/variants/287?v=1790073478842&r=2&w=412&q=75&f=webp)

### **List Section Separator Tint**

Sets the tint color associated with a section.

![GroupedTabViewStyle - macOS - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/160/variants/514?v=1790073478842&r=2&w=412&q=75&f=webp)

### **GroupedTabViewStyle**

A tab view style that displays a tab bar that groups its tabs together.

![ProgressView - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/78/variants/65?v=1790073478842&r=2&w=412&q=75&f=webp)

### **ProgressView**

The different ProgressView initializers

![PalettePickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/184/variants/598?v=1790073478842&r=2&w=412&q=75&f=webp)

### **PalettePickerStyle**

A picker style that presents the options as a row of compact elements. When used outside of menus, this style is rendered as a segmented picker. If that is the intended usage, consider segmented instead.

![ViewThatFits Vertical - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/6/variants/20?v=1790073478842&r=2&w=412&q=75&f=webp)

### **ViewThatFits Vertical**

A view that adapts to the available vertical space by providing the first child view that fits.

![Hard ScrollEdgeEffect - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/83/variants/320?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Hard ScrollEdgeEffect**

A scroll edge effect with a hard cutoff and dividing line

![WheelPickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/186/variants/604?v=1790073478842&r=2&w=412&q=75&f=webp)

### **WheelPickerStyle**

A picker style that presents the options in a scrollable wheel that shows the selected option and a few neighboring options.

![NavigationLinkPickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/181/variants/560?v=1790073478842&r=2&w=412&q=75&f=webp)

### **NavigationLinkPickerStyle**

A picker style represented by a navigation link that presents the options by pushing a List-style picker view.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#webpage","@type":"WebPage","dateModified":"2025-12-27T17:13:59.209Z","datePublished":"2025-05-30T08:25:02.210Z","description":"A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Context Menu Preview","url":"https://exploreswiftui.com/library/menu/context-menu-preview","breadcrumb":{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/menu/context-menu-preview"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#article","dateModified":"2025-12-27T17:13:59.209Z","datePublished":"2025-05-30T08:25:02.210Z","description":"A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","headline":"Context Menu Preview","inLanguage":"en-US","name":"Context Menu Preview","thumbnailUrl":"https://exploreswiftui.com/api/images/25/variants/159?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/menu/context-menu-preview","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/view/contextmenu(menuitems:preview:)","codeSampleType":"full example","description":"A context menu with custom preview. Learn how to use Context Menu Preview in SwiftUI with visual code examples for iOS, macOS, watchOS, tvOS, and visionOS.","name":"Context Menu Preview SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"Text(\"Buttons\")\n    .contextMenu {\n        Button(\"Button 1\", action: action)\n        Button(\"Button 2\", systemImage: \"button.vertical.left.press\", action: action)\n        Button(action: action) {\n            Text(\"Button 3\")\n            Text(\"Description 3\")\n        }\n    } preview: {\n        Text(\"Custom Preview\")\n            .padding()\n    }","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Menu"},{"@type":"Thing","name":"Context Menu Preview"}]},{"@id":"https://exploreswiftui.com/library/menu/context-menu-preview#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Menu","item":"https://exploreswiftui.com/library/menu","position":2},{"@type":"ListItem","name":"Context Menu Preview","item":"https://exploreswiftui.com/library/menu/context-menu-preview","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/25/variants/159?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/25/variants/159?v=1790073478842&r=2"}]}
```