<!--
{
  "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/preferredPencilSqueezeAction",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesVAAE28preferredPencilSqueezeActionAA0f9PreferredH0Vvp"
  },
  "title" : "preferredPencilSqueezeAction"
}
-->

# preferredPencilSqueezeAction

The action that the user prefers to perform when squeezing their Apple
Pencil, as selected in the Settings app.

```
var preferredPencilSqueezeAction: 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
[`onPencilSqueeze(perform:)`](/documentation/SwiftUI/View/onPencilSqueeze(perform:)) view modifier as an indication of
what to do when the user squeezes their Apple Pencil:

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

var body: some View {
    MyDrawingCanvas()
        .onPencilSqueeze { phase in
            switch (phase, preferredAction) {
                ...
            }
        }
}
```

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

---

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)