<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSMenuItem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMenuItem"
  },
  "title" : "NSMenuItem"
}
-->

# NSMenuItem

A command item in an app menu.

```
class NSMenuItem
```

## Overview

The [`NSMenuItem`](/documentation/AppKit/NSMenuItem) class includes some private functionality needed to maintain binary compatibility with other components of Cocoa. Because of this fact, you can’t replace the [`NSMenuItem`](/documentation/AppKit/NSMenuItem) class with a different class, but you can subclass it if necessary.

## Topics

### Creating a menu item

[`-  initWithTitle:action:keyEquivalent:`](/documentation/AppKit/NSMenuItem/init(title:action:keyEquivalent:))

Returns an initialized instance of `NSMenuItem`.

[`-  initWithCoder:`](/documentation/AppKit/NSMenuItem/init(coder:))

### Enabling a menu item

[`enabled`](/documentation/AppKit/NSMenuItem/isEnabled)

A Boolean value that indicates whether the menu item is enabled.

### Managing hidden status

[`hidden`](/documentation/AppKit/NSMenuItem/isHidden)

A Boolean value that indicates whether the menu item is hidden.

[`hiddenOrHasHiddenAncestor`](/documentation/AppKit/NSMenuItem/isHiddenOrHasHiddenAncestor)

A Boolean value that indicates whether the menu item or any of its superitems is hidden.

### Managing the target and action

[`target`](/documentation/AppKit/NSMenuItem/target)

The menu item’s target.

[`action`](/documentation/AppKit/NSMenuItem/action)

The menu item’s action-method selector.

### Managing the title

[`title`](/documentation/AppKit/NSMenuItem/title)

The menu item’s title.

[`attributedTitle`](/documentation/AppKit/NSMenuItem/attributedTitle)

A custom string for a menu item.

### Managing the tag

[`tag`](/documentation/AppKit/NSMenuItem/tag)

The menu item’s tag.

### Managing the state

[`state`](/documentation/AppKit/NSMenuItem/state)

The state of the menu item.

### Managing the image

[`image`](/documentation/AppKit/NSMenuItem/image)

The menu item’s image.

[`onStateImage`](/documentation/AppKit/NSMenuItem/onStateImage)

The image of the menu item that indicates an “on” state.

[`offStateImage`](/documentation/AppKit/NSMenuItem/offStateImage)

The image of the menu item that indicates an “off” state.

[`mixedStateImage`](/documentation/AppKit/NSMenuItem/mixedStateImage)

The image of the menu item that indicates a “mixed” state, that is, a state neither “on” nor “off.”

[`preferredImageVisibility`](/documentation/AppKit/NSMenuItem/preferredImageVisibility)

A menu item’s image visibility determines whether the item’s image is displayed when the menu is open.
The default visibility for an item’s image is Automatic. With this value, AppKit determines whether the item’s image is visible based on system configuration.
If an item’s image should be visible in all cases, regardless of macOS version or other settings, then set the image visibility to `.visible`.

[`ImageVisibility`](/documentation/AppKit/NSMenuItem/ImageVisibility)

Values for the `preferredImageVisibility` property of NSMenuItem.
When a menu item is initialized, the default value for the item’s image visibility is Automatic.

### Managing the badge

[`badge`](/documentation/AppKit/NSMenuItem/badge)

A badge used to provide additional quantitative information specific to the menu item, such as the number of available updates.

### Managing the section header

[`sectionHeader`](/documentation/AppKit/NSMenuItem/isSectionHeader)

A Boolean value indicating whether the menu item is a section header.

[`+  sectionHeaderWithTitle:`](/documentation/AppKit/NSMenuItem/sectionHeaderWithTitle:)

Returns a menu item representing a section header for a logical grouping of menu commands.

### Managing submenus

[`submenu`](/documentation/AppKit/NSMenuItem/submenu)

The submenu of the menu item.

[`hasSubmenu`](/documentation/AppKit/NSMenuItem/hasSubmenu)

A Boolean value that indicates whether the menu item has a submenu.

[`parentItem`](/documentation/AppKit/NSMenuItem/parent)

The menu item whose submenu contains the receiver.

### Managing the separator item

[`separatorItem`](/documentation/AppKit/NSMenuItem/isSeparatorItem)

A Boolean value indicating whether the menu item is a separator item.

