Skip to content

Number Field

SNumberField is a number input with "plus"/"minus" buttons. It is built on Reka UI (the spinbutton role, arrow-key stepping, min/max bounds, formatting) and reuses SFormField (label, hint, error message, a11y), SButton-like step buttons and SIcon. The value is bound with v-model.

Basic usage

Step

States and placeholder

required marks the field as required, error shows an error message and makes the field invalid (explicit invalid does the same), disabled blocks the field and the step buttons, placeholder is visible while the field is empty.

When this is not the right component

SNumberField is a stepper: a border with "minus" and "plus" buttons at the edges, and those buttons cannot be turned off. It does not fit a form field that needs plain input with a unit on the right — use SInput with the numeric prop instead: it has the same precision and bounds constraints, plus suffix, slots and size.

vue
<template>
  <!-- counter: stepping matters more than typing -->
  <SNumberField
    v-model="quantity"
    :min="1"
    :max="99"
    label="Quantity"
  />

  <!-- form field: typing and the unit matter -->
  <SInput
    v-model="weight"
    :numeric="{ decimals: 2, unsigned: true }"
    suffix="kg"
    label="Weight"
  />
</template>

API

Props

NameTypeDefaultDescription
idstringundefinedControl id. Generated automatically (SSR-safe) when not set.
labelstringundefinedField label.
hintstringundefinedHint below the field.
errorstringundefinedError message. When set, the field is marked invalid.
invalidbooleanfalseMarks the field invalid explicitly (in addition to error).
squarebooleanundefinedSquare corners: removes the field border rounding (rounded by default).
requiredbooleanfalseMarks the field as required.
disabledbooleanfalseDisables the field and the step buttons.
minnumberundefinedMinimum value.
maxnumberundefinedMaximum value.
stepnumber1Step for the plus/minus buttons and arrow keys.
placeholderstringundefinedPlaceholder in an empty field.
decrement-labelstringundefinedAccessible name of the decrement button (taken from the locale dictionary by default).
increment-labelstringundefinedAccessible name of the increment button (taken from the locale dictionary by default).
model-valuenull | numbernullNumeric value of the field. Two-way binding via v-model.

Events

NameSignatureDescription
update:modelValue(value: number | null) => voidEmitted when modelValue changes. Used for two-way binding (v-model).