---
title: "On Secondary Photos Picker Action | Explore SwiftUI"
description: "Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples."
canonical_url: "https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action"
meta:
  author: "Explore SwiftUI"
  "og:description": "Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples."
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_On%2BSecondary%2BPhotos%2BPicker%2BAction%2Cdescription_Sets%2Bthe%2Bsecondary%2Baction%2Bhandler%2Bfor%2Bthe%2BPhotos%2Bpicker.%2Ccategory_PhotosPicker%2Cimage_~L2FwaS9pbWFnZXMvMjY4L3ZhcmlhbnRzLzIyNTU~dj0xNzk0OTEwNzU4NTIwJnI9MiZ3PTEyODAmcT04NSZmPWpwZWc%2CimageMode_crop%2CimagePosition_top%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm90dG9tOiAwOyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLXRvcC1sZWZ0LXJhZGl1czogNzRweDs%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ2aXNpb25PUyJdfQ%2Cp_Ii9saWJyYXJ5L3Bob3Rvc3BpY2tlci9vbi1zZWNvbmRhcnktcGhvdG9zLXBpY2tlci1hY3Rpb24i%2Cs_kX6bDo9TmWANAe-O.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "On Secondary Photos Picker Action | Explore SwiftUI"
  "twitter:description": "Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples."
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_On%2BSecondary%2BPhotos%2BPicker%2BAction%2Cdescription_Sets%2Bthe%2Bsecondary%2Baction%2Bhandler%2Bfor%2Bthe%2BPhotos%2Bpicker.%2Ccategory_PhotosPicker%2Cimage_~L2FwaS9pbWFnZXMvMjY4L3ZhcmlhbnRzLzIyNTU~dj0xNzk0OTEwNzU4NTIwJnI9MiZ3PTEyODAmcT04NSZmPWpwZWc%2CimageMode_crop%2CimagePosition_top%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm90dG9tOiAwOyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLXRvcC1sZWZ0LXJhZGl1czogNzRweDs%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ2aXNpb25PUyJdfQ%2Cp_Ii9saWJyYXJ5L3Bob3Rvc3BpY2tlci9vbi1zZWNvbmRhcnktcGhvdG9zLXBpY2tlci1hY3Rpb24i%2Cs_kX6bDo9TmWANAe-O.png"
  "twitter:title": "On Secondary Photos Picker Action | Explore SwiftUI"
---

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

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

# **On Secondary Photos Picker Action**

Sets the secondary action handler for the Photos picker.

