<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/buttonRepeatBehavior(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE20buttonRepeatBehavioryQrAA06ButtoneF0VF"
  },
  "title" : "buttonRepeatBehavior(_:)"
}
-->

# buttonRepeatBehavior(_:)

Sets whether buttons in this view should repeatedly trigger their
actions on prolonged interactions.

```
nonisolated func buttonRepeatBehavior(_ behavior: ButtonRepeatBehavior) -> some View
```

## Parameters

`behavior`

A value of `enabled` means that buttons should
enable repeating behavior and a value of `disabled` means that buttons
should disallow repeating behavior.

## Discussion

Apply this to buttons that increment or decrement a value or perform
some other inherently iterative operation. Interactions such as
pressing-and-holding on the button, holding the button’s keyboard
shortcut, or holding down the space key while the button is focused will
trigger this repeat behavior.

```
Button {
    playbackSpeed.advance(by: 1)
} label: {
    Label("Speed up", systemImage: "hare")
}
.buttonRepeatBehavior(.enabled)
```

This affects all system button styles, as well as automatically
affects custom `ButtonStyle` conforming types. This does not
automatically apply to custom `PrimitiveButtonStyle` conforming types,
and the `EnvironmentValues.buttonRepeatBehavior` value should be used
to adjust their custom gestures as appropriate.

---

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)