---
title: "presentTemplate(_:animated:completion:)"
framework: carplay
role: symbol
role_heading: Instance Method
path: "carplay/cpinterfacecontroller/presenttemplate(_:animated:completion:)"
---

# presentTemplate(_:animated:completion:)

Presents a template modally.

## Declaration

```swift
func presentTemplate(_ templateToPresent: CPTemplate, animated: Bool, completion: ((Bool, (any Error)?) -> Void)? = nil)
```

```swift
func presentTemplate(_ templateToPresent: CPTemplate, animated: Bool) async throws -> Bool
```

## Parameters

- `templateToPresent`: The template to present modally.
- `animated`: If doc://com.apple.documentation/documentation/Swift/true, CarPlay animates the presentation of the template.
- `completion`: The closure CarPlay calls after it presents the template.

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func presentTemplate(_ templateToPresent: CPTemplate, animated: Bool) async throws -> Bool For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. CarPlay can only present one modal template at a time. templateToPresent must be one of CPActionSheetTemplate, CPAlertTemplate, or CPVoiceControlTemplate. CarPlay calls completion after it presents the template. The Boolean parameter is true when the presentation succeeds; otherwise, it’s false and CarPlay provides an error that describes the failure. CarPlay throws an exception if the presentation fails and you don’t provide a closure.

## See Also

### Displaying Templates Modally

- [dismissTemplate(animated:completion:)](carplay/cpinterfacecontroller/dismisstemplate(animated:completion:).md)
- [presentedTemplate](carplay/cpinterfacecontroller/presentedtemplate.md)
