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

# CPButton

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

```
class CPButton
```

## 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`](/documentation/CarPlay/CPContactCallButton) or [`CPContactMessageButton`](/documentation/CarPlay/CPContactMessageButton).

## Topics

### Creating a Button

[`init(image: UIImage, handler: ((CPButton) -> Void)?)`](/documentation/CarPlay/CPButton/init(image:handler:))

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

[`let CPButtonMaximumImageSize: CGSize`](/documentation/CarPlay/CPButtonMaximumImageSize)

The maximum size of a button’s image that CarPlay supports.

### Getting the Button’s Image

[`var image: UIImage?`](/documentation/CarPlay/CPButton/image)

The button’s image.

### Configuring the Button’s Attributes

[`var title: String?`](/documentation/CarPlay/CPButton/title)

The button’s title.

[`var isEnabled: Bool`](/documentation/CarPlay/CPButton/isEnabled)

A Boolean value that determines whether the button is in an enabled state.

## Relationships

### Conforms To

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

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

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

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

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Inherited By

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

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

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

---

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)