Components
Stepper
Adjust a number with increment and decrement buttons.
Example
Requires React 18.2+ or 19 and shared styles. See setup.
Controlled
Loading preview…
Code
'use client';
import { useState } from 'react';
import { Stepper } from '@swiftuijs/ui';
import { VStack } from '@swiftuijs/ui';
import { Text } from '@swiftuijs/ui';
const ControlledDemo = () => {
const [value, setValue] = useState(5);
return (<VStack spacing={16}>
<Text>Controlled value: {value}</Text>
<Stepper value={value} onValueChange={setValue}/>
</VStack>);
};
export default function Example() {
return (<ControlledDemo />);
}Usage and limitations
- Controlled:
value; uncontrolled:defaultValue.onValueChangeandonChangereceive the numeric update. min,max, andstepconstrain changes; buttons disable at the bounds.disableddisables the control.- Keep both buttons visible and labeled; display the value in the surrounding form when needed.
More examples
Uncontrolled Usage
Bounded Usage
API reference
| 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.