[`+  separatorItem`](/documentation/AppKit/NSMenuItem/separator())

Returns a menu item that is used to separate logical groups of menu commands.

### Managing the owning menu

[`menu`](/documentation/AppKit/NSMenuItem/menu)

The menu item’s menu.

### Managing key equivalents

[`keyEquivalent`](/documentation/AppKit/NSMenuItem/keyEquivalent)

The menu item’s unmodified key equivalent.

[`keyEquivalentModifierMask`](/documentation/AppKit/NSMenuItem/keyEquivalentModifierMask)

The menu item’s keyboard equivalent modifiers.

### Managing mnemonics

[`-  setMnemonicLocation:`](/documentation/AppKit/NSMenuItem/setMnemonicLocation:)

Sets the character of the menu item title at location that is to be underlined.

[`-  mnemonicLocation`](/documentation/AppKit/NSMenuItem/mnemonicLocation)

Returns the position of the underlined character in the menu item title used as a mnemonic.

[`-  setTitleWithMnemonic:`](/documentation/AppKit/NSMenuItem/setTitleWithMnemonic(_:))

Sets the title of a menu item with a character denoting an access key.

[`-  mnemonic`](/documentation/AppKit/NSMenuItem/mnemonic)

Returns the character in the menu item title that appears underlined for use as a mnemonic.

### Managing user key equivalents

[`usesUserKeyEquivalents`](/documentation/AppKit/NSMenuItem/usesUserKeyEquivalents)

Returns a Boolean value that indicates whether menu items conform to user preferences for key equivalents.

[`userKeyEquivalent`](/documentation/AppKit/NSMenuItem/userKeyEquivalent)

The user-assigned key equivalent for the menu item.

[`allowsAutomaticKeyEquivalentLocalization`](/documentation/AppKit/NSMenuItem/allowsAutomaticKeyEquivalentLocalization)

A Boolean value that determines whether the system automatically remaps the keyboard shortcut to support localized keyboards.

[`allowsAutomaticKeyEquivalentMirroring`](/documentation/AppKit/NSMenuItem/allowsAutomaticKeyEquivalentMirroring)

A Boolean value that determines whether the system automatically swaps input strings for some keyboard shortcuts when the interface direction changes.

[`allowsKeyEquivalentWhenHidden`](/documentation/AppKit/NSMenuItem/allowsKeyEquivalentWhenHidden)

### Managing alternates

[`alternate`](/documentation/AppKit/NSMenuItem/isAlternate)

A Boolean value that marks the menu item as an alternate to the previous menu item.

### Managing indentation levels

[`indentationLevel`](/documentation/AppKit/NSMenuItem/indentationLevel)

The menu item indentation level for the menu item.

### Managing tool tips

[`toolTip`](/documentation/AppKit/NSMenuItem/toolTip)

A help tag for the menu item.

### Representing an object

[`representedObject`](/documentation/AppKit/NSMenuItem/representedObject)

The object represented by the menu item.

### Managing the view

[`view`](/documentation/AppKit/NSMenuItem/view)

The content view for the menu item.

### Getting highlighted status

[`highlighted`](/documentation/AppKit/NSMenuItem/isHighlighted)

A Boolean value that indicates whether the menu item should be drawn highlighted.

### Identifying the Continuity Camera menu item

[`NSMenuItemImportFromDeviceIdentifier`](/documentation/AppKit/NSMenuItem/importFromDeviceIdentifier)

The identifier for a Continuity Camera menu item, which takes pictures or scans documents using an iOS device.

### Type Methods

[`sectionHeader(title:)`](/documentation/AppKit/NSMenuItem/sectionHeader(title:))

Returns a menu item representing a section header for a logical grouping of menu commands.

[`sectionHeader(withTitle:)`](/documentation/AppKit/NSMenuItem/sectionHeader(withTitle:))

Returns a menu item representing a section header for a logical grouping of menu commands.

## Relationships

### Conforms To

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSAccessibilityElementProtocol`](/documentation/AppKit/NSAccessibilityElementProtocol)

[`NSUserInterfaceItemIdentification`](/documentation/AppKit/NSUserInterfaceItemIdentification)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`NSAccessibilityProtocol`](/documentation/AppKit/NSAccessibilityProtocol)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSValidatedUserInterfaceItem`](/documentation/AppKit/NSValidatedUserInterfaceItem)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)