<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/badge(_:)-8adyq",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE5badgeyQrSiF"
  },
  "title" : "badge(_:)"
}
-->

# badge(_:)

Generates a badge for the view from an integer value.

```
nonisolated func badge(_ count: Int) -> some View
```

## Parameters

`count`

An integer value to display in the badge.
Set the value to zero to hide the badge.

## Discussion

Use a badge to convey optional, supplementary information about a
view. Keep the contents of the badge as short as possible. Badges
appear in list rows, tab bars, toolbar items, and menus.

The following example shows a `List` with the value of `recentItems.count`
represented by a badge on one of the rows:

```
List {
    Text("Recents")
        .badge(recentItems.count)
    Text("Favorites")
}
```

![A table with two rows, titled Recents and Favorites. The first row](images/com.apple.SwiftUI/View-badge-1@2x.png)

---

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)