NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

NavigationLink inside DisclosureGroup

Forums > macOS

Is it possible to get a NavigationLink to work with a subitem in a DisclosureGroup?

Not intened to be useful, the following is just an example of sort of something I want to do. The first navigation link works the second doesn't even show the navigation link.



        List(selection: self.$selection) {

            NavigationLink(destination: ManuscriptView(name: "howdy")) {
                Label("Manuscript", systemImage: "book")

            DisclosureGroup("Items", isExpanded: $topExpanded) {

                NavigationLink(destination: ManuscriptView(name: "howdy")) {
                    Toggle("Toggle 1", isOn: $toggleStates.oneIsOn)



I couldnt get that to work, but I found this example which does what I need with OutlineGroup instead:

    NavigationView {

        List() {

            ForEach(data) { dataValue in

                Section(header: EmptyView()) {

                    OutlineGroup(dataValue, id: \.id, children: \.children) { item in

                        NavigationLink(destination: ManuscriptView(name: item.description)) {
                            Text ("\(item.description)").padding(.all)
        .navigationTitle("Fruits & Vegitables")


@jfranknichols it is possible - just make sure you're implementing correctly the Identifiable protocol. Instead of doing:

let id = UUID()

Make the id property be something unique, that doesn't change, and is associated to some data of that line.


Hacking with Swift is sponsored by MadMachine

SPONSORED Want to explore your Swift skill outside of the Apple world? Join the MadMachine community and start to program microcontrollers in Swift.

Get it now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.