Stepper
Decimal stepping, committed input and repeated long presses. Controlled values remain owned by the parent.
Import
With uni-app easycom, use hui-stepper。 Standalone Vue imports @nscode/handy-uni/web HuiStepper or installs the preview plugin.
Examples
Interaction and event results
Interact with the control. The latest event and its full payload are shown below. Popup selectors commit only after confirmation; cancellation keeps the previous value.
vue
<script setup lang="ts">
import { ref } from 'vue'
const result = ref('')
const value = ref(0.1)
function event0(arg0: unknown) {
result.value = 'update:modelValue' + ': ' + JSON.stringify([arg0])
}
function event1(arg0: unknown) {
result.value = 'change' + ': ' + JSON.stringify([arg0])
}
function event2(arg0: unknown) {
result.value = 'overlimit' + ': ' + JSON.stringify([arg0])
}
function event3(arg0: unknown) {
result.value = 'focus' + ': ' + JSON.stringify([arg0])
}
function event4(arg0: unknown) {
result.value = 'blur' + ': ' + JSON.stringify([arg0])
}
</script>
<template>
<view>
<hui-stepper
v-model="value"
:min="0"
:max="10"
:step="0.2"
@update:model-value="event0"
@change="event1"
@overlimit="event2"
@focus="event3"
@blur="event4"
></hui-stepper>
<text aria-live="polite">{{ result }}</text>
</view>
</template>
Props
| Property | Type | Default | Description |
|---|---|---|---|
model-value | number | null | undefined | undefined | Controlled committed value; display remains unchanged until the parent writes back. |
default-value | number | null | undefined | null | Initial uncontrolled value. |
min | number | undefined | -Infinity | Numeric min bound; negative bounds use a text keyboard that permits a minus sign. |
max | number | undefined | Infinity | Numeric max bound. |
step | number | undefined | 1 | Positive step; invalid or nonpositive values use one. |
precision | number | undefined | — | Committed and displayed decimal precision; display pads trailing zeroes. Inferred when omitted. |
allow-empty | boolean | undefined | false | Allow null on empty input; otherwise restore min or zero. |
disabled | boolean | undefined | false | Disable user interaction, including inherited form state. |
readonly | boolean | undefined | undefined | Readonly; inherit form context when omitted. |
disable-input | boolean | undefined | false | Disable input while retaining step buttons. |
long-press | boolean | undefined | true | Repeat every 100ms after a 400ms long press. |
before-change | ((value: number | null, context: { action: StepperAction; }) => boolean | void | Promise<boolean | void>) | undefined | — | Asynchronous change guard; repeated interaction waits. |
placeholder | string | undefined | — | Placeholder for an empty value. |
input-width | number | undefined | — | Input width in pixels. |
size | ComponentSize | undefined | — | small, default or large size. |
aria-label | string | undefined | — | Accessible input name; defaults to the FormItem label. |
custom-class | string | undefined | '' | Additional root classes. |
custom-style | string | CSSProperties | undefined | — | Additional root styles. |
Events
| Event | Parameters | Description |
|---|---|---|
update:modelValue | (value: number | null) | Requests a controlled value update. |
change | (value: number | null) | Reports change with the arguments shown in the example. |
overlimit | (action: "plus" | "minus") | Reports overlimit with the arguments shown in the example. |
focus | (event: unknown) | Reports focus with the arguments shown in the example. |
blur | (event: unknown) | Reports blur with the arguments shown in the example. |
Slots
| Slot | Description |
|---|
Methods
| Method | Signature |
|---|---|
focus | () => void |
blur | () => void |
Types
StepperProps、StepperEmits、StepperExpose。 Public types are exported from the package entry.
Platform notes
| Scope | Behavior and validation limits |
|---|---|
| Shared implementation | All targets share numeric commits, bounds and async guards. Touch long presses repeat changes and suppress the following click. |
| Device checks pending | Check native confirm, blur, numeric keyboards and long presses on WeChat and App; also check keyboard and mouse input in ordinary Vue. |
See examples/uni-demo/smoke/Stepper.md for the checklist. Unit tests do not replace device acceptance.