Skip to content

Stepper

Count things with minus and plus, such as pieces in a cart or guests on a booking, or type the number when it is far from the current one.

pcs
kg
<script setup lang="ts">import { ref } from 'vue'import { UiStepper } from 'grani' const qty = ref<string | null>('2') const kilos = ref<string | null>('4') const count = ref<string | null>('1') const adults = ref<string | null>('1')</script> <template>  <UiStepper v-model="qty" :min="1" :max="20" ariaLabel="Quantity">    <template #end>pcs</template>  </UiStepper>  <UiStepper v-model="kilos" :min="1" ariaLabel="Weight">    <template #end>kg</template>  </UiStepper>  <UiStepper v-model="count" :min="0" size="xs" ariaLabel="Count" />  <!-- One adult at least: the minus rests inert at the bound. -->  <UiStepper v-model="adults" :min="1" :max="9" ariaLabel="Adults" /></template>

Also called quantity input, counter, plus minus input, numeric stepper.

Usage

<UiStepper v-model="value" />

With GraniResolver in the Vite config, a template needs no import: set it up once.

API

Name · typeDefaultDescription
Value
modelValue*string | nullThe count as text (v-model): null when emptied. A number is plain text (12) parsed by its owner on use.
Behavior
stepnumber= 11How much a button or an arrow key moves the count.
minnumberThe lowest count the buttons and the arrows reach. Typing is not clamped: the form validates.
maxnumberThe highest count the buttons and the arrows reach.
Look
placeholderstringHint shown while empty. Not a replacement for a label.
sizexs | sm | mdStep of the control ladder. Unset, the app's size (createGrani({ size })), sm by default.
Form and access
namestringNative name for forms.
idstringOwn id when standalone. Inside UiField the field's id takes precedence.
readonlyboolean= falsefalsePrevents editing while keeping the count focusable: something else sets it.
disabledboolean= falsefalsePrevents input and interaction.
invalidboolean= falsefalseMarks the control invalid: red border and halo. Inside UiField the error sets this.
requiredboolean= falsefalseStandalone only: a count is needed, said to a reader and to a form. Inside UiField the field's required says so.
ariaLabelstringAccessible name when there is no visible label.

Attributes are placed by the component itself: its description says where.

When to use another component

When you needTake
A number with decimals or moneyInput numeric
A mark from 1 to NScale input