<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/musicPicker(isPresented:title:selection:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewP010_MusicKit_aB0E11musicPicker11isPresented5title9selectionQrAA7BindingVySbG_AA4TextVSgAJy0dE00D14ItemCollectionVyqd__GGtAD08PickabledN0Rd__lF::OverloadGroup"
  },
  "title" : "musicPicker(isPresented:title:selection:)"
}
-->

# musicPicker(isPresented:title:selection:)

Presents a music picker to select items from the Apple Music catalog and the user’s music library.

```
@MainActor @preconcurrency func musicPicker<Selection>(isPresented: Binding<Bool>, title: Text? = nil, selection: Binding<MusicItemCollection<Selection>>) -> some View where Selection : PickableMusicItem
```

## Parameters

`isPresented`

The binding to whether the music picker should be shown.

`title`

The title to be shown in the navigation bar.

`selection`

The selected music items.

## Discussion

Example:

```swift
struct MusicPickerButton: View {
    @State private var isShowingMusicPicker = false
    @State private var selectedSongs: MusicItemCollection<Song> = []
    private var title = "Add to Playlist"

    var body: some View {
        Button("Pick one or more songs") {
            isShowingMusicPicker = true
        }
        .musicPicker(
            isPresented: $isShowingMusicPicker,
            title: Text(title), 
            selection: $selectedSongs
        )
        .onChange(of: selectedSongs) { oldValue, newValue in
            let delta = newValue.count - oldValue.count
            print("You selected \(delta) new tracks!")
        }
    }
}
```

---

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)