<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PhotoKit",
  "identifier" : "/documentation/PhotosUI/PhotosPicker",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "PhotosUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:015_PhotosUI_SwiftB00A6PickerV"
  },
  "title" : "PhotosPicker"
}
-->

# PhotosPicker

A view that displays a Photos picker for choosing assets from the photo library.

```
@MainActor @preconcurrency struct PhotosPicker<Label> where Label : View
```

## Overview

Use the Photos picker view to browse and select images and videos from the photo library. The view contains methods for single selection and multiple selection. For example, the following code displays a button that — when pressed — shows a picker in multiple selection mode.

```swift
import SwiftUI
import PhotosUI

struct PhotosSelector: View {
    @State var selectedItems: [PhotosPickerItem] = []

    var body: some View {
        PhotosPicker(selection: $selectedItems,
                     matching: .images) {
            Text("Select Multiple Photos")
        }
    }
}
```

When displaying the picker, you can use [`PHPickerFilter`](/documentation/PhotosUI/PHPickerFilter-swift.struct) options to customize what it displays. For example, the following code displays [`images`](/documentation/PhotosUI/PHPickerFilter-swift.struct/images) and excludes [`screenshots`](/documentation/PhotosUI/PHPickerFilter-swift.struct/screenshots).

```swift
PhotosPicker(selection: $selectedItems,
             matching: .any(of: [.images, .not(.screenshots)])) {
    Text("Select Photos")
}
```

The selection results you get are placeholder objects. A [`PhotosPickerItem`](/documentation/PhotosUI/PhotosPickerItem) conforms to <doc://com.apple.documentation/documentation/CoreTransferable/Transferable>, and allows you to load a representation you request. To load a SwiftUI <doc://com.apple.documentation/documentation/SwiftUI/Image> and track progress, use [`loadTransferable(type:completionHandler:)`](/documentation/PhotosUI/PhotosPickerItem/loadTransferable(type:completionHandler:)).

```swift
func loadTransferable(from imageSelection: PhotosPickerItem) -> Progress {
    return imageSelection.loadTransferable(type: Image.self) { result in
        DispatchQueue.main.async {
            guard imageSelection == self.imageSelection else { return }
            switch result {
            case .success(let image?):
                // Handle the success case with the image.
            case .success(nil):
                // Handle the success case with an empty value.
            case .failure(let error):
                // Handle the failure case with the provided error.
            }
        }
    }
}
```

A failure can occur when the system attempts to retrieve the data. For example, if the picker tries to download data from iCloud Photos without a network connection.

> Important:
> <doc://com.apple.documentation/documentation/SwiftUI/Image> only supports `PNG` file types through its <doc://com.apple.documentation/documentation/CoreTransferable/Transferable> conformance, so you need to create a custom `Transferable` model to support other image types. See <doc://com.apple.photokit/documentation/PhotoKit/bringing-photos-picker-to-your-swiftui-app> to learn more.

## Topics

### Creating a picker

[`init(selection:matching:preferredItemEncoding:label:)`](/documentation/PhotosUI/PhotosPicker/init(selection:matching:preferredItemEncoding:label:))

Creates a picker that selects an item and optionally configures the types of items to show, item encoding, and label behavior.

[`init(selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:label:)`](/documentation/PhotosUI/PhotosPicker/init(selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:label:))

Creates a picker that selects a collection of items and optionally configures the max selection count, selection behavior, types of items to show, item encoding, and label behavior.

[`init(selection:matching:preferredItemEncoding:photoLibrary:label:)`](/documentation/PhotosUI/PhotosPicker/init(selection:matching:preferredItemEncoding:photoLibrary:label:))

Creates a picker that selects an item from the photo library you specify and optionally configures the types of items to show, item encoding, and label behavior.

[`init(selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:label:)`](/documentation/PhotosUI/PhotosPicker/init(selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:label:))

Creates a picker that selects a collection of items from the photo library you specify and optionally configures the max selection count, selection behavior, types of items to show, item encoding, and label behavior.

### Creating a picker with a title

[`init(_:selection:matching:preferredItemEncoding:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:matching:preferredItemEncoding:)-7jbef)

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

[`init(_:selection:matching:preferredItemEncoding:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:matching:preferredItemEncoding:)-48f7l)

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

[`init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)-8ac23)

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

[`init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:)-6m11r)

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

[`init(_:selection:matching:preferredItemEncoding:photoLibrary:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:matching:preferredItemEncoding:photoLibrary:)-bu7c)

Creates a picker with a title key and selection from the photo library you specify, and optionally configures the types of items to show, item encoding, and label behavior.

[`init(_:selection:matching:preferredItemEncoding:photoLibrary:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:matching:preferredItemEncoding:photoLibrary:)-6bm2n)

Creates a picker with a title and selection from the photo library you specify, and optionally configures the types of items to show, item encoding, and label behavior.

[`init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)-5tpfd)

Creates a picker with a title key and selection from the photo library you specify, and optionally configures the max selection count, selection behavior, types of items to show, item encoding, and label behavior.

[`init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)`](/documentation/PhotosUI/PhotosPicker/init(_:selection:maxSelectionCount:selectionBehavior:matching:preferredItemEncoding:photoLibrary:)-6fwsc)

Creates a picker with a title and selection from the photo library you specify, and optionally configures the max selection count, selection behavior, types of items to show, item encoding, and label behavior.



---

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)