Interactive previews iPhone

Container Photo Picker

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

Container Photo Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview

Platform Compatibility

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

Tags

SwiftUI Code

Docs
@State private var selectedPhoto: PhotosPickerItem?
@State private var albumIdentifier: String?

var body: some View {
    PhotosPicker("FooBar", selection: $selectedPhoto)
        .photosPickerContainerIdentifier(albumIdentifier)
        .disabled(albumIdentifier == nil)
        .task { await loadAlbumIdentifier() }
}

private func loadAlbumIdentifier() async {
    guard await PHPhotoLibrary.requestAuthorization(for: .readWrite) == .authorized else {
        print("Full photo library access is required to find Custom Album.")
        return
    }

    let options = PHFetchOptions()
    options.predicate = NSPredicate(format: "title ==[c] %@", "CustomAlbum")

    guard let album = PHAssetCollection.fetchAssetCollections(
        with: .album,
        subtype: .albumRegular,
        options: options
    ).firstObject else {
        print("Custom Album not found.")
        return
    }

    albumIdentifier = album.localIdentifier
}

Found an issue or have a suggestion?

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

More PhotosPicker Components

View all
Photos Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

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
modifier

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
modifier

Photos Picker Prompt

Sets the prompt of the Photos picker.

On Secondary Photos Picker Action - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

On Secondary Photos Picker Action

Sets the secondary action handler for the Photos picker.

On Primary Photos Picker Action - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

On Primary Photos Picker Action

Sets the primary action handler for the Photos picker.

Custom Photo Picker Buttons - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

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
modifier

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
modifier

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
Custom Phases Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Custom Phases Async URL Image

Loads and displays a modifiable image from the specified URL load request in phases.

Value Tab View - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Value Tab View

Creates a tab view that uses a builder to create and specify selection values for its tabs.

Labeled Content - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Labeled Content

Creates a labeled informational view.

TabView Bottom Accessory Placement - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

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

Message Error Alert - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Message Error Alert

Presents an alert with a message when an error is present.

Formatted Labeled Content - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Formatted Labeled Content

Creates a labeled informational view from a formatted value.

Sheet Size - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Sheet Size

Sets the available detents for the enclosing sheet.

Custom Placeholder Async URL Image - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Custom Placeholder Async URL Image

Loads and displays a modifiable image from the specified URL load request using a custom placeholder until the image loads.