---
title: "badge(_:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/badge(_:)"
---

# badge(_:)

Generates a badge for the view from an integer value.

## Declaration

```swift
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

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") }

## See Also

### Displaying a badge on a list item

- [badgeProminence(_:)](swiftui/view/badgeprominence(_:).md)
- [badgeProminence](swiftui/environmentvalues/badgeprominence.md)
- [BadgeProminence](swiftui/badgeprominence.md)
