<!--
{
  "availability" : [
    "iOS: 16.4.0 -",
    "iPadOS: 16.4.0 -",
    "macCatalyst: 16.4.0 -",
    "macOS: 13.3.0 -",
    "tvOS: 16.4.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/menuActionDismissBehavior(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE25menuActionDismissBehavioryQrAA04MenuefG0VF"
  },
  "title" : "menuActionDismissBehavior(_:)"
}
-->

# menuActionDismissBehavior(_:)

Tells a menu whether to dismiss after performing an action.

```
nonisolated func menuActionDismissBehavior(_ behavior: MenuActionDismissBehavior) -> some View
```

## Parameters

`behavior`

The menu action dismissal behavior to apply.

## Return Value

A view that has the specified menu dismissal behavior.

## Discussion

Use this modifier to control the dismissal behavior of a menu.
In the example below, the menu doesn’t dismiss after someone
chooses either the increase or decrease action:

```
Menu("Font size") {
    Button(action: increase) {
        Label("Increase", systemImage: "plus.magnifyingglass")
    }
    .menuActionDismissBehavior(.disabled)

    Button("Reset", action: reset)

    Button(action: decrease) {
        Label("Decrease", systemImage: "minus.magnifyingglass")
    }
    .menuActionDismissBehavior(.disabled)
}
```

You can use this modifier on any controls that present a menu, like a
[`Picker`](/documentation/SwiftUI/Picker) that uses the [`menu`](/documentation/SwiftUI/PickerStyle/menu) style or a
[`ControlGroup`](/documentation/SwiftUI/ControlGroup). For example, the code below creates a picker that
disables dismissal when someone selects one of the options:

```
Picker("Flavor", selection: $selectedFlavor) {
    ForEach(Flavor.allCases) { flavor in
        Text(flavor.rawValue.capitalized)
            .tag(flavor)
    }
}
.pickerStyle(.menu)
.menuActionDismissBehavior(.disabled)
```

You can also use this modifier on context menus. The example below
creates a context menu that stays presented after someone selects an
action to run:

```
Text("Favorite Card Suit")
    .padding()
    .contextMenu {
        Button("♥️ - Hearts", action: increaseHeartsCount)
        Button("♣️ - Clubs", action: increaseClubsCount)
        Button("♠️ - Spades", action: increaseSpadesCount)
        Button("♦️ - Diamonds", action: increaseDiamondsCount)
    }
    .menuActionDismissBehavior(.disabled)
```

---

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)