MenuStyle

A type that applies standard interaction behavior and a custom appearance to all menus within a view hierarchy.

ProtocoliOS 14.0+macOS 11.0+tvOS 17.0+MenuStyle in SwiftUI

Declaration

React
type MenuStyle = 'automatic' | 'button' | ButtonMenuStyle | DefaultMenuStyle;
Swift
@MainActor @preconcurrency protocol MenuStyle

Pass a literal, or build one with SwiftUI.MenuStyle from import { SwiftUI } from 'swiftui-react-native'.

Type properties

  • 'automatic'SwiftUI.MenuStyle.automatic

    The default menu style, based on the menu's context.

  • 'button'SwiftUI.MenuStyle.button

    A menu style that displays a button that toggles the display of the menu's contents when pressed.

Overview

To configure the current menu style for a view hierarchy, use the View.menuStyle(_:) modifier.

A type conforming to this protocol inherits @preconcurrency @MainActor isolation from the protocol if the conformance is included in the type's base declaration:

struct MyCustomType: Transition {
    // `@preconcurrency @MainActor` isolation by default
}

Isolation to the main actor is the default, but it's not required. Declare the conformance in an extension to opt out of main actor isolation:

extension MyCustomType: Transition {
    // `nonisolated` by default
}

From Apple’s SwiftUI documentation. Code samples there are Swift.

Used by

See also

More in Styles.