---
title: CPButton
framework: carplay
role: symbol
role_heading: Class
path: carplay/cpbutton
---

# CPButton

A button that displays an image and invokes a handler when the user taps it.

## Declaration

```swift
class CPButton
```

## Overview

Overview You create instances of CPButton to provide a template’s actions. The button displays a custom image that communicates its function. When a user taps the button, CarPlay invokes the handler you provide. The template that contains the button manages its appearance. The framework provides specialized subclasses for common actions, such as CPContactCallButton or CPContactMessageButton.

## Topics

### Creating a Button

- [init(image:handler:)](carplay/cpbutton/init(image:handler:).md)
- [CPButtonMaximumImageSize](carplay/cpbuttonmaximumimagesize.md)

### Getting the Button’s Image

- [image](carplay/cpbutton/image.md)

### Configuring the Button’s Attributes

- [title](carplay/cpbutton/title.md)
- [isEnabled](carplay/cpbutton/isenabled.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Inherited By

- [CPContactCallButton](carplay/cpcontactcallbutton.md)
- [CPContactDirectionsButton](carplay/cpcontactdirectionsbutton.md)
- [CPContactMessageButton](carplay/cpcontactmessagebutton.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Related Types

- [CPImageSet](carplay/cpimageset.md)
- [CarPlayErrorDomain](carplay/carplayerrordomain.md)
