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

# NSMenuItemBadge

A control that provides additional quantitative information specific to a menu item, such as the number of available updates.

```
class NSMenuItemBadge
```

## Overview

You create a badge using an initializer or a predefined factory method, and then you assign it to the [`badge`](/documentation/AppKit/NSMenuItem/badge) property of a [`NSMenuItem`](/documentation/AppKit/NSMenuItem) for display.

![A menu containing five menu items with each menu item displaying a different style of badge. A NSMenuItem callout points to a menu item in the menu. A NSMenuItemBadge call out points to the badge that displays to the right of the menu item.](images/com.apple.appkit/media-4304515@2x.png)

For example, to display a badge with a count, use the [`init(count:)`](/documentation/AppKit/NSMenuItemBadge/init(count:)) initalizer, passing in the value of `count` as an `Int`.

```objc
NSMenu *menu = [[NSMenu alloc] init];

// Create a menu item.
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Messages" action:nil keyEquivalent:@""];

// Set the badge to display "6".
menuItem.badge = [[NSMenuItemBadge alloc] initWithCount:6];

// Add the item to the menu.
[menu addItem:menuItem];
```

To display a badge with a custom string, use the [`init(string:)`](/documentation/AppKit/NSMenuItemBadge/init(string:)) initializer, passing in the string you want to display.

```objc
NSInteger updateCount = 3;
NSMenu *menu = [[NSMenu alloc] init];

// Create a menu item.
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Changes" action:nil keyEquivalent:@""];

// Set the badge to display "3 changes".
menuItem.badge = [[NSMenuItemBadge alloc] initWithString:[NSString stringWithFormat:@"%ld changes", (long)updateCount]];

// Add the item to the menu.
[menu addItem:menuItem];
```

To display a badge using a predefined [`NSMenuItemBadge.BadgeType`](/documentation/AppKit/NSMenuItemBadge/BadgeType), use a factory method such as [`newItems(count:)`](/documentation/AppKit/NSMenuItemBadge/newItems(count:)), passing in the `count` of the badge to display.

```objc
NSMenu *menu = [[NSMenu alloc] init];

// Add a new items style badge.
NSMenuItem *newItemsItem = [[NSMenuItem alloc] initWithTitle:@"New Items" action:nil keyEquivalent:@""];
newItemsItem.badge = [NSMenuItemBadge newItemsWithCount:3];
[menu addItem:newItemsItem];

// Add an alerts style badge.
NSMenuItem *alertsItem = [[NSMenuItem alloc] initWithTitle:@"New Items" action:nil keyEquivalent:@""];
alertsItem.badge = [NSMenuItemBadge alertsWithCount:4];
[menu addItem:alertsItem];

// Add an update style badge.
NSMenuItem *updatesItem = [[NSMenuItem alloc] initWithTitle:@"Updates" action:nil keyEquivalent:@""];
updatesItem.badge = [NSMenuItemBadge updatesWithCount:5];
[menu addItem:updatesItem];
```

> Important:
> If you use one of the predefined badge types, the system localizes and pluralizes the string for you. If you create your own custom badge string, you need to localize and pluralize that string yourself. For more information on how to localize and pluralize text, see <doc://com.apple.documentation/documentation/Xcode/localizing-and-varying-text-with-a-string-catalog>.

The default value of this property is `nil`.

## Topics

### Creating menu item badges

[`init(count:)`](/documentation/AppKit/NSMenuItemBadge/init(count:))

Creates a badge with a count and an empty string.

[`initWithCount:type:`](/documentation/AppKit/NSMenuItemBadge/initWithCount:type:)

Initializes the badge with a count and a pre-defined badge type.

[`init(string:)`](/documentation/AppKit/NSMenuItemBadge/init(string:))

Creates a badge with the provided custom string.

### Creating badges of a specific type

[`alerts(count:)`](/documentation/AppKit/NSMenuItemBadge/alerts(count:))

Creates an alert-style badge with an integer count and a predefined label that represents the number of alerts.

[`newItems(count:)`](/documentation/AppKit/NSMenuItemBadge/newItems(count:))

Creates a new item-style badge with an integer count and a predefined label that represents the number of new items.

[`updates(count:)`](/documentation/AppKit/NSMenuItemBadge/updates(count:))

Creates an update-style badge with an integer count and a predefined label that represents the number of available updates.

[`NSMenuItemBadge.BadgeType`](/documentation/AppKit/NSMenuItemBadge/BadgeType)

Constants that define types of badges for display.

### Accessing menu item badge attributes

[`itemCount`](/documentation/AppKit/NSMenuItemBadge/itemCount)

The number of items the badge displays.

[`stringValue`](/documentation/AppKit/NSMenuItemBadge/stringValue-fc9f)

The string representation of the badge when it displays.

[`type`](/documentation/AppKit/NSMenuItemBadge/type)

The type of items the badge displays.



---

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)