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

# menuOrder(_:)

Sets the preferred order of items for menus presented from this view.

```
nonisolated func menuOrder(_ order: MenuOrder) -> some View
```

## Parameters

`order`

The menu item ordering strategy to apply.

## Return Value

A view that uses the specified menu ordering strategy.

## Discussion

Use this modifier to override the default menu order. On supported
platforms, [`priority`](/documentation/SwiftUI/MenuOrder/priority) order keeps the first items closer
to the user’s point of interaction, whereas [`fixed`](/documentation/SwiftUI/MenuOrder/fixed) order
always orders items from top to bottom.

On iOS, the [`automatic`](/documentation/SwiftUI/MenuOrder/automatic) order resolves to
[`fixed`](/documentation/SwiftUI/MenuOrder/fixed) for menus presented within scrollable content.
Pickers that use the [`menu`](/documentation/SwiftUI/PickerStyle/menu) style also default to
[`fixed`](/documentation/SwiftUI/MenuOrder/fixed) order. In all other cases, menus default to
[`priority`](/documentation/SwiftUI/MenuOrder/priority) order.

On macOS, tvOS and watchOS, the [`automatic`](/documentation/SwiftUI/MenuOrder/automatic) order always
resolves to [`fixed`](/documentation/SwiftUI/MenuOrder/fixed) order.

The following example creates a menu that presents its content in a
fixed order from top to bottom:

```
Menu {
    Button("Select", action: selectFolders)
    Button("New Folder", action: createFolder)
    Picker("Appearance", selection: $appearance) {
        Label("Icons", systemImage: "square.grid.2x2").tag(Appearance.icons)
        Label("List", systemImage: "list.bullet").tag(Appearance.list)
    }
} label: {
    Label("Settings", systemImage: "ellipsis.circle")
}
.menuOrder(.fixed)
```

You can use this modifier on controls that present a menu.
For example, the code below creates a [`Picker`](/documentation/SwiftUI/Picker) using the
[`menu`](/documentation/SwiftUI/PickerStyle/menu) style with a priority-based order:

```
Picker("Flavor", selection: $selectedFlavor) {
    Text("Chocolate").tag(Flavor.chocolate)
    Text("Vanilla").tag(Flavor.vanilla)
    Text("Strawberry").tag(Flavor.strawberry)
}
.pickerStyle(.menu)
.menuOrder(.priority)
```

You can also use this modifier on context menus. The example below
creates a context menu that presents its content in a fixed order:

```
Text("Favorite Card Suit")
    .padding()
    .contextMenu {
        Button("♥️ - Hearts", action: selectHearts)
        Button("♣️ - Clubs", action: selectClubs)
        Button("♠️ - Spades", action: selectSpades)
        Button("♦️ - Diamonds", action: selectDiamonds)
    }
    .menuOrder(.fixed)
```

The modifier has no effect when applied to a subsection or
submenu of a menu.

---

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)