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

# CPNowPlayingButton

The abstract base class that Now Playing template buttons use.

```
@MainActor class CPNowPlayingButton
```

## Overview

`CPNowPlayingButton` is an abstract base class for defining buttons that the Now Playing template displays. It provides the common functionality that’s present in all buttons available to the template.

You don’t use this class directly, or create your own subclasses. Instead, you must use one of the concrete subclasses that the framework provides, such as [`CPNowPlayingImageButton`](/documentation/CarPlay/CPNowPlayingImageButton) or [`CPNowPlayingShuffleButton`](/documentation/CarPlay/CPNowPlayingShuffleButton).

## Topics

### Creating a Button

[`init(handler: ((CPNowPlayingButton) -> Void)?)`](/documentation/CarPlay/CPNowPlayingButton/init(handler:))

Creates a Now Playing button that invokes a handler.

### Managing the Button State

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

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

[`var isSelected: Bool`](/documentation/CarPlay/CPNowPlayingButton/isSelected)

A Boolean value that indicates whether the button is in a selected state.

### Initializers

[`init?(coder: NSCoder)`](/documentation/CarPlay/CPNowPlayingButton/init(coder:))

## Relationships

### Inherited By

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

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

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

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

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

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

### Conforms To

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)