---
title: CPAlertAction
framework: carplay
role: symbol
role_heading: Class
path: carplay/cpalertaction
---

# CPAlertAction

An object that encapsulates an action the user can perform on an action sheet or alert.

## Declaration

```swift
class CPAlertAction
```

## Overview

Overview Use an alert action to display a button on an alert. The combination of the alert and the action styles determines the appearance of the action button. To perform an action after the user taps the button, provide a block to the action’s handler property.

## Topics

### Creating an Alert Action

- [init(title:style:handler:)](carplay/cpalertaction/init(title:style:handler:).md)

### Getting the Title

- [title](carplay/cpalertaction/title.md)

### Getting the Action Style

- [style](carplay/cpalertaction/style-swift.property.md)
- [CPAlertAction.Style](carplay/cpalertaction/style-swift.enum.md)

### Getting the Action Handler

- [handler](carplay/cpalertaction/handler.md)
- [CPAlertActionHandler](carplay/cpalertactionhandler.md)

### Initializers

- [init(title:color:handler:)](carplay/cpalertaction/init(title:color:handler:).md)
- [init(coder:)](carplay/cpalertaction/init(coder:).md)

### Instance Properties

- [color](carplay/cpalertaction/color.md)

## Relationships

### Inherits From

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

### Conforms To

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

## See Also

### Actions and Alerts

- [CPActionSheetTemplate](carplay/cpactionsheettemplate.md)
- [CPAlertTemplate](carplay/cpalerttemplate.md)
