<!--
{
  "availability" : [
    "iOS: 17.5.0 -",
    "iPadOS: 17.5.0 -",
    "macCatalyst: 17.5.0 -",
    "macOS: 14.5.0 -",
    "visionOS: 26.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/preferredPencilDoubleTapAction",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesVAAE30preferredPencilDoubleTapActionAA0f9PreferredI0Vvp"
  },
  "title" : "preferredPencilDoubleTapAction"
}
-->

# preferredPencilDoubleTapAction

The action that the user prefers to perform after double-tapping their
Apple Pencil, as selected in the Settings app.

```
var preferredPencilDoubleTapAction: PencilPreferredAction { get }
```

## Discussion

You can read this value by creating a property with the [`Environment`](/documentation/SwiftUI/Environment)
property wrapper and using it inside the action closure of the
[`onPencilDoubleTap(perform:)`](/documentation/SwiftUI/View/onPencilDoubleTap(perform:)) view modifier as an indication of
what to do after the user double-taps their Apple Pencil:

```
@Environment(\.preferredPencilDoubleTapAction) private var preferredAction

var body: some View {
    MyDrawingCanvas()
        .onPencilDoubleTap { value in
            switch preferredAction {
                ...
            }
        }
}
```

In macOS, this value cannot be changed by users and is always set to
[`switchEraser`](/documentation/SwiftUI/PencilPreferredAction/switchEraser).

---

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)