<!--
{
  "availability" : [
    "iOS: 12.0.0 - 14.0.0",
    "iPadOS: 12.0.0 - 14.0.0",
    "macCatalyst: 13.1.0 - 14.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "CarPlay",
  "identifier" : "/documentation/CarPlay/CPBarButton/init(type:handler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "CarPlay"
    ],
    "preciseIdentifier" : "c:objc(cs)CPBarButton(im)initWithType:handler:"
  },
  "title" : "init(type:handler:)"
}
-->

# init(type:handler:)

Creates a bar button with a type and handler.

```
init(type: CPBarButton.Type, handler: CPBarButtonHandler? = nil)
```

## Parameters

`type`

The button type.

`handler`

The block that CarPlay invokes when the user taps the button.

## Return Value

A bar button of the specified type.

---

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)