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

# CPTabBarTemplate

A container template that displays and manages other templates, presenting them as tabs.

```
@MainActor class CPTabBarTemplate
```

## Overview

`CPTabBarTemplate` is a container template that displays a collection of other templates, where each template occupies a single tab in the tab bar. At runtime, use [`maximumTabCount`](/documentation/CarPlay/CPTabBarTemplate/maximumTabCount) to determine the maximum number of tabs that your tab bar can display.

When creating an instance of `CPTabBarTemplate`, provide an array of templates for the tab bar to display. CarPlay treats the array’s templates as root templates, each with its own navigation hierarchy. When a tab bar template is the [`rootTemplate`](/documentation/CarPlay/CPInterfaceController/rootTemplate) of your app’s interface controller and you use the controller to add and remove templates, CarPlay applies those changes to the selected tab’s navigation hierarchy.

> Note:
> You can’t add a tab bar template to an existing navigation hierarchy, or present one modally. Instead, use ``doc://com.apple.carplay/documentation/CarPlay/CPInterfaceController/setRootTemplate(_:animated:completion:)`` to set the tab bar as your app’s root template.

Use a transactional approach when making changes to the tab bar. Retrieve the current set of templates using the [`templates`](/documentation/CarPlay/CPTabBarTemplate/templates) property. Add, remove, reorder, or make appearance changes to one or more of the array’s templates. For example, use the [`tabTitle`](/documentation/CarPlay/CPTemplate/tabTitle) property to update a template’s tab title, or set [`showsTabBadge`](/documentation/CarPlay/CPTemplate/showsTabBadge) to `true` to add an indicator to a template’s tab. Then call the [`updateTemplates(_:)`](/documentation/CarPlay/CPTabBarTemplate/updateTemplates(_:)) method and pass it the updated array. CarPlay commits those changes and updates the tab bar.

When the user selects a tab, the template calls the [`tabBarTemplate(_:didSelect:)`](/documentation/CarPlay/CPTabBarTemplateDelegate/tabBarTemplate(_:didSelect:)) method on its delegate, which is an object you provide that conforms to the [`CPTabBarTemplateDelegate`](/documentation/CarPlay/CPTabBarTemplateDelegate) protocol.

## Topics

### Creating a Tab Bar Template

[`-  initWithTemplates:`](/documentation/CarPlay/CPTabBarTemplate/init(templates:))

Creates a tab bar template that displays the provided root templates as tabs.

### Managing Tab Bar Interactions

[`delegate`](/documentation/CarPlay/CPTabBarTemplate/delegate)

The object that acts as the template’s delegate.

[`CPTabBarTemplateDelegate`](/documentation/CarPlay/CPTabBarTemplateDelegate)

The methods an object implements to act as the delegate for a tab bar template.

### Managing the Templates

[`templates`](/documentation/CarPlay/CPTabBarTemplate/templates)

The tab bar’s templates.

[`-  updateTemplates:`](/documentation/CarPlay/CPTabBarTemplate/updateTemplates(_:))

Adds, removes, reorders, or updates the tab bar’s templates.

[`maximumTabCount`](/documentation/CarPlay/CPTabBarTemplate/maximumTabCount)

The maximum number of tabs that the template can display.

### Getting the Selected Template

[`selectedTemplate`](/documentation/CarPlay/CPTabBarTemplate/selectedTemplate)

The currently selected template in the tab bar.

### Instance Methods

[`-  selectTemplate:`](/documentation/CarPlay/CPTabBarTemplate/select(_:))

[`-  selectTemplateAtIndex:`](/documentation/CarPlay/CPTabBarTemplate/selectTemplate(at:))

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`CPTemplate`](/documentation/CarPlay/CPTemplate)

---

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)