<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Stepper/init(_:value:in:step:format:onEditingChanged:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7StepperVA2A4TextVRszrlE_5value2in4step6format16onEditingChangedACyAEG10Foundation23LocalizedStringResourceV_AA7BindingVy11FormatInputQyd__GSNyARGAQ_6StrideQYd__qd__ySbctcAL09ParseableQ5StyleRd__SBARRQSS0Q6OutputRtd__lufc::OverloadGroup"
  },
  "title" : "init(_:value:in:step:format:onEditingChanged:)"
}
-->

# init(_:value:in:step:format:onEditingChanged:)

Creates a stepper instance that increments and decrements a binding to
a value, by a step size and within a closed range that you provide,
displaying its value with an applied format style.

```
@export(implementation) nonisolated init<F>(_ titleResource: LocalizedStringResource, value: Binding<F.FormatInput>, in bounds: ClosedRange<F.FormatInput>, step: F.FormatInput.Stride = 1, format: F, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where F : ParseableFormatStyle, F.FormatInput : BinaryFloatingPoint, F.FormatOutput == String
```

## Parameters

`titleResource`

Text resource for the stepper’s localized title
describing the purpose of the stepper.

`value`

A [`Binding`](/documentation/SwiftUI/Binding) to a value that your provide.

`bounds`

A closed range that describes the upper and lower bounds
permitted by the stepper.

`step`

The amount to increment or decrement `value` each time the
user clicks or taps the stepper’s increment or decrement button,
respectively. Defaults to `1`.

`format`

A format style of type `F` to use when converting between
the string the user edits and the underlying value of type
`F.FormatInput`. If `format` can’t perform the conversion, the
stepper leaves `value` unchanged. If the user stops editing the
text in an invalid state, the stepper updates the text to the last
known valid value.

`onEditingChanged`

A closure that’s called when editing begins and
ends. For example, on iOS, the user may touch and hold the increment
or decrement buttons on a `Stepper` which causes the execution
of the `onEditingChanged` closure at the start and end of
the gesture.

## Discussion

Use `Stepper(_:value:in:step:format:onEditingChanged:)` to create a
stepper that increments or decrements a value within a specific range
of values by a specific step size, while displaying the current value.
In the example below, a stepper increments or decrements a binding to
value over a range of `1...50` by `5` each time the user clicks or taps
the stepper’s increment or decrement buttons:

```
struct StepperView: View {
    @State private var value = 0.0
    private let step = 5.0
    private let range = 1.0...50.0

    var body: some View {
        Stepper("Stepping by \(step) in \(range.description)",
            value: $value,
            in: range,
            step: step,
            format: .number
        )
        .padding()
    }
}
```

---

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)