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

# badge(_:)

Generates a badge for a tab from an integer value.

## Declaration

```swift
nonisolated func badge(_ count: Int) -> some TabContent<Self.TabValue>

```

## 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. The number provided will appear as a numerical indicator on the given tab. The following example shows a TabView with the value of alerts.count displayed as a badge on the alerts tab. TabView {     Tab("Home", systemImage: "house") {         HomeView()     }     Tab("Alerts", systemImage: "bell") {         AlertsView()     }     .badge(alerts.count) }

## See Also

### Configuring tab content

- [contextMenu(menuItems:)](swiftui/tabcontent/contextmenu(menuitems:).md)
- [customizationBehavior(_:for:)](swiftui/tabcontent/customizationbehavior(_:for:).md)
- [customizationID(_:)](swiftui/tabcontent/customizationid(_:).md)
- [defaultSectionExpansion(_:)](swiftui/tabcontent/defaultsectionexpansion(_:).md)
- [TabSectionExpansion](swiftui/tabsectionexpansion.md)
- [defaultVisibility(_:for:)](swiftui/tabcontent/defaultvisibility(_:for:).md)
- [disabled(_:)](swiftui/tabcontent/disabled(_:).md)
- [draggable(_:)](swiftui/tabcontent/draggable(_:).md)
- [dropDestination(for:action:)](swiftui/tabcontent/dropdestination(for:action:).md)
- [help(_:)](swiftui/tabcontent/help(_:).md)
- [hidden(_:)](swiftui/tabcontent/hidden(_:).md)
- [popover(isPresented:attachmentAnchor:arrowEdge:content:)](swiftui/tabcontent/popover(ispresented:attachmentanchor:arrowedge:content:).md)
- [popover(item:attachmentAnchor:arrowEdge:content:)](swiftui/tabcontent/popover(item:attachmentanchor:arrowedge:content:).md)
- [sectionActions(content:)](swiftui/tabcontent/sectionactions(content:).md)
- [springLoadingBehavior(_:)](swiftui/tabcontent/springloadingbehavior(_:).md)
