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

# touchBarItemPresence(_:)

Sets the behavior of the user-customized view.

## Declaration

```swift
nonisolated func touchBarItemPresence(_ presence: TouchBarItemPresence) -> some View

```

## Parameters

- `presence`: One of the allowed doc://com.apple.SwiftUI/documentation/SwiftUI/TouchBarItemPresence descriptions.

## Return Value

Return Value A trait that describes the behavior for this Touch Bar view.

## Discussion

Discussion Use touchBarItemPresence(_:) to define the visibility requirements of a particular Touch Bar view during customization by the user. Touch Bar views may be: .required: not allowed to be removed by the user. .default: shown by default prior to user customization, but removable. .optional: not visible by default, but can be added through the customization palette. Each TouchBarItemPresence must be initialized with a string that is a globally unique identifier for this item. In the example below, all of the Touch Bar items are visible in the Touch Bar by default, except for the “Clubs” item. It’s set to .optional but is configurable by the user: TextField("TouchBar Demo", text: $placeholder)     .frame(maxWidth: .infinity, maxHeight: .infinity)     .focusable()     .touchBar {         Button("♥️", action: selectHearts)             .touchBarItemPresence(.required("heartsKey"))         Button("♣️", action: selectClubs)             .touchBarItemPresence(.optional("clubsKey"))         Button("♠️", action: selectSpades)             .touchBarItemPresence(.required("spadesKey"))         Button("♦️", action: selectDiamonds)             .touchBarItemPresence(.required("diamondsKey")) }

## See Also

### Managing Touch Bar input

- [touchBar(content:)](swiftui/view/touchbar(content:).md)
- [touchBar(_:)](swiftui/view/touchbar(_:).md)
- [touchBarItemPrincipal(_:)](swiftui/view/touchbaritemprincipal(_:).md)
- [touchBarCustomizationLabel(_:)](swiftui/view/touchbarcustomizationlabel(_:).md)
- [TouchBar](swiftui/touchbar.md)
- [TouchBarItemPresence](swiftui/touchbaritempresence.md)