![On Secondary Photos Picker Action - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/268/variants/2255?v=1794910758520&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 27.3+ iPadOS 27.3+ macOS 27.3+ visionOS 27.3+

### **Tags**

### **SwiftUI Code**

[ Docs](<https://developer.apple.com/documentation/SwiftUI/View/photosPickerOnSecondaryAction(_:)>)

```
@State private var selectedPhoto: PhotosPickerItem?

var body: some View {
    PhotosPicker("FooBar", selection: $selectedPhoto)
        .photosPickerOnSecondaryAction {
            print("selection canceled")
        }
}
```

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

Created: November 17, 2026Updated: November 17, 2026

### **More PhotosPicker Components **

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

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

### **Photos Picker**

Creates a picker with a title key and selection, and optionally configures the types of items to show and item encoding behavior.

![Photos Picker Title - iPadOS - Landscape - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/270/variants/2261?v=1794910543223&r=2&w=412&q=75&f=webp)

### **Photos Picker Title**

Overrides the title of the Photos picker. The title is not visible on small screens, like the iPhone.

![Photos Picker Prompt - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/269/variants/2259?v=1794910719258&r=2&w=412&q=75&f=webp)

### **Photos Picker Prompt**

Sets the prompt of the Photos picker.

![On Primary Photos Picker Action - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/267/variants/2251?v=1794910789851&r=2&w=412&q=75&f=webp)

### **On Primary Photos Picker Action**

Sets the primary action handler for the Photos picker.

![Container Photo Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/266/variants/2243?v=1794910698423&r=2&w=412&q=75&f=webp)

### **Container Photo Picker**

Limits the Photos picker to only show items in the specified container. In this case, to the user-created album "CustomAlbum".

![Custom Photo Picker Buttons - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/265/variants/2235?v=1794910823065&r=2&w=412&q=75&f=webp)

### **Custom Photo Picker Buttons**

Sets the primary and secondary button types of the Photos picker.

![Disable Automatic Photos Picker Dismissal - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/264/variants/2231?v=1794910665768&r=2&w=412&q=75&f=webp)

### **Disable Automatic Photos Picker Dismissal**

Prevents the Photos picker from dismissing automatically. Without this modifier, the Photos picker would automatically dismiss when an image is tapped.

![Range Photo Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/263/variants/2229?v=1794910645062&r=2&w=412&q=75&f=webp)

### **Range Photo Picker**

Presents a Photos picker that selects a collection of PhotosPickerItem, constrained to a range of selection counts.

### **Explore Other Components **

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

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

### **MenuControlGroupStyle**

A control group style that presents its content as a menu when the user presses the control, or as a submenu when nested within a larger menu

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

### **Swipe Container**

Only allows a single active swipe within a container.

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

### **ControlGroup**

Creates a new ControlGroup with the specified children

![TabView Bottom Accessory Placement - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/90/variants/385?v=1794865244707&r=2&w=412&q=75&f=webp)

### **TabView Bottom Accessory Placement**

A placement of the bottom accessory in a tab view. You can use this to adjust the content of the accessory view based on the placement

![Overlay Arrangement ZIndex - iOS on iPhone Duo - Landscape - Fully Open - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/252/variants/1906?v=1792480289764&r=2&w=412&q=75&f=webp)

### **Overlay Arrangement ZIndex**

The z-index for a view within an overlay arrangement view.

![Only Horizontal Split Arrangement Style - iOS on iPhone Duo - Portrait - Fully Open - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/245/variants/1614?v=1791207712827&r=2&w=412&q=75&f=webp)

### **Only Horizontal Split Arrangement Style**

Creates a horizontal split arrangement only in portrait orientation. In landscape orientation, no split is applied.

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

### **Icon Phase Store View**

Creates a view to load a collection of products from the App Store using product identifiers, and merchandise them using their promotional images and a custom placeholder icon.

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

### **Formatted Labeled Content**

Creates a labeled informational view from a formatted value.

```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/photospicker/on-secondary-photos-picker-action#webpage","@type":"WebPage","dateModified":"2026-11-17T10:19:18.688Z","datePublished":"2026-11-17T09:56:32.055Z","description":"Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples.","name":"On Secondary Photos Picker Action","url":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action","breadcrumb":{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"mainEntity":{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#article"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action"]}],"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/photospicker/on-secondary-photos-picker-action#article","citation":"https://developer.apple.com/documentation/SwiftUI/View/photosPickerOnSecondaryAction(_:)","dateModified":"2026-11-17T10:19:18.688Z","datePublished":"2026-11-17T09:56:32.055Z","description":"Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples.","headline":"On Secondary Photos Picker Action","inLanguage":"en-US","name":"On Secondary Photos Picker Action","thumbnailUrl":"https://exploreswiftui.com/api/images/268/variants/2255?v=1794910758520&r=2","url":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"hasPart":{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#source-code"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#webpage"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#source-code","@type":"SoftwareSourceCode","codeSampleType":"full example","description":"Sets the secondary action handler for the Photos picker. Learn how to use On Secondary Photos Picker Action in SwiftUI with visual code examples.","name":"On Secondary Photos Picker Action SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"@State private var selectedPhoto: PhotosPickerItem?\n\nvar body: some View {\n    PhotosPicker(\"FooBar\", selection: $selectedPhoto)\n        .photosPickerOnSecondaryAction {\n            print(\"selection canceled\")\n        }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"PhotosPicker"},{"@type":"Thing","name":"On Secondary Photos Picker Action"}]},{"@id":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"PhotosPicker","item":"https://exploreswiftui.com/library/photospicker","position":2},{"@type":"ListItem","name":"On Secondary Photos Picker Action","item":"https://exploreswiftui.com/library/photospicker/on-secondary-photos-picker-action","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/268/variants/2255?v=1794910758520&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/268/variants/2255?v=1794910758520&r=2"}]}
```