How it works
MenuStyleConfiguration carries the resolved properties of a menu — its label and its contents — to a custom menu style at the moment SwiftUI is about to render it. You don't create this type yourself; SwiftUI builds an instance and hands it to your style's makeBody(configuration:) method, where it represents the menu that the system wants drawn. Reach for it whenever the built-in menu styles aren't enough and you want to define your own reusable appearance for menus by conforming to MenuStyle, while leaving the menu's behavior and interaction to the framework.
Conform to MenuStyle and receive the Configuration
A custom menu style is a type that conforms to MenuStyle and implements makeBody(configuration:). The configuration parameter is a MenuStyleConfiguration value describing the menu to render. In the example, BorderedMenuStyle conforms to MenuStyle, and its makeBody(configuration:) signature receives configuration as the typealiased Configuration (which is MenuStyleConfiguration).
Rebuild the menu with Menu(_:)
Rather than exposing each property individually, you typically pass the whole configuration to the Menu(_:) initializer that accepts a MenuStyleConfiguration. This reconstructs the system menu — preserving its label and the actions inside — so you can wrap it in your own visuals. The example writes Menu(configuration) to recreate the menu before styling it.
Apply your appearance around the reconstructed menu
Once you have the menu back from Menu(configuration), you decorate it with ordinary view modifiers to define the style's look. Here the menu is given padding(8), a tinted background(Color.blue.opacity(0.15)), and a clipShape(RoundedRectangle(cornerRadius: 8)) — the framing that makes BorderedMenuStyle distinct without touching what the menu does.
Install the style with menuStyle(_:)
A MenuStyle takes effect only when you attach it to a menu (or an enclosing view) with the menuStyle(_:) modifier, which is where SwiftUI produces the MenuStyleConfiguration and invokes your makeBody. The example applies .menuStyle(BorderedMenuStyle()) to the Menu("Options") that holds the Rename, Duplicate, and Delete buttons.
Example & preview
Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.
struct MenuStyleConfigurationDemo: View {
struct BorderedMenuStyle: MenuStyle {
func makeBody(configuration: Configuration) -> some View {
Menu(configuration)
.padding(8)
.background(Color.blue.opacity(0.15))
.clipShape(RoundedRectangle(cornerRadius: 8))
}
}
var body: some View {
Menu("Options") {
Button("Rename") {}
Button("Duplicate") {}
Button("Delete", role: .destructive) {}
}
.menuStyle(BorderedMenuStyle())
.padding()
}
}