Stepper
Stepper is a control for incrementing or decrementing a numeric value. It supports both controlled and uncontrolled usage and exposes semantic increment/decrement buttons.
Stepper is a control for incrementing or decrementing a numeric value. It supports both controlled and uncontrolled usage and exposes semantic increment/decrement buttons.
Examples
Basic Usage
Preview unavailable for this example in the static docs build.
Show code
const ControlledDemo = () => {
const [value, setValue] = useState(5)
return (
<VStack spacing={16}>
<Text>Controlled value: {value}</Text>
<Stepper
value={value}
onValueChange={setValue}
/>
</VStack>
)
}Uncontrolled Usage
Preview unavailable for this example in the static docs build.
Show code
const UncontrolledDemo = () => {
const [value, setValue] = useState(2)
return (
<VStack spacing={16}>
<Text>Observed value: {value}</Text>
<Stepper
defaultValue={2}
onChange={setValue}
/>
</VStack>
)
}Bounded Usage
Preview unavailable for this example in the static docs build.
Show code
const BoundedDemo = () => {
const [value, setValue] = useState(1)
return (
<VStack spacing={16}>
<Text>Bounded value: {value}</Text>
<Stepper
value={value}
onValueChange={setValue}
min={0}
max={4}
step={2}
/>
</VStack>
)
}API
| Prop | Type | Required | Description |
|---|---|---|---|
value | number | No | The current value when used in controlled mode. |
defaultValue | number | No | The initial value when used in uncontrolled mode. Default: 0 |
onChange | (value: number) => void | No | Native-style change callback with the next numeric value. |
onValueChange | (value: number) => void | No | SwiftUI-style value callback. |
min | number | No | The minimum value allowed. |
max | number | No | The maximum value allowed. |
step | number | No | The step amount for each increment/decrement. Default: 1 |
disabled | boolean | No | Whether the stepper is disabled. Default: false |
Inherits additional props from IBaseComponent.
Overview
Stepper is a control for incrementing or decrementing a numeric value. It supports both controlled and uncontrolled usage and exposes semantic increment/decrement buttons.
SwiftUI Correspondence: Similar to SwiftUI's Stepper.
Notes
valuemakes the control controlleddefaultValueinitializes uncontrolled state- Use
onValueChangeoronChangeto observe updates - Stepper supports optional
min,max, andstepconstraints - Stepper can be disabled with the
disabledprop - Buttons disable automatically at the current bounds
- Use Stepper for precise numeric value adjustment
Best Practices
- Constraints: Set appropriate
minandmaxvalues - State: Prefer controlled
valuewhen the source of truth lives outside the component - Updates: Use
defaultValuefor local state andonValueChangeto observe changes - Feedback: Show the current value to the user when the stepper is part of a larger form
- Accessibility: Keep the increment and decrement buttons visible and labeled
Spacer
Spacer is a flexible space that expands along the major axis of its parent container. Spacer is used to push content apart and create flexible layouts.
SwipeActions
SwipeActions adapts SwiftUI's swipe-revealed row actions into an explicit, accessible web row wrapper. On the web, actions are revealed with a toggle instead of relying on touch-only gestures.