/*! For license information please see 8611.43c9d310.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["8611"],{49166:function(n,t,s){"use strict";s.r(t);var a=s("80681");let e=["innerHTML"];t.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'

Stepper

\n

Intro

\n

The stepper component consists of an increase button, a decrease button and an input box, which are used to input and adjust numbers within a certain range.

\n

Install

\n

Register component globally via app.use, refer to Component Registration for more registration ways.

\n
import { createApp } from 'vue';\nimport { Stepper } from 'vant';\n\nconst app = createApp();\napp.use(Stepper);\n
\n

Usage

\n

Basic Usage

\n
<van-stepper v-model="value" />\n
\n
import { ref } from 'vue';\n\nexport default {\n  setup() {\n    const value = ref(1);\n    return { value };\n  },\n};\n
\n

Step

\n
<van-stepper v-model="value" step="2" />\n
\n

Range

\n
<van-stepper v-model="value" min="5" max="8" />\n
\n

Integer

\n
<van-stepper v-model="value" integer />\n
\n

Disabled

\n
<van-stepper v-model="value" disabled />\n
\n

Disable Input

\n
<van-stepper v-model="value" disable-input />\n
\n

Decimal Length

\n
<van-stepper v-model="value" step="0.2" :decimal-length="1" />\n
\n

Custom Size

\n
<van-stepper v-model="value" input-width="40px" button-size="32px" />\n
\n

Before Change

\n
<van-stepper v-model="value" :before-change="beforeChange" />\n
\n
import { ref } from 'vue';\nimport { closeToast, showLoadingToast } from 'vant';\n\nexport default {\n  setup() {\n    const value = ref(1);\n\n    const beforeChange = (value) => {\n      showLoadingToast({ forbidClick: true });\n\n      return new Promise((resolve) => {\n        setTimeout(() => {\n          closeToast();\n          // resolve 'true' or 'false'\n          resolve(true);\n        }, 500);\n      });\n    };\n\n    return {\n      value,\n      beforeChange,\n    };\n  },\n};\n
\n

Round Theme

\n
<van-stepper v-model="value" theme="round" button-size="22" disable-input />\n
\n

API

\n

Props

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
AttributeDescriptionTypeDefault
v-modelCurrent valuenumber | string-
minMin valuenumber | string1
maxMax valuenumber | string-
auto-fixedWhether to auto fix value that is out of range, set to false and value that is out of range won\u2019t be auto fixedbooleantrue
default-valueDefault value, valid when v-model is emptynumber | string1
stepValue change stepnumber | string1
nameStepper name, usually a unique string or numbernumber | string-
input-widthInput widthnumber | string32px
button-sizeButton sizenumber | string28px
decimal-lengthDecimal lengthnumber | string-
themeTheme, can be set to roundstring-
placeholderInput placeholderstring-
integerWhether to allow only integersbooleanfalse
disabledWhether to disable value changebooleanfalse
disable-plusWhether to disable plus buttonbooleanfalse
disable-minusWhether to disable minus buttonbooleanfalse
disable-inputWhether to disable inputbooleanfalse
before-changeCallback function before changing, return false to prevent change, support return Promise(value: number | string) => boolean | Promise<boolean>false
show-plusWhether to show plus buttonbooleantrue
show-minusWhether to show minus buttonbooleantrue
show-inputWhether to show inputbooleantrue
long-pressWhether to enable the long press gesture, when enabled you can long press the increase and decrease buttonsbooleantrue
allow-emptyWhether to allow the input value to be empty, set to true to allow an empty string to be passed inbooleanfalse
\n

Events

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
EventDescriptionArguments
changeEmitted when value changedvalue: string, detail: { name: string }
overlimitEmitted when a disabled button is clicked-
plusEmitted when the plus button is clicked-
minusEmitted when the minus button is clicked-
focusEmitted when the input is focusedevent: Event
blurEmitted when the input is blurredevent: Event
\n

Types

\n

The component exports the following type definitions:

\n
import type { StepperTheme, StepperProps } from 'vant';\n
\n

Theming

\n

CSS Variables

\n

The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
NameDefault ValueDescription
--van-stepper-backgroundvar(--van-active-color)-
--van-stepper-button-icon-colorvar(--van-text-color)-
--van-stepper-button-disabled-colorvar(--van-background)-
--van-stepper-button-disabled-icon-colorvar(--van-gray-5)-
--van-stepper-button-round-theme-colorvar(--van-primary-color)-
--van-stepper-input-width32px-
--van-stepper-input-height28px-
--van-stepper-input-font-sizevar(--van-font-size-md)-
--van-stepper-input-line-heightnormal-
--van-stepper-input-text-colorvar(--van-text-color)-
--van-stepper-input-disabled-text-colorvar(--van-text-color-3)-
--van-stepper-input-disabled-backgroundvar(--van-active-color)-
--van-stepper-radiusvar(--van-radius-md)-
\n
'},null,8,e))}}}]);